Преглед изворни кода

Reordered FilterConstants to have No Date Provided on top.

Kenric Nugteren пре 1 година
родитељ
комит
a3bedf645c
2 измењених фајлова са 15 додато и 12 уклоњено
  1. 2 2
      InABox.Core/Filter.cs
  2. 13 10
      inabox.wpf/DynamicGrid/Editors/FilterEditor/FilterNode.cs

+ 2 - 2
InABox.Core/Filter.cs

@@ -147,6 +147,7 @@ namespace InABox.Core
             if ((type == typeof(DateTime)) && SimpleOperators.Contains(op))
                 return new[]
                 {
+                    FilterConstant.NoDateProvided,
                     FilterConstant.Today, 
                     FilterConstant.Now,       
                     FilterConstant.OneWeekAgo,
@@ -182,8 +183,7 @@ namespace InABox.Core
                     FilterConstant.StartOfThisFinancialYear,
                     FilterConstant.EndOfThisFinancialYear,                    
                     FilterConstant.StartOfNextFinancialYear,
-                    FilterConstant.EndOfNextFinancialYear,
-                    FilterConstant.NoDateProvided
+                    FilterConstant.EndOfNextFinancialYear
                 };
             
             if (type.IsNumeric() && SimpleOperators.Contains(op))

+ 13 - 10
inabox.wpf/DynamicGrid/Editors/FilterEditor/FilterNode.cs

@@ -248,16 +248,18 @@ public class FilterNode<T> : BaseFilterNode
         
     private ConstantNode? CreateConstantNode(string? propertyName, Operator op, FilterConstant? constantvalue)
     {
-        var values = new Dictionary<string, FilterConstant?>();
+        var values = new List<KeyValuePair<string, FilterConstant?>>();
         if (!string.IsNullOrWhiteSpace(propertyName))
         {
             var property = CoreUtils.GetProperty(typeof(T), propertyName);
             var constants = FilterConstants.Constants(property.PropertyType, op);
             if (constants.Any())
             {
-                values[""] = null;
+                values.Add(new KeyValuePair<string, FilterConstant?>("", null));
                 foreach (var constant in constants)
-                    values[CoreUtils.Neatify(constant.ToString())] = constant;
+                {
+                    values.Add(new KeyValuePair<string, FilterConstant?>(CoreUtils.Neatify(constant.ToString()), constant));
+                }
             }
         }
 
@@ -266,13 +268,14 @@ public class FilterNode<T> : BaseFilterNode
             return null;
         }
 
-        var result = new ConstantNode();
-
-        result.DisplayMemberPath = "Key";
-        result.SelectedValuePath = "Value";
-        result.ItemsSource = values;
-        result.SelectedConstant = constantvalue; 
-        result.Margin = new Thickness(0, 0, 5, 0);
+        var result = new ConstantNode
+        {
+            DisplayMemberPath = "Key",
+            SelectedValuePath = "Value",
+            ItemsSource = values,
+            SelectedConstant = constantvalue,
+            Margin = new Thickness(0, 0, 5, 0)
+        };
         result.ConstantChanged += ConstantChanged;
         return result;
     }