Browse Source

Moved product mapping and job styles to their own tabs.

Kenric Nugteren 1 year ago
parent
commit
2eb20c5158

+ 1 - 1
prs.classes/Entities/Job/JobProductMapping.cs

@@ -5,7 +5,7 @@ using System.Text;
 
 namespace Comal.Classes
 {
-    public class JobProductMapping : Entity, IRemotable, IPersistent, IOneToMany<Job>, ILicense<ProjectManagementLicense>
+    public class JobProductMapping : Entity, IRemotable, IPersistent, ILicense<ProjectManagementLicense>
     {
         [CodeEditor(Editable = Editable.Enabled)]
         public string Code { get; set; }

+ 1 - 1
prs.classes/Entities/Job/JobStyle.cs

@@ -2,7 +2,7 @@
 
 namespace Comal.Classes
 {
-    public class JobStyle : Entity, IRemotable, IPersistent, IManyToMany<Job, ProductStyle>, ILicense<ProjectManagementLicense>
+    public class JobStyle : Entity, IRemotable, IPersistent, ILicense<ProjectManagementLicense>
     {
         [EntityRelationship(DeleteAction.Cascade)]
         [EditorSequence(1)]

+ 1 - 1
prs.desktop/Panels/DataEntry/DataEntryList.xaml.cs

@@ -391,7 +391,7 @@ public partial class DataEntryList : UserControl, ICorePanel, IDockPanel
         DoSelect(e.Rows);
     }
 
-    private void DoSelect(CoreRow[] rows)
+    private void DoSelect(CoreRow[]? rows)
     {
         var appliesTo = rows?.Length == 1
             ? rows[0].Get<DataEntryDocument, string>(x => x.Tag.AppliesTo)

+ 2 - 2
prs.desktop/Panels/Jobs/JobITPGrid.cs

@@ -77,13 +77,13 @@ public class JobITPGrid : DynamicDataGrid<JobITP>, IJobControl, IDataModelSource
         base.Reload(criteria, columns, ref sort, action);
     }
 
-    protected override Dictionary<string, object> EditorValueChanged(IDynamicEditorForm editor, JobITP[] items, string name, object value)
+    protected override Dictionary<string, object?> EditorValueChanged(IDynamicEditorForm editor, JobITP[] items, string name, object value)
     {
         var result = base.EditorValueChanged(editor, items, name, value);
         if (name == "ITPTypeLink.ID")
         {
             var type = typeof(IDynamicEnclosedListGrid<,>).MakeGenericType(typeof(JobITP), typeof(QAQuestion));
-            var page = editor.Pages.FirstOrDefault(x => x.GetType().GetInterface(type.Name) != null);
+            var page = editor.Pages?.FirstOrDefault(x => x.GetType().GetInterface(type.Name) != null);
             if (page != null)
             {
                 var template = new Client<DigitalForm>().Load(new Filter<DigitalForm>(x => x.ID).IsEqualTo(value)).FirstOrDefault();

+ 2 - 0
prs.desktop/Panels/Jobs/JobPanel.xaml

@@ -34,6 +34,8 @@
                 <dynamicgrid:DynamicTabItem Header="Documents" Name="Documents" />
                 <dynamicgrid:DynamicTabItem Header="Planning" Name="Stages" />
                 <dynamicgrid:DynamicTabItem Header="ITP Areas" Name="ITPs" />
+                <dynamicgrid:DynamicTabItem Header="Product Mappings" Name="ProductMappings" />
+                <dynamicgrid:DynamicTabItem Header="Product Styles" Name="ProductStyles" />
                 <dynamicgrid:DynamicTabItem Header="BOM" Name="BOM" />
                 <dynamicgrid:DynamicTabItem Header="Requisitions" Name="Requisitions" />
                 <dynamicgrid:DynamicTabItem Header="Orders" x:Name="Orders" />

+ 14 - 4
prs.desktop/Panels/Jobs/JobPanel.xaml.cs

@@ -16,6 +16,7 @@ using InABox.WPF;
 using Microsoft.Office.Interop.Outlook;
 using System.ComponentModel;
 using Selection = InABox.Core.Selection;
+using PRSDesktop.Panels.Jobs;
 
 namespace PRSDesktop
 {
@@ -43,6 +44,8 @@ namespace PRSDesktop
             Documents,
             Stages,
             ITPs,
+            ProductMappings,
+            ProductStyles,
             BOM,
             Requisitions,
             Orders,
@@ -70,6 +73,8 @@ namespace PRSDesktop
         private JobDocumentSetPanel? JobDocumentsPage;
         private JobStagesPanel? JobPlanningPage;
         private JobITPGrid? JobITPPage;
+        private JobProductMappingsGrid? ProductMappingsPage;
+        private JobProductStylesGrid? ProductStylesPage;
         private JobBillOfMaterialsPanel? JobBillOfMaterialsPage; 
         private JobRequisitionPanel? JobRequisitionsPage;
         private JobDesignList? JobDesignsPage;
@@ -209,6 +214,8 @@ namespace PRSDesktop
             Documents.Visibility = Security.CanView<JobDocumentSet>() ? Visibility.Visible : Visibility.Collapsed;
             Stages.Visibility = ClientFactory.IsSupported<JobStage>() ? Visibility.Visible : Visibility.Collapsed;
             ITPs.Visibility = ClientFactory.IsSupported<JobITP>() ? Visibility.Visible : Visibility.Collapsed;
+            ProductMappings.Visibility = ClientFactory.IsSupported<JobProductMapping>() ? Visibility.Visible : Visibility.Collapsed;
+            ProductStyles.Visibility = ClientFactory.IsSupported<JobStyle>() ? Visibility.Visible : Visibility.Collapsed;
             BOM.Visibility = ClientFactory.IsSupported<JobBillOfMaterials>() ? Visibility.Visible : Visibility.Collapsed;
             Requisitions.Visibility = ClientFactory.IsSupported<JobRequisition>() ? Visibility.Visible : Visibility.Collapsed;
             Orders.Visibility = ClientFactory.IsSupported<PurchaseOrderItem>() ? Visibility.Visible : Visibility.Collapsed;
@@ -377,9 +384,8 @@ namespace PRSDesktop
             var propertyEditor = new DynamicEditorForm(typeof(JobPanelSettings), pages, buttons);
             propertyEditor.OnDefineLookups += sender =>
             {
-                var editor = sender.EditorDefinition as ILookupEditor;
                 var colname = sender.ColumnName;
-                var values = editor.Values(colname, new [] { _settings });
+                var values = sender.LookupEditorDefinition.Values(colname, new [] { _settings });
                 sender.LoadLookups(values);
             };
             propertyEditor.OnEditorValueChanged += (sender, name, value) =>
@@ -417,7 +423,7 @@ namespace PRSDesktop
         {
         }
 
-        private void Timer_Tick(object sender, EventArgs e)
+        private void Timer_Tick(object? sender, EventArgs e)
         {
             if (lastselection < DateTime.Now.AddMilliseconds(-500))
             {
@@ -443,6 +449,10 @@ namespace PRSDesktop
                         break;
                     case PageIndex.ITPs : RefreshGrid(ITPs, ref JobITPPage, job);
                         break;
+                    case PageIndex.ProductMappings: RefreshGrid(ProductMappings, ref ProductMappingsPage, job);
+                        break;
+                    case PageIndex.ProductStyles: RefreshGrid(ProductStyles, ref ProductStylesPage, job);
+                        break;
                     case PageIndex.BOM : RefreshPanel(BOM, ref JobBillOfMaterialsPage, job);
                         break;
                     case PageIndex.Requisitions : RefreshPanel(Requisitions, ref JobRequisitionsPage, job);
@@ -496,7 +506,7 @@ namespace PRSDesktop
             }
         }
 
-        private void RefreshPanel<T>(TabItem container, ref T panel, Job job) where T : IBasePanel, IJobControl, new()
+        private void RefreshPanel<T>(TabItem container, ref T? panel, Job job) where T : IBasePanel, IJobControl, new()
         {
             if (panel == null)
             {

+ 46 - 0
prs.desktop/Panels/Jobs/JobProductMappingsGrid.cs

@@ -0,0 +1,46 @@
+using Comal.Classes;
+using InABox.Core;
+using InABox.DynamicGrid;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PRSDesktop.Panels.Jobs;
+
+public class JobProductMappingsGrid : DynamicDataGrid<JobProductMapping>, IJobControl, IDataModelSource
+{
+    public Job Job { get; set; }
+
+    JobPanelSettings IJobControl.Settings { get; set; }
+
+    public string SectionName => "Job Product Mappings";
+
+    public event DataModelUpdateEvent? OnUpdateDataModel;
+
+    protected override bool CanCreateItems()
+    {
+        return Job.ID != Guid.Empty;
+    }
+
+    protected override JobProductMapping CreateItem()
+    {
+        var result = base.CreateItem();
+        result.Job.ID = Job.ID;
+        result.Job.Synchronise(Job);
+        return result;
+    }
+
+    public DataModel DataModel(Selection selection)
+    {
+        var ids = ExtractValues(x => x.ID, selection).ToArray();
+        return new BaseDataModel<JobProductMapping>(new Filter<JobProductMapping>(x => x.ID).InList(ids));
+    }
+
+    protected override void Reload(Filters<JobProductMapping> criteria, Columns<JobProductMapping> columns, ref SortOrder<JobProductMapping>? sort, Action<CoreTable?, Exception?> action)
+    {
+        criteria.Add(new Filter<JobProductMapping>(x => x.Job.ID).IsEqualTo(Job.ID));
+        base.Reload(criteria, columns, ref sort, action);
+    }
+}

+ 46 - 0
prs.desktop/Panels/Jobs/JobProductStylesGrid.cs

@@ -0,0 +1,46 @@
+using Comal.Classes;
+using InABox.Core;
+using InABox.DynamicGrid;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PRSDesktop.Panels.Jobs;
+
+public class JobProductStylesGrid : DynamicDataGrid<JobStyle>, IJobControl, IDataModelSource
+{
+    public Job Job { get; set; }
+
+    JobPanelSettings IJobControl.Settings { get; set; }
+
+    public string SectionName => "Job Product Styles";
+
+    public event DataModelUpdateEvent? OnUpdateDataModel;
+
+    protected override bool CanCreateItems()
+    {
+        return Job.ID != Guid.Empty;
+    }
+
+    protected override JobStyle CreateItem()
+    {
+        var result = base.CreateItem();
+        result.Job.ID = Job.ID;
+        result.Job.Synchronise(Job);
+        return result;
+    }
+
+    public DataModel DataModel(Selection selection)
+    {
+        var ids = ExtractValues(x => x.ID, selection).ToArray();
+        return new BaseDataModel<JobStyle>(new Filter<JobStyle>(x => x.ID).InList(ids));
+    }
+
+    protected override void Reload(Filters<JobStyle> criteria, Columns<JobStyle> columns, ref SortOrder<JobStyle>? sort, Action<CoreTable?, Exception?> action)
+    {
+        criteria.Add(new Filter<JobStyle>(x => x.Job.ID).IsEqualTo(Job.ID));
+        base.Reload(criteria, columns, ref sort, action);
+    }
+}

+ 3 - 2
prs.desktop/Panels/Jobs/JobRequisitionItemGrid.cs

@@ -8,6 +8,7 @@ using Comal.Classes;
 using InABox.Clients;
 using InABox.Core;
 using InABox.DynamicGrid;
+using InABox.Wpf;
 using InABox.WPF;
 
 namespace PRSDesktop
@@ -35,7 +36,7 @@ namespace PRSDesktop
         {
             if(rows.Length == 0)
             {
-                MessageBox.Show("Please select at least one item to cancel.");
+                MessageWindow.ShowMessage("Please select at least one item to cancel.", "Select items");
                 return false;
             }
 
@@ -112,7 +113,7 @@ namespace PRSDesktop
                 return null;
             }))
             {
-                MessageBox.Show($"Created requisition {requisition.Number}");
+                MessageWindow.ShowMessage($"Created requisition {requisition.Number}", "Created Requisition");
                 return true;
             }
             else