This commit is contained in:
2021-01-13 17:49:17 +00:00
parent 061b05035b
commit 9a6889d859
2 changed files with 42 additions and 12 deletions

View File

@@ -50,16 +50,10 @@ namespace AyaNova.Api.Controllers
/// "zon some" is NOT valid (missing TAGS indicator), "..zone some re" is NOT valid (too many strings) /// "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="pickListParams">Parameters for pick list see api docs for details </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="preIds">Return only specific items (for pre-selected items on forms) </param>
/// <param name="variant">Some lists optionally take a variant string, e.g. User type "inside","outside" etc </param>
/// <returns>Filtered list</returns> /// <returns>Filtered list</returns>
[HttpGet("list")] [HttpPost("list")]
public async Task<IActionResult> GetList([FromQuery] AyaType ayaType, [FromQuery] string query, [FromQuery] bool inactive, [FromQuery] long[] preIds, [FromQuery] string variant) public async Task<IActionResult> PostList([FromBody] PickListParams pickListParams)
{ {
if (serverState.IsClosed) if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
@@ -69,7 +63,7 @@ namespace AyaNova.Api.Controllers
//NOTE: these sequence of calls are a little different than other objects due to the nature of rights and stuff with picklists being different //NOTE: these sequence of calls are a little different than other objects due to the nature of rights and stuff with picklists being different
var PickList = PickListFactory.GetAyaPickList(ayaType); var PickList = PickListFactory.GetAyaPickList(pickListParams.AyaType);
//was the name not found as a pick list? //was the name not found as a pick list?
if (PickList == null) if (PickList == null)
@@ -83,7 +77,7 @@ namespace AyaNova.Api.Controllers
PickListBiz biz = PickListBiz.GetBiz(ct, HttpContext); PickListBiz biz = PickListBiz.GetBiz(ct, HttpContext);
var o = await biz.GetPickListAsync(PickList, query, inactive, preIds, variant, log); var o = await biz.GetPickListAsync(PickList, pickListParams.Query, pickListParams.Inactive, pickListParams.PreselectedIds.ToArray(), pickListParams.ListVariant, log);
if (o == null) if (o == null)
return BadRequest(new ApiErrorResponse(biz.Errors)); return BadRequest(new ApiErrorResponse(biz.Errors));
else else

View File

@@ -0,0 +1,36 @@
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using AyaNova.Biz;
namespace AyaNova.PickList
{
/*
/// <param name="params">The AyaType object type to select from</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="preIds">Return only specific items (for pre-selected items on forms) </param>
/// <param name="variant">Some lists optionally take a variant string, e.g. User type "inside","outside" etc </param>
*/
public sealed class PickListParams
{
[FromBody]
public AyaType AyaType { get; set; }
[FromBody]
public string Query { get; set; }
[FromBody]
public bool Inactive { get; set; }
[FromBody]
public List<long> PreselectedIds { get; set; }
[FromBody]
public string ListVariant { get; set; }
}
}