Ver Fonte

Added scope link to Job forms and Kanbans

Kenric Nugteren há 1 ano atrás
pai
commit
88061011ab

+ 2 - 0
prs.classes/Entities/Job/JobForm.cs

@@ -4,6 +4,8 @@ namespace Comal.Classes
 {
     public class JobForm : EntityForm<Job, JobLink, JobForm>, IDigitalForm<Job>, ILicense<ProjectManagementLicense>
     {
+        public JobScopeLink JobScope { get; set; }
+
         public override string AutoIncrementPrefix() => "JF";
     }
 }

+ 18 - 3
prs.classes/Entities/Job/JobScopes/JobScopeLookups.cs

@@ -4,7 +4,7 @@ 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, RequisitionItem>, ILookupDefinition<JobScope, Requisition>
+        , ILookupDefinition<JobScope, Assignment>, ILookupDefinition<JobScope, Kanban>, ILookupDefinition<JobScope, RequisitionItem>, ILookupDefinition<JobScope, Requisition>
     {
         
         #region Invoice Lines
@@ -104,9 +104,24 @@ namespace Comal.Classes
         
         Columns<Requisition> ILookupDefinition<JobScope, Requisition>.DefineFilterColumns()
             => new Columns<Requisition>(x=>x.JobLink.ID);
-        
+
         #endregion
-        
+
+        #region
+
+        public Filter<JobScope> DefineFilter(Kanban[] items)
+        {
+            var item = items?.Length == 1 ? items[0] : null;
+            if (item != null)
+                return new Filter<JobScope>(x => x.Job.ID).IsEqualTo(item.JobLink.ID).And(x => x.Status.Approved).IsEqualTo(true);
+            return new Filter<JobScope>(x => x.ID).None();
+        }
+
+        Columns<Kanban> ILookupDefinition<JobScope, Kanban>.DefineFilterColumns()
+            => new Columns<Kanban>(x => x.JobLink.ID);
+
+        #endregion
+
         public override Columns<JobScope> DefineColumns()
         {
             return new Columns<JobScope>().Default();

+ 17 - 10
prs.classes/Entities/Kanban/Kanban.cs

@@ -42,7 +42,7 @@ namespace Comal.Classes
     [UserTracking("Task Management")]
     [Caption("Tasks")]
     public class Kanban : Entity, IPersistent, IRemotable, IKanban, IScheduleAction, IOneToMany<Schedule>, INumericAutoIncrement<Kanban>,
-        IOneToMany<Equipment>, ILicense<TaskManagementLicense>, IExportable, IImportable
+        IOneToMany<Equipment>, ILicense<TaskManagementLicense>, IExportable, IImportable, IJobScopedItem
     {
         
         public static String OPEN => "Open";
@@ -66,39 +66,41 @@ namespace Comal.Classes
         public string Title { get; set; }
 
         [EditorSequence(1)]
-        [Caption("Attached to")]
         public JobLink JobLink { get; set; }
 
-        [RichTextEditor]
         [EditorSequence(2)]
+        public JobScopeLink JobScope { get; set; }
+
+        [RichTextEditor]
+        [EditorSequence(3)]
         public string Description { get; set; }
 
         [NotesEditor]
-        [EditorSequence(3)]
+        [EditorSequence(4)]
         public string[] Notes { get; set; } = Array.Empty<string>();
 
         [MemoEditor(Visible = Visible.Optional, Editable = Editable.Hidden)]
-        [EditorSequence(4)]
+        [EditorSequence(5)]
         public string Summary { get; set; }
 
-        [EditorSequence(5)]
+        [EditorSequence(6)]
         [Caption("Task Type")]
         public KanbanTypeLink Type { get; set; }
 
         [DateEditor]
-        [EditorSequence(6)]
+        [EditorSequence(7)]
         public DateTime DueDate { get; set; } = DateTime.Today;
 
-        [EditorSequence(7)]
+        [EditorSequence(8)]
         [Caption("Assigned To")]
         public EmployeeLink EmployeeLink { get; set; }
 
-        [EditorSequence(8)]
+        [EditorSequence(9)]
         [Caption("Allocated By")]
         public EmployeeLink ManagerLink { get; set; }
 
         [DateTimeEditor(Editable = Editable.Hidden)]
-        [EditorSequence(9)]
+        [EditorSequence(10)]
         public DateTime Completed { get; set; } = DateTime.MinValue;
 
         [EditorSequence("Other", 1)]
@@ -206,6 +208,11 @@ namespace Comal.Classes
             bChanging = false;
         }
 
+        static Kanban()
+        {
+            Classes.JobScope.LinkScopeProperties<Kanban>();
+        }
+
         private class KanbanCategoryLookups : LookupGenerator<object>
         {
             public KanbanCategoryLookups(object[] items) : base(items)

+ 1 - 0
prs.classes/Entities/Manufacturing/ManufacturingPacket/ManufacturingPacketStage.cs

@@ -116,6 +116,7 @@ namespace Comal.Classes
         {
             return Parent.ID;
         }
+        public Type ParentType() => typeof(ManufacturingPacket);
 
         [NullEditor]
         [Obsolete("Being Replaced by FormData")]

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

@@ -0,0 +1,30 @@
+using System;
+using Comal.Classes;
+using InABox.Core;
+using InABox.DynamicGrid;
+
+namespace PRSDesktop;
+
+public class JobScopeFormGrid : DynamicEntityFormGrid<JobForm, Job, JobLink>, IJobScopeGrid
+{
+    public JobScope? Scope { get; set; }
+
+    public JobScopeFormGrid(Job job): base(job)
+    {
+    }
+
+    protected override void DoReconfigure(FluentList<DynamicGridOption> options)
+    {
+        base.DoReconfigure(options);
+        options.Remove(DynamicGridOption.AddRows);
+    }
+
+    protected override void Reload(Filters<JobForm> criteria, Columns<JobForm> columns, ref SortOrder<JobForm>? sort, Action<CoreTable?, Exception?> action)
+    {
+        if ((Scope == null) || (Scope.ID == Guid.Empty))
+            criteria.Add(new Filter<JobForm>(x => x.ID).None());
+        else
+            criteria.Add(new Filter<JobForm>(x => x.JobScope.ID).IsEqualTo(Scope.ID));
+        base.Reload(criteria, columns, ref sort, action);
+    }
+}

+ 26 - 0
prs.desktop/Panels/Jobs/JobScopes/JobScopeKanbanGrid.cs

@@ -0,0 +1,26 @@
+using System;
+using Comal.Classes;
+using InABox.Core;
+using InABox.DynamicGrid;
+
+namespace PRSDesktop;
+
+public class JobScopeKanbanGrid : DynamicDataGrid<Kanban>, IJobScopeGrid
+{
+    public JobScope? Scope { get; set; }
+
+    protected override void DoReconfigure(FluentList<DynamicGridOption> options)
+    {
+        base.DoReconfigure(options);
+        options.Remove(DynamicGridOption.AddRows);
+    }
+
+    protected override void Reload(Filters<Kanban> criteria, Columns<Kanban> columns, ref SortOrder<Kanban>? sort, Action<CoreTable?, Exception?> action)
+    {
+        if ((Scope == null) || (Scope.ID == Guid.Empty))
+            criteria.Add(new Filter<Kanban>(x => x.ID).None());
+        else
+            criteria.Add(new Filter<Kanban>(x => x.JobScope.ID).IsEqualTo(Scope.ID));
+        base.Reload(criteria, columns, ref sort, action);
+    }
+}

+ 2 - 0
prs.desktop/Panels/Jobs/JobScopes/JobScopePanel.xaml

@@ -38,6 +38,8 @@
                     <dynamicGrid:DynamicTabItem Header="Delivery Items" x:Name="_deliveryItems" />
                     <dynamicGrid:DynamicTabItem Header="Activities" x:Name="_assignments" />
                     <dynamicGrid:DynamicTabItem Header="Documents" x:Name="_documents" />
+                    <dynamicGrid:DynamicTabItem Header="Tasks" x:Name="_kanbans" />
+                    <dynamicGrid:DynamicTabItem Header="Forms" x:Name="_forms" />
                 </dynamicGrid:DynamicTabControl.Items>
             </dynamicGrid:DynamicTabControl>
         </dynamicGrid:DynamicSplitPanel.Detail>

+ 18 - 4
prs.desktop/Panels/Jobs/JobScopes/JobScopePanel.xaml.cs

@@ -19,7 +19,9 @@ public partial class JobScopePanel : UserControl, IPanel<JobScope>, IJobControl
         ManufacturingPackets,
         DeliveryItems,
         Assignments,
-        Documents
+        Documents,
+        Tasks,
+        Forms,
     }
             
     private int _currentPage = -1;
@@ -27,6 +29,8 @@ public partial class JobScopePanel : UserControl, IPanel<JobScope>, IJobControl
     private JobScopeRequisitionItemGrid? _requisitionItemsGrid;
     private JobScopeAssignmentGrid? _assignmentGrid;
     private JobScopeDocumentGrid? _documentGrid;
+    private JobScopeKanbanGrid? _kanbanGrid;
+    private JobScopeFormGrid? _formGrid;
 
     public JobScopePanel()
     {
@@ -89,6 +93,12 @@ public partial class JobScopePanel : UserControl, IPanel<JobScope>, IJobControl
             case PageIndex.Documents:
                 RefreshGrid(_documents, ref _documentGrid, scope);
                 break;
+            case PageIndex.Tasks:
+                RefreshGrid(_kanbans, ref _kanbanGrid, scope);
+                break;
+            case PageIndex.Forms:
+                RefreshGrid(_forms, ref _formGrid, scope, () => new JobScopeFormGrid(Job));
+                break;
         }
     }
 
@@ -113,13 +123,17 @@ public partial class JobScopePanel : UserControl, IPanel<JobScope>, IJobControl
     {
         RefreshPage();
     }
-    
-    private void RefreshGrid<T>(TabItem container, ref T? grid, JobScope? scope) where T : IDynamicGrid, IJobScopeGrid, new()
+
+    private void RefreshGrid<T>(TabItem container, ref T? grid, JobScope? scope) where T : IDynamicGrid, IJobScopeGrid, new() =>
+        RefreshGrid(container, ref grid, scope, () => new T());
+
+    private void RefreshGrid<T>(TabItem container, ref T? grid, JobScope? scope, Func<T> newGrid)
+        where T : IDynamicGrid, IJobScopeGrid
     {
         var bInitialised = grid != null;
         if (!bInitialised)
         {
-            grid = new T();
+            grid = newGrid();
             container.Content = grid;
         }
         grid.Scope = scope;