This commit is contained in:
@@ -55,11 +55,11 @@ namespace AyaNova.Api.Controllers
|
||||
/// 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="preId">Return only one item (for pre-selected items on forms) </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>
|
||||
[HttpGet("list")]
|
||||
public async Task<IActionResult> GetList([FromQuery] AyaType ayaType, [FromQuery] string query, [FromQuery] bool inactive, [FromQuery] long? preId, [FromQuery] string variant)
|
||||
public async Task<IActionResult> GetList([FromQuery] AyaType ayaType, [FromQuery] string query, [FromQuery] bool inactive, [FromQuery] long[] preIds, [FromQuery] string variant)
|
||||
{
|
||||
if (serverState.IsClosed)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
@@ -82,9 +82,8 @@ namespace AyaNova.Api.Controllers
|
||||
//Instantiate the business object handler
|
||||
PickListBiz biz = PickListBiz.GetBiz(ct, HttpContext);
|
||||
|
||||
if (preId == null)
|
||||
preId = 0;
|
||||
var o = await biz.GetPickListAsync(PickList, query, inactive, (long)preId, variant, log);
|
||||
|
||||
var o = await biz.GetPickListAsync(PickList, query, inactive, preIds, variant, log);
|
||||
if (o == null)
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
else
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace AyaNova.PickList
|
||||
internal static class PickListFetcher
|
||||
{
|
||||
internal static async Task<List<NameIdActiveItem>> GetResponseAsync(IAyaPickList PickList, string autoCompleteQuery,
|
||||
string tagSpecificQuery, bool includeInactive, long preId, string variant, AyContext ct, ILogger log)
|
||||
string tagSpecificQuery, bool includeInactive, long[] preIds, string variant, AyContext ct, ILogger log)
|
||||
{
|
||||
|
||||
//Sort out effective Template
|
||||
@@ -34,7 +34,7 @@ namespace AyaNova.PickList
|
||||
List<string> TemplateColumnNames = PickList.GetFieldListFromTemplate(jTemplate);
|
||||
|
||||
//BUILD THE QUERY
|
||||
var q = PickListSqlBuilder.Build(PickList, TemplateColumnNames, autoCompleteQuery, tagSpecificQuery, includeInactive, preId, variant);
|
||||
var q = PickListSqlBuilder.Build(PickList, TemplateColumnNames, autoCompleteQuery, tagSpecificQuery, includeInactive, preIds, variant);
|
||||
|
||||
//RETURN OBJECTS
|
||||
var ret = new List<NameIdActiveItem>();
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace AyaNova.PickList
|
||||
const int MAXIMUM_RESULT_COUNT = 100;
|
||||
|
||||
//Build the query for a picklist request
|
||||
internal static string Build(IAyaPickList pickList, List<string> templateColumnNames, string autoCompleteQuery, string tagSpecificQuery, bool IncludeInactive, long preId, string variant)
|
||||
internal static string Build(IAyaPickList pickList, List<string> templateColumnNames, string autoCompleteQuery, string tagSpecificQuery, bool IncludeInactive, long[] preIds, string variant)
|
||||
{
|
||||
|
||||
//determine this in advance as it will be used in a loop later
|
||||
@@ -62,9 +62,12 @@ namespace AyaNova.PickList
|
||||
|
||||
|
||||
|
||||
if (preId != 0)
|
||||
if (preIds.Length > 0)
|
||||
{
|
||||
PredefinedOnlyWhereFragment = rowIdColumn.SqlIdColumnName + " = " + preId.ToString();
|
||||
//select id,name from acustomer where id in(1,3,5,7)
|
||||
//string.Join(",", arr)
|
||||
// PredefinedOnlyWhereFragment = rowIdColumn.SqlIdColumnName + " = " + preId.ToString();
|
||||
PredefinedOnlyWhereFragment = $"{rowIdColumn.SqlIdColumnName} in ({string.Join(",", preIds)})";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
//get picklist
|
||||
internal async Task<List<NameIdActiveItem>> GetPickListAsync(IAyaPickList PickList, string query, bool inactive, long preId, string variant, ILogger log)
|
||||
internal async Task<List<NameIdActiveItem>> GetPickListAsync(IAyaPickList PickList, string query, bool inactive, long[] preIds, string variant, ILogger log)
|
||||
{
|
||||
|
||||
//Crack and validate the query part set a broken rule if not valid and return null
|
||||
@@ -134,7 +134,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
//Autocomplete and tagonly query terms now set for consumption by PickListFetcher, ready to fetch...
|
||||
List<NameIdActiveItem> items = await PickListFetcher.GetResponseAsync(PickList, AutoCompleteQuery, TagSpecificQuery, inactive, preId,variant, ct, log);
|
||||
List<NameIdActiveItem> items = await PickListFetcher.GetResponseAsync(PickList, AutoCompleteQuery, TagSpecificQuery, inactive, preIds,variant, ct, log);
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user