|
@@ -1,4 +1,7 @@
|
|
|
using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Windows;
|
|
|
using Comal.Classes;
|
|
|
using InABox.Configuration;
|
|
|
using InABox.Core;
|
|
@@ -17,6 +20,49 @@ public class ProjectsPanelSettings : BaseObject, IUserConfigurationSettings, IMa
|
|
|
|
|
|
[NullEditor]
|
|
|
public Guid MasterID { get; set; }
|
|
|
+
|
|
|
+ private class VisiblePanelsGenerator : LookupGenerator<object>
|
|
|
+ {
|
|
|
+
|
|
|
+ public VisiblePanelsGenerator(object[] items) : base(items)
|
|
|
+ {
|
|
|
+ AddValue(typeof(JobDetails).EntityName().Split('.').Last(),"Details");
|
|
|
+ AddValue(typeof(JobScopePanel).EntityName().Split('.').Last(), "Scopes");
|
|
|
+ AddValue(typeof(JobDocumentSetPanel).EntityName().Split('.').Last(), "Documents");
|
|
|
+ AddValue(typeof(JobStagesPanel).EntityName().Split('.').Last(), "Stages");
|
|
|
+ AddValue(typeof(JobITPGrid).EntityName().Split('.').Last(), "ITPs");
|
|
|
+ AddValue(typeof(JobProductMappingsGrid).EntityName().Split('.').Last(), "Product Mappings");
|
|
|
+ AddValue(typeof(JobProductStylesGrid).EntityName().Split('.').Last(), "Product Styles");
|
|
|
+ AddValue(typeof(JobBillOfMaterialsPanel).EntityName().Split('.').Last(), "BOM");
|
|
|
+ AddValue(typeof(JobRequisitionPanel).EntityName().Split('.').Last(), "Requisitions");
|
|
|
+ AddValue(typeof(JobStockGrid).EntityName().Split('.').Last(), "Stock Holdings");
|
|
|
+ AddValue(typeof(JobPickingListPanel).EntityName().Split('.').Last(), "Picking Lists");
|
|
|
+ AddValue(typeof(JobOrderGrid).EntityName().Split('.').Last(), "Orders");
|
|
|
+ AddValue(typeof(JobDesignPanel).EntityName().Split('.').Last(), "Designs");
|
|
|
+ AddValue(typeof(ManufacturingGrid).EntityName().Split('.').Last(), "Manufacturing");
|
|
|
+ AddValue(typeof(ReadyToGoGrid).EntityName().Split('.').Last(), "Dispatch");
|
|
|
+ AddValue(typeof(DeliveryPanel).EntityName().Split('.').Last(), "Deliveries");
|
|
|
+ AddValue(typeof(DeliveredOnSiteGrid).EntityName().Split('.').Last(), "OnSite");
|
|
|
+ AddValue(typeof(TaskPanel).EntityName().Split('.').Last(), "Tasks");
|
|
|
+ AddValue(typeof(JobEquipmentGrid).EntityName().Split('.').Last(), "EquipmentTab");
|
|
|
+ AddValue(typeof(JobEmployeePanel).EntityName().Split('.').Last(), "Employees");
|
|
|
+ AddValue(typeof(JobTrackerGrid).EntityName().Split('.').Last(), "Trackers");
|
|
|
+ AddValue(typeof(JobAssignmentPanel).EntityName().Split('.').Last(), "Assignments");
|
|
|
+ AddValue(typeof(JobTimesheetGrid).EntityName().Split('.').Last(), "Timesheets");
|
|
|
+ AddValue(typeof(JobFormGrid).EntityName().Split('.').Last(), "Forms");
|
|
|
+ AddValue(typeof(InvoicePanel).EntityName().Split('.').Last(), "Invoices");
|
|
|
+ AddValue(typeof(JobSpreadsheetGrid).EntityName().Split('.').Last(), "Spreadsheets");
|
|
|
+ AddValue(typeof(JobSummaryPanel).EntityName().Split('.').Last(), "Summary");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ [CheckListEditor(typeof(VisiblePanelsGenerator))]
|
|
|
+ public Dictionary<string, bool> VisiblePanels { get; set; }
|
|
|
+
|
|
|
+ public ProjectsPanelSettings()
|
|
|
+ {
|
|
|
+ VisiblePanels = new Dictionary<string, bool>();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public class ProjectsPanel : MasterDetailPanel<Job,ProjectsGrid,ProjectsPanelSettings>
|
|
@@ -28,35 +74,71 @@ public class ProjectsPanel : MasterDetailPanel<Job,ProjectsGrid,ProjectsPanelSet
|
|
|
|
|
|
protected override string MasterColumnsTag => "Projects";
|
|
|
|
|
|
+
|
|
|
+ private void SetPageVisible(Type type, IMasterDetailPage? page)
|
|
|
+ {
|
|
|
+ if (page is null)
|
|
|
+ return;
|
|
|
+ var isvisible = Settings.VisiblePanels.TryGetValue(type.EntityName().Split('.').Last(), out bool visible)
|
|
|
+ ? visible
|
|
|
+ : true;
|
|
|
+ page.Tab.Visibility = isvisible
|
|
|
+ ? Visibility.Visible
|
|
|
+ : Visibility.Collapsed;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetPagesVisible()
|
|
|
+ {
|
|
|
+ foreach (var page in _pages.Where(x=>x.Value is not null))
|
|
|
+ SetPageVisible(page.Key,page.Value);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DoCreatePanel<TPanel>(Func<bool> cancreate, string caption)
|
|
|
+ where TPanel : class, IBasePanel, IMasterDetailControl<Job>, new()
|
|
|
+ {
|
|
|
+ _pages[typeof(TPanel)] = CreatePage<JobDetailPanel<TPanel>>(cancreate, caption);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DoCreateGrid<TGrid,TEntity>(Func<bool> cancreate, string caption)
|
|
|
+ where TGrid : DynamicGrid<TEntity>, IDataModelSource, IMasterDetailControl<Job,TEntity>, new()
|
|
|
+ where TEntity : BaseObject, new()
|
|
|
+ {
|
|
|
+ _pages[typeof(TGrid)] = CreatePage<JobDetailGrid<TGrid,TEntity>>(cancreate, caption);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Dictionary<Type, IMasterDetailPage?> _pages = new();
|
|
|
+
|
|
|
protected override void CreatePages()
|
|
|
{
|
|
|
- CreatePage<JobDetailPanel<JobDetails>>("Details");
|
|
|
- CreatePage<JobDetailPanel<JobScopePanel>>(Security.CanView<JobScope>, "Scopes");
|
|
|
- CreatePage<JobDetailPanel<JobDocumentSetPanel>>(Security.CanView<JobDocumentSet>, "Documents");
|
|
|
- CreatePage<JobDetailPanel<JobStagesPanel>>(Security.CanView<JobStage>, "Stages");
|
|
|
- CreatePage<JobDetailGrid<JobITPGrid, JobITP>>(Security.CanView<JobITP>, "ITPs");
|
|
|
- CreatePage<JobDetailGrid<JobProductMappingsGrid, JobProductMapping>>(Security.CanView<JobProductMapping>, "Product Mappings");
|
|
|
- CreatePage<JobDetailGrid<JobProductStylesGrid, JobStyle>>(Security.CanView<JobStyle>, "Product Styles");
|
|
|
- CreatePage<JobDetailPanel<JobBillOfMaterialsPanel>>(Security.CanView<JobBillOfMaterials>, "BOM");
|
|
|
- CreatePage<JobDetailPanel<JobRequisitionPanel>>(Security.CanView<JobRequisition>, "Requisitions");
|
|
|
- CreatePage<JobDetailPanel<JobStockGrid>>(Security.CanView<StockHolding>, "Stock Holdings");
|
|
|
- CreatePage<JobDetailPanel<JobPickingListPanel>>(Security.CanView<Requisition>, "Picking Lists");
|
|
|
- CreatePage<JobDetailGrid<JobOrderGrid, PurchaseOrderItem>>(Security.CanView<PurchaseOrderItem>, "Orders");
|
|
|
- CreatePage<JobDetailPanel<JobDesignPanel>>(Security.CanView<Setout>, "Designs");
|
|
|
- CreatePage<JobDetailGrid<ManufacturingGrid, ManufacturingPacket>>(Security.CanView<ManufacturingPacket>, "Manufacturing");
|
|
|
- CreatePage<JobDetailGrid<ReadyToGoGrid, DeliveryItem>>(Security.CanView<DeliveryItem>, "Dispatch");
|
|
|
- CreatePage<JobDetailPanel<DeliveryPanel>>(Security.CanView<Delivery>, "Deliveries");
|
|
|
- CreatePage<JobDetailGrid<DeliveredOnSiteGrid, DeliveryItem>>(Security.CanView<DeliveryItem>, "OnSite");
|
|
|
- CreatePage<JobDetailPanel<TaskPanel>>(Security.CanView<Kanban>, "Tasks");
|
|
|
- CreatePage<JobDetailGrid<JobEquipmentGrid, JobEquipment>>(Security.CanView<Equipment>, "EquipmentTab");
|
|
|
- CreatePage<JobDetailPanel<JobEmployeePanel>>(Security.CanView<Employee>, "Employees");
|
|
|
- CreatePage<JobDetailGrid<JobTrackerGrid, JobTracker>>(Security.CanView<GPSTracker>, "Trackers");
|
|
|
- CreatePage<JobDetailPanel<JobAssignmentPanel>>(Security.CanView<Assignment>, "Assignments");
|
|
|
- CreatePage<JobDetailGrid<JobTimesheetGrid, TimeSheet>>(Security.CanView<TimeSheet>, "Timesheets");
|
|
|
- CreatePage<JobDetailGrid<JobFormGrid, JobForm>>(Security.CanView<JobForm>, "Forms");
|
|
|
- CreatePage<JobDetailPanel<InvoicePanel>>(Security.CanView<Invoice>, "Invoices");
|
|
|
- CreatePage<JobDetailGrid<JobSpreadsheetGrid, JobSpreadsheet>>(Security.CanView<JobSpreadsheet>, "Spreadsheets");
|
|
|
- CreatePage<JobDetailPanel<JobSummaryPanel>>(Security.CanView<JobMaterial>, "Summary");
|
|
|
+ DoCreatePanel<JobDetails>(() => true,"Details");
|
|
|
+ DoCreatePanel<JobScopePanel>(Security.CanView<JobScope>, "Scopes");
|
|
|
+ DoCreatePanel<JobDocumentSetPanel>(Security.CanView<JobDocumentSet>, "Documents");
|
|
|
+ DoCreatePanel<JobStagesPanel>(Security.CanView<JobStage>, "Stages");
|
|
|
+ DoCreateGrid<JobITPGrid, JobITP>(Security.CanView<JobITP>, "ITPs");
|
|
|
+ DoCreateGrid<JobProductMappingsGrid, JobProductMapping>(Security.CanView<JobProductMapping>, "Product Mappings");
|
|
|
+ DoCreateGrid<JobProductStylesGrid, JobStyle>(Security.CanView<JobStyle>, "Product Styles");
|
|
|
+ DoCreatePanel<JobBillOfMaterialsPanel>(Security.CanView<JobBillOfMaterials>, "BOM");
|
|
|
+ DoCreatePanel<JobRequisitionPanel>(Security.CanView<JobRequisition>, "Requisitions");
|
|
|
+ DoCreatePanel<JobStockGrid>(Security.CanView<StockHolding>, "Stock Holdings");
|
|
|
+ DoCreatePanel<JobPickingListPanel>(Security.CanView<Requisition>, "Picking Lists");
|
|
|
+ DoCreateGrid<JobOrderGrid, PurchaseOrderItem>(Security.CanView<PurchaseOrderItem>, "Orders");
|
|
|
+ DoCreatePanel<JobDesignPanel>(Security.CanView<Setout>, "Designs");
|
|
|
+ DoCreateGrid<ManufacturingGrid, ManufacturingPacket>(Security.CanView<ManufacturingPacket>, "Manufacturing");
|
|
|
+ DoCreateGrid<ReadyToGoGrid, DeliveryItem>(Security.CanView<DeliveryItem>, "Dispatch");
|
|
|
+ DoCreatePanel<DeliveryPanel>(Security.CanView<Delivery>, "Deliveries");
|
|
|
+ DoCreateGrid<DeliveredOnSiteGrid, DeliveryItem>(Security.CanView<DeliveryItem>, "OnSite");
|
|
|
+ DoCreatePanel<TaskPanel>(Security.CanView<Kanban>, "Tasks");
|
|
|
+ DoCreateGrid<JobEquipmentGrid, JobEquipment>(Security.CanView<Equipment>, "Equipment");
|
|
|
+ DoCreatePanel<JobEmployeePanel>(Security.CanView<Employee>, "Employees");
|
|
|
+ DoCreateGrid<JobTrackerGrid, JobTracker>(Security.CanView<GPSTracker>, "Trackers");
|
|
|
+ DoCreatePanel<JobAssignmentPanel>(Security.CanView<Assignment>, "Assignments");
|
|
|
+ DoCreateGrid<JobTimesheetGrid, TimeSheet>(Security.CanView<TimeSheet>, "Timesheets");
|
|
|
+ DoCreateGrid<JobFormGrid, JobForm>(Security.CanView<JobForm>, "Forms");
|
|
|
+ DoCreatePanel<InvoicePanel>(Security.CanView<Invoice>, "Invoices");
|
|
|
+ DoCreateGrid<JobSpreadsheetGrid, JobSpreadsheet>(Security.CanView<JobSpreadsheet>, "Spreadsheets");
|
|
|
+ DoCreatePanel<JobSummaryPanel>(Security.CanView<JobMaterial>, "Summary");
|
|
|
+
|
|
|
+ SetPagesVisible();
|
|
|
}
|
|
|
|
|
|
protected override void AfterLoadSettings(ProjectsPanelSettings settings)
|
|
@@ -71,6 +153,24 @@ public class ProjectsPanel : MasterDetailPanel<Job,ProjectsGrid,ProjectsPanelSet
|
|
|
|
|
|
public override void CreateToolbarButtons(IPanelHost host)
|
|
|
{
|
|
|
+
|
|
|
+ host.CreateSetupAction(new PanelAction()
|
|
|
+ {
|
|
|
+ Caption = "Projects Settings",
|
|
|
+ Image = PRSDesktop.Resources.specifications,
|
|
|
+ OnExecute = action =>
|
|
|
+ {
|
|
|
+ var settings = new UserConfiguration<ProjectsPanelSettings>().Load();
|
|
|
+
|
|
|
+ var grid = new DynamicItemsListGrid<ProjectsPanelSettings>();
|
|
|
+ if (grid.EditItems(new ProjectsPanelSettings[] { Settings }))
|
|
|
+ {
|
|
|
+ SaveSettings();
|
|
|
+ SetPagesVisible();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
ProjectSetupActions.JobStatuses(host);
|
|
|
ProjectSetupActions.DocumentMilestones(host);
|
|
|
ProjectSetupActions.JobScopeStatuses(host);
|
|
@@ -82,17 +182,7 @@ public class ProjectsPanel : MasterDetailPanel<Job,ProjectsGrid,ProjectsPanelSet
|
|
|
|
|
|
if (SelectedPage is IMasterDetailPanelPage { Panel: not null } subpanel)
|
|
|
subpanel.Panel.CreateToolbarButtons(host);
|
|
|
-
|
|
|
- // host.CreateSetupAction(new PanelAction()
|
|
|
- // {
|
|
|
- // Caption = "Job Settings",
|
|
|
- // Image = PRSDesktop.Resources.specifications,
|
|
|
- // OnExecute = action =>
|
|
|
- // {
|
|
|
- // if (DynamicGridUtils.Edit(Settings))
|
|
|
- // SaveSettings();
|
|
|
- // }
|
|
|
- // });
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|