Browse Source

Added option for hiding the From location on the stock holding relocation window

Kenric Nugteren 1 year ago
parent
commit
6d487b97e0

+ 5 - 3
prs.desktop/Panels/Products/Locations/StockHoldingRelocationWindow.xaml

@@ -24,7 +24,7 @@
             <ColumnDefinition Width="*"/>
         </Grid.ColumnDefinitions>
 
-        <Grid Grid.Row="0" Margin="5">
+        <Grid Grid.Row="0" Margin="5" Visibility="{Binding ShowHeader,Converter={StaticResource boolToVisibilityConverter}}">
             <Grid.ColumnDefinitions>
                 <ColumnDefinition Width="Auto"/>
                 <ColumnDefinition Width="Auto"/>
@@ -63,7 +63,8 @@
                 Grid.Column="0"
                 VerticalAlignment="Center" 
                 Content="From:" 
-                FontWeight="Bold"/>
+                FontWeight="Bold"
+                Visibility="{Binding ShowFrom,Converter={StaticResource boolToVisibilityConverter}}"/>
             
             <TextBox 
                 Grid.Column="1"
@@ -72,7 +73,8 @@
                 IsEnabled="False" 
                 Text="{Binding From.Location.Code}" 
                 VerticalContentAlignment="Center"
-                Background="WhiteSmoke"/>
+                Background="WhiteSmoke"
+                Visibility="{Binding ShowFrom,Converter={StaticResource boolToVisibilityConverter}}"/>
             
             <Label 
                 Grid.Column="2"

+ 18 - 0
prs.desktop/Panels/Products/Locations/StockHoldingRelocationWindow.xaml.cs

@@ -57,6 +57,7 @@ public class StockHoldingRelocationItem : INotifyPropertyChanged
 
     public JobRequisitionItem JRI { get; set; }
 
+
     public event PropertyChangedEventHandler? PropertyChanged;
 
     protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
@@ -98,6 +99,20 @@ public partial class StockHoldingRelocationWindow : Window, INotifyPropertyChang
 
     public StockHolding From { get; private init; }
 
+    public bool ShowHeader => ShowFrom || IsTargetEditable || IsJobEditable;
+
+    private bool _showFrom = true;
+    public bool ShowFrom
+    {
+        get => _showFrom;
+        set
+        {
+            _showFrom = value;
+            OnPropertyChanged();
+            OnPropertyChanged(nameof(ShowHeader));
+        }
+    }
+
     private bool _isTargetEditable = true;
     public bool IsTargetEditable
     {
@@ -106,6 +121,7 @@ public partial class StockHoldingRelocationWindow : Window, INotifyPropertyChang
         {
             _isTargetEditable = value;
             OnPropertyChanged();
+            OnPropertyChanged(nameof(ShowHeader));
         }
     }
 
@@ -117,6 +133,7 @@ public partial class StockHoldingRelocationWindow : Window, INotifyPropertyChang
         {
             _isJobEditable = value;
             OnPropertyChanged();
+            OnPropertyChanged(nameof(ShowHeader));
         }
     }
 
@@ -229,6 +246,7 @@ public partial class StockHoldingRelocationWindow : Window, INotifyPropertyChang
                 ID = item.ID,
                 JRI = item
             };
+
             newItem.PropertyChanged += (o, e) => Recalculate();
             if(item.ID == Guid.Empty)
             {