Skip to content

Commit

Permalink
Grid - Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gvreddy04 committed Jul 23, 2023
1 parent 028b301 commit a405539
Show file tree
Hide file tree
Showing 5 changed files with 297 additions and 341 deletions.
96 changes: 50 additions & 46 deletions blazorbootstrap/Components/Grid/FilterOperatorHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ public static class FilterOperatorHelper
{
public static IEnumerable<FilterOperatorInfo> GetFilterOperators(string propertyTypeName)
{
if (propertyTypeName == StringConstants.PropertyTypeNameInt16
|| propertyTypeName == StringConstants.PropertyTypeNameInt32
|| propertyTypeName == StringConstants.PropertyTypeNameInt64
|| propertyTypeName == StringConstants.PropertyTypeNameSingle // float
|| propertyTypeName == StringConstants.PropertyTypeNameDecimal
|| propertyTypeName == StringConstants.PropertyTypeNameDouble)
if (propertyTypeName is StringConstants.PropertyTypeNameInt16
or StringConstants.PropertyTypeNameInt32
or StringConstants.PropertyTypeNameInt64
or StringConstants.PropertyTypeNameSingle // float
or StringConstants.PropertyTypeNameDecimal
or StringConstants.PropertyTypeNameDouble)
{
return GetNumberFilterOperators();
}
else if (propertyTypeName == StringConstants.PropertyTypeNameString
|| propertyTypeName == StringConstants.PropertyTypeNameChar)
else if (propertyTypeName is StringConstants.PropertyTypeNameString
or StringConstants.PropertyTypeNameChar)
{
return GetStringFilterOperators();
}
else if (propertyTypeName == StringConstants.PropertyTypeNameDateOnly
|| propertyTypeName == StringConstants.PropertyTypeNameDateTime)
else if (propertyTypeName is StringConstants.PropertyTypeNameDateOnly
or StringConstants.PropertyTypeNameDateTime)
{
return GetDateFilterOperators();
}
Expand All @@ -33,60 +33,64 @@ public static IEnumerable<FilterOperatorInfo> GetFilterOperators(string property

public static IEnumerable<FilterOperatorInfo> GetNumberFilterOperators()
{
List<FilterOperatorInfo> result = new();

result.Add(new("=", "Equals", FilterOperator.Equals));
result.Add(new("!=", "Not equals", FilterOperator.NotEquals));
result.Add(new("<", "Less than", FilterOperator.LessThan));
result.Add(new("<=", "Less than or equals", FilterOperator.LessThanOrEquals));
result.Add(new(">", "Greater than", FilterOperator.GreaterThan));
result.Add(new(">=", "Greater than or equals", FilterOperator.GreaterThanOrEquals));
result.Add(new("x", "Clear", FilterOperator.Equals));
List<FilterOperatorInfo> result = new()
{
new("=", "Equals", FilterOperator.Equals),
new("!=", "Not equals", FilterOperator.NotEquals),
new("<", "Less than", FilterOperator.LessThan),
new("<=", "Less than or equals", FilterOperator.LessThanOrEquals),
new(">", "Greater than", FilterOperator.GreaterThan),
new(">=", "Greater than or equals", FilterOperator.GreaterThanOrEquals),
new("x", "Clear", FilterOperator.Equals)
};

return result;
}

public static IEnumerable<FilterOperatorInfo> GetStringFilterOperators()
{
List<FilterOperatorInfo> result = new();

result.Add(new("*a*", "Contains", FilterOperator.Contains));
//result.Add(new("!*a*", "Does not contain", FilterOperator.DoesNotContain));
result.Add(new("a**", "Starts with", FilterOperator.StartsWith));
result.Add(new("**a", "Ends with", FilterOperator.EndsWith));
//result.Add(new("=''", "Is empty", FilterOperator.IsEmpty));
//result.Add(new("!=''", "Is not empty", FilterOperator.IsNotEmpty));
result.Add(new("=", "Equals", FilterOperator.Equals));
//result.Add(new("!=", "Not equals", FilterOperator.NotEquals));
//result.Add(new("null", "Is null", FilterOperator.IsNull));
//result.Add(new("!null", "Is not null", FilterOperator.IsNotNull));
result.Add(new("x", "Clear", FilterOperator.Contains));
List<FilterOperatorInfo> result = new()
{
new("*a*", "Contains", FilterOperator.Contains),
//result.Add(new("!*a*", "Does not contain", FilterOperator.DoesNotContain));
new("a**", "Starts with", FilterOperator.StartsWith),
new("**a", "Ends with", FilterOperator.EndsWith),
//result.Add(new("=''", "Is empty", FilterOperator.IsEmpty));
//result.Add(new("!=''", "Is not empty", FilterOperator.IsNotEmpty));
new("=", "Equals", FilterOperator.Equals),
//result.Add(new("!=", "Not equals", FilterOperator.NotEquals));
//result.Add(new("null", "Is null", FilterOperator.IsNull));
//result.Add(new("!null", "Is not null", FilterOperator.IsNotNull));
new("x", "Clear", FilterOperator.Contains)
};

return result;
}

public static IEnumerable<FilterOperatorInfo> GetDateFilterOperators()
{
List<FilterOperatorInfo> result = new();

result.Add(new("=", "Equals", FilterOperator.Equals));
result.Add(new("!=", "Not equals", FilterOperator.NotEquals));
result.Add(new("<", "Less than", FilterOperator.LessThan));
result.Add(new("<=", "Less than or equals", FilterOperator.LessThanOrEquals));
result.Add(new(">", "Greater than", FilterOperator.GreaterThan));
result.Add(new(">=", "Greater than or equals", FilterOperator.GreaterThanOrEquals));
result.Add(new("x", "Clear", FilterOperator.Equals));
List<FilterOperatorInfo> result = new()
{
new("=", "Equals", FilterOperator.Equals),
new("!=", "Not equals", FilterOperator.NotEquals),
new("<", "Less than", FilterOperator.LessThan),
new("<=", "Less than or equals", FilterOperator.LessThanOrEquals),
new(">", "Greater than", FilterOperator.GreaterThan),
new(">=", "Greater than or equals", FilterOperator.GreaterThanOrEquals),
new("x", "Clear", FilterOperator.Equals)
};

return result;
}

public static IEnumerable<FilterOperatorInfo> GetBooleanFilterOperators()
{
List<FilterOperatorInfo> result = new();

result.Add(new("=", "Equals", FilterOperator.Equals));
result.Add(new("!=", "Not equals", FilterOperator.NotEquals));
result.Add(new("x", "Clear", FilterOperator.Equals));
List<FilterOperatorInfo> result = new()
{
new("=", "Equals", FilterOperator.Equals),
new("!=", "Not equals", FilterOperator.NotEquals),
new("x", "Clear", FilterOperator.Equals)
};

return result;
}
Expand Down
Loading

0 comments on commit a405539

Please sign in to comment.