|
|
@@ -73,7 +73,7 @@ public class FilterNode<T> : BaseFilterNode
|
|
|
this.filterType = filterType;
|
|
|
|
|
|
Property = new(filter.Property) { Margin = new Thickness(0, 0, 5, 0) };
|
|
|
- Operator = new(filter.Operator, filter.IsNot) { Margin = new Thickness(0, 0, 5, 0) };
|
|
|
+ Operator = CreateOperatorNode(Property.SelectedProperty, filter.Operator, filter.IsNot);
|
|
|
|
|
|
ValuePlaceHolder = CreateValuePlaceHolder();
|
|
|
|
|
|
@@ -81,7 +81,6 @@ public class FilterNode<T> : BaseFilterNode
|
|
|
SetValueNode(valueNode ?? new EmptyValueNode(), filter.Value);
|
|
|
|
|
|
Constant = CreateConstantNode(Property.SelectedProperty, filter.Operator, filter.Value as FilterConstant?);
|
|
|
- CheckValueVisibilities();
|
|
|
|
|
|
CustomValue = CreateCustomValueNode(Property.SelectedProperty, filter.Operator, filter.Value as CustomFilterValue);
|
|
|
CheckValueVisibilities();
|
|
|
@@ -95,7 +94,6 @@ public class FilterNode<T> : BaseFilterNode
|
|
|
OrButton.Click += OrButton_Click;
|
|
|
|
|
|
Property.PropertyChanged += Property_PropertyChanged;
|
|
|
- Operator.OperatorChanged += Operator_OperatorChanged;
|
|
|
|
|
|
Add(ClearButton, 0, 0);
|
|
|
if(LabelButton != null)
|
|
|
@@ -259,6 +257,23 @@ public class FilterNode<T> : BaseFilterNode
|
|
|
Add(Value, 0, 6);
|
|
|
CheckValueVisibilities();
|
|
|
}
|
|
|
+
|
|
|
+ private OperatorNode CreateOperatorNode(string? propertyName, Operator op, bool isNot)
|
|
|
+ {
|
|
|
+ Operator[] operators;
|
|
|
+ if (!string.IsNullOrWhiteSpace(propertyName) && DatabaseSchema.Property(typeof(T), propertyName) is IProperty property)
|
|
|
+ {
|
|
|
+ operators = Operators.GetOperators(property.PropertyType);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ operators = [];
|
|
|
+ }
|
|
|
+ var opNode = new OperatorNode(op, isNot, operators) { Margin = new Thickness(0, 0, 5, 0) };
|
|
|
+ opNode.Visibility = operators.Length > 0 ? Visibility.Visible : Visibility.Collapsed;
|
|
|
+ opNode.OperatorChanged += Operator_OperatorChanged;
|
|
|
+ return opNode;
|
|
|
+ }
|
|
|
|
|
|
private ConstantNode? CreateConstantNode(string? propertyName, Operator op, FilterConstant? constantvalue)
|
|
|
{
|
|
|
@@ -315,6 +330,10 @@ public class FilterNode<T> : BaseFilterNode
|
|
|
|
|
|
private void Property_PropertyChanged(string? property)
|
|
|
{
|
|
|
+ Children.Remove(Operator);
|
|
|
+ Operator = CreateOperatorNode(Property.SelectedProperty, Operator.SelectedOperator, Operator.IsNot);
|
|
|
+ Add(Operator, 0, 3);
|
|
|
+
|
|
|
if (Constant is not null)
|
|
|
{
|
|
|
Children.Remove(Constant);
|
|
|
@@ -350,12 +369,11 @@ public class FilterNode<T> : BaseFilterNode
|
|
|
|
|
|
private void Operator_OperatorChanged(Operator op, bool isNot)
|
|
|
{
|
|
|
-
|
|
|
if (Constant is not null)
|
|
|
{
|
|
|
Children.Remove(Constant);
|
|
|
}
|
|
|
- Constant = CreateConstantNode(Property.SelectedProperty, Operator.SelectedOperator, null);
|
|
|
+ Constant = CreateConstantNode(Property.SelectedProperty, Operator.SelectedOperator, Constant?.SelectedConstant);
|
|
|
if (Constant is not null)
|
|
|
{
|
|
|
Add(Constant, 0, 4);
|