Browse Source

Fixed Jobscopeform lookup; hid jobscope lookup on editor.

Kenric Nugteren 1 year ago
parent
commit
ddc6439d0f

+ 26 - 4
prs.classes/Entities/Job/JobScopes/JobScopeLookups.cs

@@ -3,8 +3,15 @@ using InABox.Core;
 
 namespace Comal.Classes
 {
-    public class JobScopeLookups : EntityLookup<JobScope>, ILookupDefinition<JobScope, InvoiceLine>, ILookupDefinition<JobScope, Job>, ILookupDefinition<JobScope, StagingSetout>
-        , ILookupDefinition<JobScope, Assignment>, ILookupDefinition<JobScope, Kanban>, ILookupDefinition<JobScope, RequisitionItem>, ILookupDefinition<JobScope, Requisition>
+    public class JobScopeLookups : EntityLookup<JobScope>,
+        ILookupDefinition<JobScope, InvoiceLine>,
+        ILookupDefinition<JobScope, Job>,
+        ILookupDefinition<JobScope, StagingSetout>,
+        ILookupDefinition<JobScope, Assignment>,
+        ILookupDefinition<JobScope, Kanban>,
+        ILookupDefinition<JobScope, RequisitionItem>,
+        ILookupDefinition<JobScope, JobForm>,
+        ILookupDefinition<JobScope, Requisition>
     {
         
         #region Invoice Lines
@@ -107,8 +114,8 @@ namespace Comal.Classes
 
         #endregion
 
-        #region
-
+        #region Kanban
+         
         public Filter<JobScope> DefineFilter(Kanban[] items)
         {
             var item = items?.Length == 1 ? items[0] : null;
@@ -122,6 +129,21 @@ namespace Comal.Classes
 
         #endregion
 
+        #region JobForm
+
+        public Filter<JobScope> DefineFilter(JobForm[] items)
+        {
+            var item = items?.Length == 1 ? items[0] : null;
+            if (item != null)
+                return new Filter<JobScope>(x => x.Job.ID).IsEqualTo(item.Parent.ID).And(x => x.Status.Approved).IsEqualTo(true);
+            return new Filter<JobScope>(x => x.ID).None();
+        }
+
+        Columns<JobForm> ILookupDefinition<JobScope, JobForm>.DefineFilterColumns()
+            => new Columns<JobForm>(x => x.Parent.ID);
+
+        #endregion
+
         public override Columns<JobScope> DefineColumns()
         {
             return new Columns<JobScope>().Default();

+ 10 - 0
prs.desktop/Panels/Jobs/JobScopes/JobScopeFormGrid.cs

@@ -13,6 +13,16 @@ public class JobScopeFormGrid : DynamicEntityFormGrid<JobForm, Job, JobLink>, IJ
     {
     }
 
+    protected override void CustomiseEditor(JobForm[] items, DynamicGridColumn column, BaseEditor editor)
+    {
+        base.CustomiseEditor(items, column, editor);
+
+        if(column.ColumnName == nameof(JobForm.JobScope.ID))
+        {
+            editor.Editable = Editable.Hidden;
+        }
+    }
+
     protected override void DoReconfigure(FluentList<DynamicGridOption> options)
     {
         base.DoReconfigure(options);