浏览代码

Removed Unecessary properties from Supplier.DefaultLocation
LeaveCalendar now properly processes digital forms when creating leave requests
StockDimensions Editors can now change values, but not unit type
Added Filtering to Stock Forecast / Product Groups Grid

frogsoftware 1 年之前
父节点
当前提交
5636887d63

+ 14 - 0
prs.classes/Entities/Stock/StockLocation/StockLocationLink.cs

@@ -3,6 +3,20 @@ using InABox.Core;
 
 namespace Comal.Classes
 {
+    
+    public class SupplierStockLocationLink : EntityLink<StockLocation>
+    {
+        
+        [CodePopupEditor(typeof(StockLocation))]
+        public override Guid ID { get; set; }
+        
+        [CodeEditor(Visible = Visible.Default, Editable = Editable.Hidden)]
+        public string Code { get; set; }
+        
+        [TextBoxEditor(Editable = Editable.Hidden)]
+        public string Description { get; set; }
+    }
+    
     public class StockLocationLink : EntityLink<StockLocation>, IStockLocation
     {
         public StockAreaLink Area { get; set; }

+ 1 - 1
prs.classes/Entities/Supplier/Supplier.cs

@@ -72,7 +72,7 @@ namespace Comal.Classes
         public string Email { get; set; } = "";
         
         [EditorSequence(5)]
-        public StockLocationLink DefaultLocation { get; set; }
+        public SupplierStockLocationLink DefaultLocation { get; set; }
         
         [EditorSequence(6)]
         public SupplierCategoryLink Category { get; set; }

+ 3 - 3
prs.desktop/Dashboards/Common/DigitalFormsDashboard.xaml.cs

@@ -1259,7 +1259,7 @@ namespace PRSDesktop
             foreach (var row in formData.Rows)
             {
                 var form = (row.ToObject(FormType!) as IDigitalFormInstance)!;
-                if (!string.IsNullOrWhiteSpace(form.FormData))
+                if (true) //(!string.IsNullOrWhiteSpace(form.FormData))
                 {
                     var dataRow = data.NewRow();
 
@@ -1347,8 +1347,8 @@ namespace PRSDesktop
                     }
 
 
-                    if (bHasData)
-                        data.Rows.Add(dataRow);
+                    //if (bHasData)
+                    data.Rows.Add(dataRow);
                 }
             }
             DataGrid.ItemsSource = data;

+ 36 - 2
prs.desktop/Panels/LeaveRequests/LeaveCalendar.xaml.cs

@@ -550,7 +550,7 @@ namespace PRSDesktop
 
         private bool HasData(GridCellInfo cell)
         {
-            if (!cell.IsDataRowCell)
+            if (cell?.IsDataRowCell != true)
                 return false;
             var propertyCollection = dataGrid.View.GetPropertyAccessProvider();
             var cellValue = propertyCollection.GetValue(cell.RowData, cell.Column.MappingName);
@@ -576,8 +576,42 @@ namespace PRSDesktop
 
             lg ??= new LeaveRequestGrid();
             if (lg.EditItems(leaves.ToArray()))
+            {
+                Progress.ShowModal("Checking Forms...", progress =>
+                {
+                    List<LeaveRequestForm> updates = new List<LeaveRequestForm>();
+                    var table = new Client<ActivityForm>().Query(
+                        new Filter<ActivityForm>(x => x.Activity.ID).IsEqualTo(leaves.First().LeaveType.ID)
+                            .And(x => x.Form.AppliesTo)
+                            .IsEqualTo(typeof(LeaveRequest).EntityName().Split('.').Last())
+                    );
+                    foreach (var leave in leaves)
+                    {
+                        foreach (var row in table.Rows)
+                        {
+                            var activityform = row.ToObject<ActivityForm>();
+                            var leaveform = new LeaveRequestForm();
+                            leaveform.Parent.ID = leave.ID;
+                            leaveform.Form.ID = activityform.Form.ID;
+                            leaveform.Form.Synchronise(activityform.Form);
+
+                            var model =
+                                new DigitalFormDataModel<LeaveRequest, LeaveRequestLink, LeaveRequestForm>(leave,
+                                    leaveform);
+                            leaveform.Description = model.EvaluateExpression(activityform.Form.DescriptionExpression) ?? activityform.Form.Description;
+                            updates.Add(leaveform);
+                        }
+                    }
+
+                    if (updates.Any())
+                    {
+                        progress.Report("Saving forms...");
+                        new Client<LeaveRequestForm>().Save(updates, "Created from Leave Calendar");
+                    }
+                });
                 Refresh();
-        }
+            }
+    }
         
         private void CreateStandardLeaveClick(object sender, RoutedEventArgs e)
         {

+ 1 - 1
prs.desktop/Panels/PurchaseOrders/SupplierPurchaseOrderItemOneToMany.cs

@@ -493,7 +493,7 @@ public class SupplierPurchaseOrderItemOneToMany : DynamicOneToManyGrid<PurchaseO
     {
         base.CustomiseEditor(items, column, editor);
 
-        if(items.Any(x => x.ReceivedDate != DateTime.MinValue) && !new Column<PurchaseOrderItem>(x => x.ReceivedDate).IsEqualTo(column.ColumnName))
+        if(items.Any(x => x.ReceivedDate != DateTime.MinValue) && !new Column<PurchaseOrderItem>(x => x.ReceivedDate).IsEqualTo(column.ColumnName) && editor.Editable == Editable.Enabled)
         {
             editor.Editable = editor.Editable.Combine(Editable.Disabled);
         }

+ 10 - 4
prs.desktop/Panels/StockSummary/StockSummaryProductGroupTree.cs

@@ -16,6 +16,7 @@ public class StockSummaryProductGroupTree : DynamicSelectorGrid<ProductGroup>, I
     public StockSummaryProductGroupTree() : base(DynamicActionColumnPosition.End)
     {
         ColumnsTag = "StockSummaryProductGroupSelector";
+        Options.Add(DynamicGridOption.FilterRows);
     }
 
     public override DynamicGridColumns GenerateColumns()
@@ -25,14 +26,19 @@ public class StockSummaryProductGroupTree : DynamicSelectorGrid<ProductGroup>, I
         return columns;
     }
 
-    public IEnumerable<Guid> GetSelectedGroups(bool recursive) => 
-        recursive
-            ? SelectedIDs.SelectMany(x => UIComponent.GetChildren(x).Select(x => x.Get<ProductGroup, Guid>(x => x.ID)))
+    public IEnumerable<Guid> GetSelectedGroups(bool recursive)
+    {
+
+        var result = recursive
+            ? SelectedIDs.SelectMany(x => UIComponent.GetChildren(x).Select(r => r.Get<ProductGroup, Guid>(c => c.ID)))
             : SelectedIDs;
+        return result.Intersect(VisibleGuids);
+    }
 
     protected override Guid[] GetSelectedGuids(Guid id)
     {
-        return UIComponent.GetChildren(id).Select(x => x.Get<ProductGroup, Guid>(x => x.ID)).ToArray();
+        var result = UIComponent.GetChildren(id).Select(x => x.Get<ProductGroup, Guid>(x => x.ID));
+        return result.Intersect(VisibleGuids).ToArray();
     }
 
     private DynamicGridTreeUIComponent<ProductGroup>? _uiComponent;

+ 16 - 2
prs.shared/Editors/Dimensions/DimensionsEditorControl.cs

@@ -86,7 +86,7 @@ namespace PRS.Shared
 
             Combo = new ComboBox
             {
-                IsEnabled = EditorDefinition.AllowEditingUnit
+                IsEnabled = false //EditorDefinition.AllowEditingUnit
             };
             Combo.SetValue(Grid.ColumnProperty, 0);
             Combo.SetValue(Grid.RowProperty, 0);
@@ -120,6 +120,11 @@ namespace PRS.Shared
             return Grid;
         }
 
+        public override void SetEnabled(bool enabled)
+        {
+            base.SetEnabled(enabled);
+        }
+
         private void UpdateColumn(int column, bool visible, DoubleTextBox box)
         {
             if (!visible && box.Value != 0.0 && box.Value != null)
@@ -277,5 +282,14 @@ namespace PRS.Shared
 
     public class ProductDimensionsEditorControl : DimensionsEditorControl<ProductDimensions, ProductDimensionUnitLink, ProductDimensionUnit> { }
     public class QuoteTakeOffDimensionsEditorControl : DimensionsEditorControl<QuoteTakeOffDimensions, QuoteTakeOffUnitLink, QuoteTakeOffUnit> { }
-    public class StockDimensionsEditorControl : DimensionsEditorControl<StockDimensions, ProductDimensionUnitLink, ProductDimensionUnit> { }
+
+    public class StockDimensionsEditorControl : DimensionsEditorControl<StockDimensions, ProductDimensionUnitLink,
+        ProductDimensionUnit>
+    {
+        public StockDimensionsEditorControl()
+        {
+            
+        }
+        
+    }
 }