This commit is contained in:
2020-02-11 23:46:28 +00:00
parent 9ae5156105
commit ddbc8d5471
4 changed files with 11 additions and 46 deletions

View File

@@ -23,8 +23,8 @@ namespace AyaNova.Api.ControllerHelpers
// [FromBody]
// public long DataFilterId { get; set; }
[FromBody]
public bool Mini { get; set; }
public bool? Mini { get; set; }
[FromBody, Required]
public string DataListKey { get; set; }

View File

@@ -48,7 +48,8 @@ namespace AyaNova.Api.Controllers
/// </summary>
/// <param name="listOptions">List key, Paging, filtering and sorting options</param>
/// <returns>Collection with paging data</returns>
[HttpPost("List", Name = nameof(List))]
// [HttpPost("List", Name = nameof(List))]
[HttpPost]
public async Task<IActionResult> List([FromBody] ListOptions listOptions)
{
if (serverState.IsClosed)
@@ -62,7 +63,7 @@ namespace AyaNova.Api.Controllers
try
{
ApiDataListResponse r = await DataListFetcher.GetResponseAsync(listOptions.DataListKey, ct, Url, nameof(List), listOptions, UserId, UserRoles);
ApiDataListResponse r = await DataListFetcher.GetResponseAsync(listOptions.DataListKey, ct, listOptions, UserId, UserRoles);
return Ok(r);
}
catch (System.UnauthorizedAccessException)

View File

@@ -13,8 +13,7 @@ namespace AyaNova.DataList
{
internal static class DataListFetcher
{
internal static async Task<ApiDataListResponse> GetResponseAsync(string DataListKey, AyContext ct, IUrlHelper Url,
string routeName, ListOptions listOptions, long UserId, AuthorizationRoles UserRoles)
internal static async Task<ApiDataListResponse> GetResponseAsync(string DataListKey, AyContext ct, ListOptions listOptions, long UserId, AuthorizationRoles UserRoles)
{
// var AyaObjectFields = AyaObjectFieldDefinitions.AyaObjectFields(AyaObjectFieldDefinitions.TEST_WIDGET_USER_EMAIL_ADDRESS_LIST_KEY);
@@ -26,7 +25,7 @@ namespace AyaNova.DataList
}
//check rights
if (listOptions.Mini)
if (listOptions.Mini != null && listOptions.Mini == true)
{
if (!UserRoles.HasAnyFlags(DataList.MiniListAllowedRoles))
throw new System.UnauthorizedAccessException("User roles insufficient for this mini format datalist");
@@ -58,7 +57,7 @@ namespace AyaNova.DataList
//convert to strings array (https://stackoverflow.com/a/33836599/8939)
string[] templateFieldList;
if (listOptions.Mini)
if (listOptions.Mini != null && listOptions.Mini == true)
{
templateFieldList = ((JArray)jtemplate["mini"]).ToObject<string[]>();
}
@@ -184,45 +183,10 @@ namespace AyaNova.DataList
}
}
//RES.PAGING.COUNT is all I need so the rest is moot, particularly since it's a post method now to get a datalist not a GET with query parameters
//below commented stuff can go once it tests
//BUILD THE PAGING LINKS PORTION
//var pageLinks = new PaginationLinkBuilder(Url, routeName, null, listOptions, totalRecordCount).PagingLinksObject();
//http://localhost:7575/api/v8/DataList/List?Offset=2&Limit=3&DataFilterId=2&Mini=true&DataListKey=TestWidgetDataList
// object routeValues = null;
// //no data filter?
// if (listOptions.DataFilterId == 0)
// {
// if (listOptions.Mini)
// {
// routeValues = new { DataListKey = DataListKey, Mini = listOptions.Mini };
// }
// else
// {
// routeValues = new { DataListKey = DataListKey };
// }
// }
// else
// {
// if (listOptions.Mini)
// {
// routeValues = new { DataListKey = DataListKey, DataFilterId = listOptions.DataFilterId, Mini = listOptions.Mini };
// }
// else
// {
// routeValues = new { DataListKey = DataListKey, DataFilterId = listOptions.DataFilterId };
// }
// }
// var pageLinks = new PaginationLinkBuilder(Url, routeName, routeValues, listOptions, totalRecordCount).PagingLinksObject();
//BUILD THE COLUMNS RETURN PROPERTY JSON FRAGMENT
Newtonsoft.Json.Linq.JArray ColumnsJSON = null;
if (listOptions.Mini)
if (listOptions.Mini != null && listOptions.Mini == true)
{
ColumnsJSON = DataList.GenerateMINIListColumnsJSON();
}

View File

@@ -13,7 +13,7 @@ namespace AyaNova.DataList
{
//Build the SELECT portion of a list query based on the template, mini or full and the object key in question
internal static string Build(List<AyaDataListFieldDefinition> objectFieldsList, string template, bool mini)
internal static string Build(List<AyaDataListFieldDefinition> objectFieldsList, string template, bool? mini)
{
//parse the template
@@ -22,7 +22,7 @@ namespace AyaNova.DataList
//convert to strings array (https://stackoverflow.com/a/33836599/8939)
string[] templateFieldList;
if (mini)
if (mini!=null && mini==true)
{
templateFieldList = ((JArray)jtemplate["mini"]).ToObject<string[]>();
}