|
@@ -11,15 +11,24 @@ using PRSDesktop.Panels.Jobs;
|
|
|
|
|
|
namespace PRSDesktop;
|
|
|
|
|
|
+public enum StockReleaseWriteDownMethod
|
|
|
+{
|
|
|
+ AverageCost,
|
|
|
+ Zero
|
|
|
+}
|
|
|
+
|
|
|
public class ProjectsPanelSettings : BaseObject, IUserConfigurationSettings, IMasterDetailSettings
|
|
|
{
|
|
|
[NullEditor] public DynamicSplitPanelView ViewType { get; set; } = DynamicSplitPanelView.Combined;
|
|
|
-
|
|
|
- [NullEditor]
|
|
|
- public double AnchorWidth { get; set; } = 300;
|
|
|
-
|
|
|
- [NullEditor]
|
|
|
- public Guid MasterID { get; set; }
|
|
|
+
|
|
|
+ [NullEditor] public double AnchorWidth { get; set; } = 300;
|
|
|
+
|
|
|
+ [NullEditor] public Guid MasterID { get; set; }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+public class ProjectsSettings : BaseObject, IGlobalConfigurationSettings
|
|
|
+{
|
|
|
|
|
|
private class VisiblePanelsGenerator : LookupGenerator<object>
|
|
|
{
|
|
@@ -56,10 +65,15 @@ public class ProjectsPanelSettings : BaseObject, IUserConfigurationSettings, IMa
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- [CheckListEditor(typeof(VisiblePanelsGenerator))]
|
|
|
+ [CheckListEditor(typeof(VisiblePanelsGenerator), ColumnWidth = 200, Width = 600)]
|
|
|
+ [EditorSequence(2)]
|
|
|
public Dictionary<string, bool> VisiblePanels { get; set; }
|
|
|
|
|
|
- public ProjectsPanelSettings()
|
|
|
+ [EnumLookupEditor(typeof(StockReleaseWriteDownMethod))]
|
|
|
+ [EditorSequence(2)]
|
|
|
+ public StockReleaseWriteDownMethod StockRelease { get; set; }
|
|
|
+
|
|
|
+ public ProjectsSettings()
|
|
|
{
|
|
|
VisiblePanels = new Dictionary<string, bool>();
|
|
|
}
|
|
@@ -75,11 +89,18 @@ public class ProjectsPanel : MasterDetailPanel<Job,ProjectsGrid,ProjectsPanelSet
|
|
|
protected override string MasterColumnsTag => "Projects";
|
|
|
|
|
|
|
|
|
+ private ProjectsSettings _settings;
|
|
|
+
|
|
|
+ public ProjectsPanel() : base()
|
|
|
+ {
|
|
|
+ _settings = new GlobalConfiguration<ProjectsSettings>().Load();
|
|
|
+ }
|
|
|
+
|
|
|
private void SetPageVisible(Type type, IMasterDetailPage? page)
|
|
|
{
|
|
|
if (page is null)
|
|
|
return;
|
|
|
- var isvisible = Settings.VisiblePanels.TryGetValue(type.EntityName().Split('.').Last(), out bool visible)
|
|
|
+ var isvisible = _settings.VisiblePanels.TryGetValue(type.EntityName().Split('.').Last(), out bool visible)
|
|
|
? visible
|
|
|
: true;
|
|
|
page.Tab.Visibility = isvisible
|
|
@@ -87,6 +108,17 @@ public class ProjectsPanel : MasterDetailPanel<Job,ProjectsGrid,ProjectsPanelSet
|
|
|
: Visibility.Collapsed;
|
|
|
}
|
|
|
|
|
|
+ private void SetStockRelease()
|
|
|
+ {
|
|
|
+ if (_pages.TryGetValue(typeof(JobSummaryPanel), out IMasterDetailPage? p)
|
|
|
+ && p is IMasterDetailPanelPage panel
|
|
|
+ && panel.Panel is JobSummaryPanel summary)
|
|
|
+ summary.StockRelease = _settings.StockRelease;
|
|
|
+ if (_pages.TryGetValue(typeof(JobStockGrid), out IMasterDetailPage? g)
|
|
|
+ && g is JobStockGrid grid)
|
|
|
+ grid.StockRelease = _settings.StockRelease;
|
|
|
+ }
|
|
|
+
|
|
|
private void SetPagesVisible()
|
|
|
{
|
|
|
foreach (var page in _pages.Where(x=>x.Value is not null))
|
|
@@ -139,6 +171,7 @@ public class ProjectsPanel : MasterDetailPanel<Job,ProjectsGrid,ProjectsPanelSet
|
|
|
DoCreatePanel<JobSummaryPanel>(Security.CanView<JobMaterial>, "Summary");
|
|
|
|
|
|
SetPagesVisible();
|
|
|
+ SetStockRelease();
|
|
|
}
|
|
|
|
|
|
protected override void AfterLoadSettings(ProjectsPanelSettings settings)
|
|
@@ -160,13 +193,12 @@ public class ProjectsPanel : MasterDetailPanel<Job,ProjectsGrid,ProjectsPanelSet
|
|
|
Image = PRSDesktop.Resources.specifications,
|
|
|
OnExecute = action =>
|
|
|
{
|
|
|
- var settings = new UserConfiguration<ProjectsPanelSettings>().Load();
|
|
|
-
|
|
|
- var grid = new DynamicItemsListGrid<ProjectsPanelSettings>();
|
|
|
- if (grid.EditItems(new ProjectsPanelSettings[] { Settings }))
|
|
|
+ var grid = new DynamicItemsListGrid<ProjectsSettings>();
|
|
|
+ if (grid.EditItems(new ProjectsSettings[] { _settings }))
|
|
|
{
|
|
|
- SaveSettings();
|
|
|
+ new GlobalConfiguration<ProjectsSettings>().Save(_settings);
|
|
|
SetPagesVisible();
|
|
|
+ SetStockRelease();
|
|
|
}
|
|
|
}
|
|
|
});
|