Ver código fonte

Calculate button is no longer visible except when job type is service

Kenric Nugteren 2 semanas atrás
pai
commit
8be039ada7

+ 13 - 1
prs.desktop/Panels/Invoices/InvoiceLineGrid.cs

@@ -14,10 +14,22 @@ namespace PRSDesktop
 {
     internal class InvoiceLineGrid : DynamicDataGrid<InvoiceLine>
     {
+        private Job? _job;
+        public Job? Job
+        {
+            get => _job;
+            set
+            {
+                _job = value;
+                Reconfigure();
+            }
+        }
+
         protected override void Init()
         {
             base.Init();
-            AddEditButton("Calculate", PRSDesktop.Resources.costcentre.AsBitmapImage(), CalculateLines);
+            AddEditButton("Calculate", PRSDesktop.Resources.costcentre.AsBitmapImage(), CalculateLines,
+                isVisible: options => Job is not null && Job.JobType == JobType.Service);
         }
 
         protected override void DoReconfigure(DynamicGridOptions options)

+ 5 - 1
prs.desktop/Panels/Invoices/InvoicePanel.xaml.cs

@@ -72,7 +72,11 @@ public partial class InvoicePanel : UserControl, IPanel<Invoice>, IMasterDetailC
     public Job? Master
     {
         get => Invoices.Master;
-        set => Invoices.Master = value;
+        set
+        {
+            Invoices.Master = value;
+            Lines.Job = value;
+        }
     }
     
     public bool IsReady { get; set; }