This commit is contained in:
2020-03-16 23:00:45 +00:00
parent a5881bb2fa
commit e47b0501c9
2 changed files with 10 additions and 12 deletions

View File

@@ -18,6 +18,7 @@ todo: add pickers for all CORE objects (User...?)
todo: write a guide in ayatype for what to do when making a new core object as there are a few things now todo: write a guide in ayatype for what to do when making a new core object as there are a few things now
todo: tests once it's all completed for server todo: tests once it's all completed for server
- test regular, tags, non-text column, max-results, order, template routes etc - test regular, tags, non-text column, max-results, order, template routes etc
- test not authorized, not found

View File

@@ -59,22 +59,17 @@ namespace AyaNova.Biz
internal async Task<List<NameIdActiveItem>> GetPickListAsync(IAyaPickList PickList, string query, bool inactive) internal async Task<List<NameIdActiveItem>> GetPickListAsync(IAyaPickList PickList, string query, bool inactive)
{ {
//Crack and validate the query part set a broken rule if not valid and return null //Crack and validate the query part set a broken rule if not valid and return null
//else do the query //else do the query
string TagSpecificQuery = null; string TagSpecificQuery = null;
string AutoCompleteQuery = null; string AutoCompleteQuery = null;
//Here need to handle scenario of badly formed query so user knows they did it wrong and doesn't just assume it's not there //Here need to handle scenario of badly formed query so user knows they did it wrong and doesn't just assume it's not there
//determine if this is a tag query and extract it //determine if this is a tag query and extract it
bool HasQuery = !string.IsNullOrWhiteSpace(query); bool HasQuery = !string.IsNullOrWhiteSpace(query);
if (HasQuery) if (HasQuery)
{ {
AutoCompleteQuery=query; AutoCompleteQuery = query;
//is it a dual template and tag query? //is it a dual template and tag query?
if (AutoCompleteQuery.Contains(" ")) if (AutoCompleteQuery.Contains(" "))
{ {
@@ -85,7 +80,8 @@ namespace AyaNova.Biz
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "query", "LT:ErrorPickListQueryInvalid"); AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "query", "LT:ErrorPickListQueryInvalid");
return null; return null;
} }
// users may type several spaces in a regular query, so ignore that and only use the first two segments //check the two query segments, it's valid for the user to put the tag first or the template query first
//we handle either way, but if there are no tas in either then it's not a valid query
if (querySegments[0].Contains("..")) if (querySegments[0].Contains(".."))
{ {
TagSpecificQuery = querySegments[0].Replace("..", ""); TagSpecificQuery = querySegments[0].Replace("..", "");
@@ -106,15 +102,16 @@ namespace AyaNova.Biz
else else
{ {
//is it a tag only query? //is it a tag only query?
if(AutoCompleteQuery.Contains("..")){ if (AutoCompleteQuery.Contains(".."))
TagSpecificQuery=AutoCompleteQuery.Replace("..",""); {
AutoCompleteQuery=null; TagSpecificQuery = AutoCompleteQuery.Replace("..", "");
AutoCompleteQuery = null;
} }
} }
} }
//Autocomplete and tagonly query terms now set for consumption by PickListFetcher, ready to fetch...
//Autocomplete and tagonly query terms now set for consumption by PickListFetcher, ready to fetch...
List<NameIdActiveItem> items = await PickListFetcher.GetResponseAsync(PickList, AutoCompleteQuery, TagSpecificQuery, inactive, ct); List<NameIdActiveItem> items = await PickListFetcher.GetResponseAsync(PickList, AutoCompleteQuery, TagSpecificQuery, inactive, ct);
return items; return items;
} }