Skip to content

Commit

Permalink
PG-1260
Browse files Browse the repository at this point in the history
  + fixed issue in ERP Item tabs, where Create button was not clickable because entityUnlocked variable scrope prevented access within click-handlers
  • Loading branch information
coolOrange-Public committed Nov 30, 2022
1 parent 836d8a9 commit b32044f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Files/powerEvents/Events/TransferERPItemTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<Label Content="Number" Grid.Row="0" Grid.Column="0" />
<TextBox Text="{Binding Number}" Grid.Row="0" Grid.Column="1" IsReadOnly="True" />
<Label Content="Description" Grid.Column="0" Grid.Row="1" />
<TextBox x:Name="Description" Text="{Binding Description}" Grid.Column="1" Grid.Row="1" />
<TextBox x:Name="Description" Text="{Binding Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" Grid.Row="1" />

<Label Content="Blocked" Grid.Column="0" Grid.Row="2" />
<CheckBox IsChecked="{Binding IsBlocked}" Grid.Column="1" Grid.Row="2" IsEnabled="False" />
Expand Down
7 changes: 3 additions & 4 deletions Files/powerEvents/Events/TransferERPItemViaFileTab.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Remove-CoolOrangeLogging
$logPath = Join-Path $env:LOCALAPPDATA "coolOrange\Projects\VDS_Vault-powerGate.log"
Set-LogFilePath -Path $logPath


function CanCreateOrUpdateErpMaterial {
param(
$erpMaterial
Expand Down Expand Up @@ -80,7 +79,7 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'File' -Action {
$Script:erpItemTab_CreateOrUpdateMaterialButton = $erpItemTab_control.FindName('CreateOrUpdateMaterialButton')
$erpItemTab_GoToMaterialButton = $erpItemTab_control.FindName('GoToMaterialButton')

$erpMaterial = Get-ERPObject -EntitySet "Materials" -Keys @{ Number = $selectedFile._PartNumber }
$Script:erpMaterial = Get-ERPObject -EntitySet "Materials" -Keys @{ Number = $selectedFile._PartNumber }
if(-not $?) {
$statusMessage_label.Content = $Error[0]
$statusMessage_label.Foreground = "Red"
Expand All @@ -91,7 +90,7 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'File' -Action {
if (-not $erpMaterial) {
$statusMessage_label.Content = 'ERP: Create Material'

$erpMaterial = NewErpMaterial
$Script:erpMaterial = NewErpMaterial
$erpMaterial = PrepareErpMaterialForCreate -erpMaterial $erpMaterial -vaultEntity $selectedFile

$erpItemTab_CreateOrUpdateMaterialButton.Content = 'Create ERP Item'
Expand Down Expand Up @@ -141,7 +140,7 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'File' -Action {
}
$erpItemTab_control.DataContext = $erpMaterial

$entityUnlocked = $selectedFile._VaultStatus.Status.LockState -ne "Locked" -and $selectedFile.IsCheckedOut -ne $true
$Script:entityUnlocked = $selectedFile._VaultStatus.Status.LockState -ne "Locked" -and $selectedFile.IsCheckedOut -ne $true
$erpItemTab_LinkMaterialButton = $erpItemTab_control.FindName('LinkMaterialButton')
$erpItemTab_LinkMaterialButton.IsEnabled = $entityUnlocked
$erpItemTab_LinkMaterialButton.Add_Click({
Expand Down
12 changes: 5 additions & 7 deletions Files/powerEvents/Events/TransferERPItemViaItemTab.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'Item' -Action {
param($selectedItem)
$erpItemTab_control = [Windows.Markup.XamlReader]::Load([System.Xml.XmlNodeReader]::new([xml](Get-Content "$PSScriptRoot\TransferERPItemTab.xaml")))

$statusMessage_label = $erpItemTab_control.FindName("lblStatusMessage")
$statusMessage_label = $erpItemTab_control.FindName('lblStatusMessage')
$erpServices = Get-ERPServices -Available
if (-not $erpServices) {
$statusMessage_label.Content = "One or more services are not available!"
Expand All @@ -78,7 +78,7 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'Item' -Action {
$Script:erpItemTab_CreateOrUpdateMaterialButton = $erpItemTab_control.FindName('CreateOrUpdateMaterialButton')
$erpItemTab_GoToMaterialButton = $erpItemTab_control.FindName('GoToMaterialButton')

$erpMaterial = Get-ERPObject -EntitySet "Materials" -Keys @{ Number = $selectedItem._Number }
$Script:erpMaterial = Get-ERPObject -EntitySet "Materials" -Keys @{ Number = $selectedItem._Number }
if(-not $?) {
$statusMessage_label.Content = $Error[0]
$statusMessage_label.Foreground = "Red"
Expand All @@ -89,7 +89,7 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'Item' -Action {
if (-not $erpMaterial) {
$statusMessage_label.Content = 'ERP: Create Material'

$erpMaterial = NewErpMaterial
$Script:erpMaterial = NewErpMaterial
$erpMaterial = PrepareErpMaterialForCreate -erpMaterial $erpMaterial -vaultEntity $selectedItem

$erpItemTab_CreateOrUpdateMaterialButton.Content = 'Create ERP Item'
Expand Down Expand Up @@ -139,11 +139,9 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'Item' -Action {
}
$erpItemTab_control.DataContext = $erpMaterial

$item = $vault.ItemService.GetLatestItemByItemMasterId($selectedItem.MasterId)
$entityUnlocked =$item.Locked -ne $true

$Script:entityUnlocked = $vault.ItemService.GetLatestItemByItemMasterId($selectedItem.MasterId).Locked -ne $true
$erpItemTab_LinkMaterialButton = $erpItemTab_control.FindName('LinkMaterialButton')
$erpItemTab_LinkMaterialButton.IsEnabled = $item.Locked -ne $true
$erpItemTab_LinkMaterialButton.IsEnabled = $entityUnlocked
$erpItemTab_LinkMaterialButton.Add_Click({
param($Sender, $EventArgs)

Expand Down

0 comments on commit b32044f

Please sign in to comment.