This commit is contained in:
2020-02-13 23:20:40 +00:00
parent d032ceb125
commit aa0cfd2e13
4 changed files with 35 additions and 5 deletions

View File

@@ -66,5 +66,10 @@ namespace AyaNova.DataList
} }
} }
public bool HasIdColumn()
{
return !string.IsNullOrWhiteSpace(SqlIdColumnName);
}
} }
} }

View File

@@ -47,8 +47,6 @@ namespace AyaNova.DataList
throw new System.ArgumentNullException($"DEV ERROR in DataListSqlFilterCriteriaBuilder.cs: field {fld} specified in template was NOT found in ObjectFields list"); throw new System.ArgumentNullException($"DEV ERROR in DataListSqlFilterCriteriaBuilder.cs: field {fld} specified in template was NOT found in ObjectFields list");
} }
#endif #endif
var SQLValueColumnName = DataListField.GetSqlValueColumnName();
var SQLIdColumnName = DataListField.SqlIdColumnName;
//get filter items collection for this field view definition //get filter items collection for this field view definition
var filterItems = (JArray)cm["filter"]["items"]; var filterItems = (JArray)cm["filter"]["items"];
@@ -76,6 +74,9 @@ namespace AyaNova.DataList
var opType = filterItem["op"].Value<string>(); var opType = filterItem["op"].Value<string>();
List<string> tagList = new List<string>(); List<string> tagList = new List<string>();
string val = string.Empty; string val = string.Empty;
bool IsPossibleIdValue = filterItem["value"].Type == JTokenType.Integer;
if (filterItem["value"].Type != JTokenType.Array) if (filterItem["value"].Type != JTokenType.Array)
val = filterItem["value"].Value<string>(); val = filterItem["value"].Value<string>();
else else
@@ -83,7 +84,24 @@ namespace AyaNova.DataList
tagList = filterItem["value"].ToObject<List<String>>(); tagList = filterItem["value"].ToObject<List<String>>();
} }
sb.Append(DataFilterToColumnCriteria(SQLValueColumnName, (UiFieldDataType)dataType, opType, val, tagList, userId)); //prep for possible ID field filter instead
string columnNameToFilter = string.Empty;
UiFieldDataType DataTypeToFilter = UiFieldDataType.NoType;
//Check if filtering by ID rather than by name
//this is indicated by this column being an id type
//and by the comparison operator being eq or neq
//and the value being a number not a string
if (DataListField.HasIdColumn() && IsPossibleIdValue && (opType == DataListFilterComparisonOperator.Equality || opType == DataListFilterComparisonOperator.NotEqual))
{
columnNameToFilter = DataListField.SqlIdColumnName;
DataTypeToFilter = UiFieldDataType.InternalId;
}
else
{
DataTypeToFilter = (UiFieldDataType)dataType;
columnNameToFilter = DataListField.GetSqlValueColumnName();
}
sb.Append(DataFilterToColumnCriteria(columnNameToFilter, DataTypeToFilter, opType, val, tagList, userId));
//close this item parenthesis //close this item parenthesis
if (y < filterItems.Count - 1) if (y < filterItems.Count - 1)
@@ -411,6 +429,7 @@ namespace AyaNova.DataList
case UiFieldDataType.Enum://enums are just ints to the db, but it's a special type so the client can recognize it case UiFieldDataType.Enum://enums are just ints to the db, but it's a special type so the client can recognize it
case UiFieldDataType.Decimal: case UiFieldDataType.Decimal:
case UiFieldDataType.Currency: case UiFieldDataType.Currency:
case UiFieldDataType.InternalId:
case UiFieldDataType.Integer: //whole numbers, not only integer case UiFieldDataType.Integer: //whole numbers, not only integer
{ {
//case 1795 - it's numeric, convert to locale independant format //case 1795 - it's numeric, convert to locale independant format
@@ -437,6 +456,11 @@ namespace AyaNova.DataList
} }
} }
break; break;
case UiFieldDataType.InternalId:
{
//do nothing, it's a simple number
}
break;
} }

View File

@@ -37,7 +37,7 @@ cm=new JObject();
cm=new JObject(); cm=new JObject();
cm.fld="widgetname"; cm.fld="widgetname";
dlistView.Add(cm); dlistView.Add(cm);
finish this
// //name starts with filter to constrict to widgets that this test block created only // //name starts with filter to constrict to widgets that this test block created only
// dynamic DataFilterNameStart = new JObject(); // dynamic DataFilterNameStart = new JObject();
// DataFilterNameStart.fld = "widgetname"; // DataFilterNameStart.fld = "widgetname";

View File

@@ -32,7 +32,8 @@ namespace AyaNova.Biz
Tags = 9, Tags = 9,
Enum = 10, Enum = 10,
EmailAddress = 11, EmailAddress = 11,
HTTP = 12 HTTP = 12,
InternalId = 13
} }
} }