This commit is contained in:
@@ -44,10 +44,18 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get picklist of all Active objects of type specified and filtered by query specified
|
/// Get picklist of all Active objects of type specified and filtered by query specified
|
||||||
|
/// NOTE: Query is valid only if:
|
||||||
|
/// it is an empty string indicating not filtered just selected
|
||||||
|
/// if not an empty string, it has at most two space separated strings and one of them is a special TAG specific query that starts with two consecutive periods
|
||||||
|
/// i.e. "some" is valid (single query on all templated fields)
|
||||||
|
/// "..zon some" is valid (all tags like zon and all template fields like some)
|
||||||
|
/// "zon some" is NOT valid (missing TAGS indicator), "..zone some re" is NOT valid (too many strings)
|
||||||
/// Note that this list is capped automatically to return no more than 100 results
|
/// Note that this list is capped automatically to return no more than 100 results
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ayaType">The AyaType object type to select from</param>
|
/// <param name="ayaType">The AyaType object type to select from</param>
|
||||||
/// <param name="query">The query to filter the returned list by</param>
|
/// <param name="query">The query to filter the returned list by. Query text as provided will be case sensitively matched to all templated fields.
|
||||||
|
/// Independantely of this, if an addition space separated string that begins with two consecutive periods is encountered that will be considered a separate match to the TAGS collection of each object
|
||||||
|
/// So a tag query might be entered as "..zon some" which would match all tags LIKE 'zon' and template fields LIKE 'some'</param>
|
||||||
/// <param name="inactive">Include inactive objects in the returned list </param>
|
/// <param name="inactive">Include inactive objects in the returned list </param>
|
||||||
/// <returns>Filtered list</returns>
|
/// <returns>Filtered list</returns>
|
||||||
[HttpGet("List")]
|
[HttpGet("List")]
|
||||||
@@ -68,9 +76,43 @@ namespace AyaNova.Api.Controllers
|
|||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
|
||||||
|
//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
|
||||||
|
/*
|
||||||
|
string TagSpecificQuery=string.Empty;
|
||||||
|
|
||||||
|
//determine if this is a tag query
|
||||||
|
if(HasAutoCompleteQuery){
|
||||||
|
if(autoCompleteQuery.Contains(" ")){
|
||||||
|
//split the query on space
|
||||||
|
var querySegments=autoCompleteQuery.Split(' ');
|
||||||
|
//users may type several spaces in a regular query, so ignore that and only use the first two segments
|
||||||
|
if(querySegments[0].Contains("..")){
|
||||||
|
TagSpecificQuery=querySegments[0].Replace("..","");
|
||||||
|
//the second string is considered the
|
||||||
|
autoCompleteQuery=querySegments[1];
|
||||||
|
}else{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
var UserRoles = UserRolesFromContext.Roles(HttpContext.Items);
|
var UserRoles = UserRolesFromContext.Roles(HttpContext.Items);
|
||||||
|
|
||||||
var o = await biz.GetPickListAsync(ayaType, query, inactive, UserRoles);
|
var o = await biz.GetPickListAsync(ayaType, query, inactive, UserRoles);
|
||||||
|
|
||||||
|
/* this is how a bad validation is handled in a widget post
|
||||||
|
//we need to validate the query and return an explanation if it's bad so user doesn't get confused and think theya re doing the right thing but not getting results anyway
|
||||||
|
//Create and validate
|
||||||
|
Widget o = await biz.CreateAsync(inObj);
|
||||||
|
if (o == null)
|
||||||
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
|
else
|
||||||
|
return CreatedAtAction(nameof(WidgetController.GetWidget), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
if (o == null)
|
if (o == null)
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||||
|
|
||||||
|
|||||||
@@ -15,12 +15,13 @@ namespace AyaNova.PickList
|
|||||||
const int MAXIMUM_RESULT_COUNT = 100;
|
const int MAXIMUM_RESULT_COUNT = 100;
|
||||||
|
|
||||||
//Build the query for a picklist request
|
//Build the query for a picklist request
|
||||||
internal static string Build(IAyaPickList pickList, List<string> templateColumnNames, string autoCompleteQuery, bool IncludeInactive)
|
internal static string Build(IAyaPickList pickList, List<string> templateColumnNames, string autoCompleteQuery, string tagSpecificQuery, bool IncludeInactive)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
//determine this in advance as it will be used in a loop later
|
//determine this in advance as it will be used in a loop later
|
||||||
bool HasAutoCompleteQuery = !string.IsNullOrWhiteSpace(autoCompleteQuery);
|
bool HasAutoCompleteQuery = !string.IsNullOrWhiteSpace(autoCompleteQuery);
|
||||||
|
|
||||||
|
|
||||||
//lists to collect the clauses so to avoid comma fuckery
|
//lists to collect the clauses so to avoid comma fuckery
|
||||||
List<string> lSelect = new List<string>();
|
List<string> lSelect = new List<string>();
|
||||||
|
|||||||
Reference in New Issue
Block a user