|
@@ -18,6 +18,7 @@ using InABox.WPF;
|
|
|
using Microsoft.Win32;
|
|
|
using Syncfusion.UI.Xaml.Diagram;
|
|
|
using System.ComponentModel;
|
|
|
+using NPOI.SS.Formula.Functions;
|
|
|
|
|
|
namespace PRSDesktop
|
|
|
{
|
|
@@ -33,41 +34,35 @@ namespace PRSDesktop
|
|
|
public OrgChartPanel()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
- if (Security.IsAllowed<CanViewOrgChartByEmployee>())
|
|
|
- Layout.Items.Add("Employees");
|
|
|
- if (Security.IsAllowed<CanViewOrgChartByPosition>())
|
|
|
- Layout.Items.Add("Positions");
|
|
|
- if (Security.IsAllowed<CanViewOrgChartByRole>())
|
|
|
- Layout.Items.Add("Job Roles");
|
|
|
- Layout.Visibility = Layout.Items.Count > 1 ? Visibility.Visible : Visibility.Collapsed;
|
|
|
- LayoutLabel.Visibility = Layout.Visibility;
|
|
|
}
|
|
|
|
|
|
public event DataModelUpdateEvent? OnUpdateDataModel;
|
|
|
|
|
|
public bool IsReady { get; set; }
|
|
|
|
|
|
- private void SaveSettings()
|
|
|
- {
|
|
|
- //_settings.Zoom = Zoom.Value;
|
|
|
- _settings.Appearance = (OrgChartAppearance)Appearance.SelectedIndex;
|
|
|
-
|
|
|
- _settings.Layout = Equals(Layout.SelectedValue, "Employees")
|
|
|
- ? OrgChartLayout.Employee
|
|
|
- : Equals(Layout.SelectedValue, "Positions")
|
|
|
- ? OrgChartLayout.Position
|
|
|
- : OrgChartLayout.Role;
|
|
|
-
|
|
|
-
|
|
|
- Task.Run(
|
|
|
- () => { new UserConfiguration<OrgChartSettings>().Save(_settings); }
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
#region IPanel Support
|
|
|
|
|
|
public void CreateToolbarButtons(IPanelHost host)
|
|
|
{
|
|
|
+ if (Security.IsAllowed<CanEditOrgChart>())
|
|
|
+ {
|
|
|
+ host.CreateSetupAction(new PanelAction
|
|
|
+ {
|
|
|
+ Caption = "Org Chart Settings",
|
|
|
+ OnExecute = OrgChartSettings_Click
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OrgChartSettings_Click(PanelAction obj)
|
|
|
+ {
|
|
|
+ var settings = new GlobalConfiguration<OrgChartSettings>().Load();
|
|
|
+ var grid = new DynamicItemsListGrid<OrgChartSettings>();
|
|
|
+ if (grid.EditItems(new OrgChartSettings[] { settings }))
|
|
|
+ {
|
|
|
+ new GlobalConfiguration<OrgChartSettings>().Save(settings);
|
|
|
+ _settings = settings;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public Dictionary<string, object[]> Selected()
|
|
@@ -81,17 +76,9 @@ namespace PRSDesktop
|
|
|
|
|
|
public void Setup()
|
|
|
{
|
|
|
- _settings = new UserConfiguration<OrgChartSettings>().Load();
|
|
|
+ _settings = new GlobalConfiguration<OrgChartSettings>().Load();
|
|
|
|
|
|
- Appearance.SelectedIndex = (int)_settings.Appearance;
|
|
|
model.Appearance = _settings.Appearance;
|
|
|
-
|
|
|
- var layout = _settings.Layout == OrgChartLayout.Employee
|
|
|
- ? "Employees"
|
|
|
- : _settings.Layout == OrgChartLayout.Position
|
|
|
- ? "Positions"
|
|
|
- : "Job Roles";
|
|
|
- Layout.SelectedValue = Layout.Items.Contains(layout) ? layout : Layout.Items[0];
|
|
|
model.Layout = _settings.Layout;
|
|
|
|
|
|
//Zoom.Value = _settings.Zoom;
|
|
@@ -567,22 +554,6 @@ namespace PRSDesktop
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void Appearance_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
- {
|
|
|
- if (model.Active)
|
|
|
- SaveSettings();
|
|
|
-
|
|
|
- model.Appearance = (OrgChartAppearance)Appearance.SelectedIndex;
|
|
|
- }
|
|
|
-
|
|
|
- private void Layout_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
- {
|
|
|
- if (model.Active)
|
|
|
- SaveSettings();
|
|
|
-
|
|
|
- model.Layout = _settings != null ? _settings.Layout : OrgChartLayout.Employee;
|
|
|
- }
|
|
|
-
|
|
|
#endregion
|
|
|
}
|
|
|
}
|