Explorar el Código

Adding user-local filters

Kenric Nugteren hace 1 año
padre
commit
ca2d833dd9

+ 6 - 2
prs.desktop/Panels/DigitalForms/DigitalFormRoleCrossTab.cs

@@ -18,8 +18,12 @@ public class DigitalFormRoleCrossTab : DynamicManyToManyCrossTab<RoleForm, Digit
 
     public DigitalFormRoleCrossTab()
     {
-        DigitalFormFilter = new(this, new GlobalConfiguration<CoreFilterDefinitions>(nameof(DigitalForm))) { ButtonText = "Digital Forms" };
-        RoleFilter = new(this, new GlobalConfiguration<CoreFilterDefinitions>(nameof(Role))) { ButtonText = "Roles" };
+        DigitalFormFilter = new(this,
+            new GlobalConfiguration<CoreFilterDefinitions>(nameof(DigitalForm)),
+            new UserConfiguration<CoreFilterDefinitions>(nameof(DigitalForm))) { ButtonText = "Digital Forms" };
+        RoleFilter = new(this,
+            new GlobalConfiguration<CoreFilterDefinitions>(nameof(Role)),
+            new UserConfiguration<CoreFilterDefinitions>(nameof(Role))) { ButtonText = "Roles" };
 
         DigitalFormFilter.OnFilterRefresh += () => Refresh(false, true);
         RoleFilter.OnFilterRefresh += () => Refresh(true, true);

+ 50 - 47
prs.desktop/Panels/Employees/EmployeeRoleCrossTab.cs

@@ -8,54 +8,57 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
-namespace PRSDesktop
+namespace PRSDesktop;
+
+public class EmployeeRoleCrossTab : DynamicManyToManyCrossTab<EmployeeRole, Employee, Role>
 {
-    public class EmployeeRoleCrossTab : DynamicManyToManyCrossTab<EmployeeRole, Employee, Role>
+    public DynamicGridFilterButtonComponent<Employee> EmployeeFilter { get; init; }
+
+    public DynamicGridFilterButtonComponent<Role> RoleFilter { get; init; }
+
+    public EmployeeRoleCrossTab()
+    {
+        EmployeeFilter = new(this,
+            new GlobalConfiguration<CoreFilterDefinitions>(nameof(Employee)),
+            new UserConfiguration<CoreFilterDefinitions>(nameof(Employee))) { ButtonText = "Employees" };
+        RoleFilter = new(this,
+            new GlobalConfiguration<CoreFilterDefinitions>(nameof(Role)),
+            new UserConfiguration<CoreFilterDefinitions>(nameof(Role))) { ButtonText = "Roles" };
+
+        EmployeeFilter.OnFilterRefresh += () => Refresh(false, true);
+        RoleFilter.OnFilterRefresh += () => Refresh(true, true);
+    }
+
+    protected override Filter<Employee>? RowFilter()
+    {
+        return EmployeeFilter.GetFilter();
+    }
+
+    protected override Filter<Role>? ColumnFilter()
+    {
+        return RoleFilter.GetFilter();
+    }
+
+    protected override Columns<Role>? LoadColumnColumns()
+    {
+        return new Columns<Role>(x => x.Code);
+    }
+
+    protected override string FormatColumnHeader(CoreRow row)
+    {
+        return row.Get<Role, string>(x => x.Code);
+    }
+
+    protected override SortOrder<Role>? LoadColumnSort()
+    {
+        return null;
+    }
+
+    protected override DynamicGridColumns LoadRowColumns()
     {
-        public DynamicGridFilterButtonComponent<Employee> EmployeeFilter { get; init; }
-
-        public DynamicGridFilterButtonComponent<Role> RoleFilter { get; init; }
-
-        public EmployeeRoleCrossTab()
-        {
-            EmployeeFilter = new(this, new GlobalConfiguration<CoreFilterDefinitions>(nameof(Employee))) { ButtonText = "Employees" };
-            RoleFilter = new(this, new GlobalConfiguration<CoreFilterDefinitions>(nameof(Role))) { ButtonText = "Roles" };
-
-            EmployeeFilter.OnFilterRefresh += () => Refresh(false, true);
-            RoleFilter.OnFilterRefresh += () => Refresh(true, true);
-        }
-
-        protected override Filter<Employee>? RowFilter()
-        {
-            return EmployeeFilter.GetFilter();
-        }
-
-        protected override Filter<Role>? ColumnFilter()
-        {
-            return RoleFilter.GetFilter();
-        }
-
-        protected override Columns<Role>? LoadColumnColumns()
-        {
-            return new Columns<Role>(x => x.Code);
-        }
-
-        protected override string FormatColumnHeader(CoreRow row)
-        {
-            return row.Get<Role, string>(x => x.Code);
-        }
-
-        protected override SortOrder<Role>? LoadColumnSort()
-        {
-            return null;
-        }
-
-        protected override DynamicGridColumns LoadRowColumns()
-        {
-            var columns = new DynamicGridColumns();
-            columns.Add<Employee, string>(x => x.Code, 100, "Code", "", Alignment.MiddleLeft);
-            columns.Add<Employee, string>(x => x.Name, 100, "Name", "", Alignment.MiddleLeft);
-            return columns;
-        }
+        var columns = new DynamicGridColumns();
+        columns.Add<Employee, string>(x => x.Code, 100, "Code", "", Alignment.MiddleLeft);
+        columns.Add<Employee, string>(x => x.Name, 100, "Name", "", Alignment.MiddleLeft);
+        return columns;
     }
 }