This commit is contained in:
@@ -23,8 +23,8 @@ namespace AyaNova.Api.ControllerHelpers
|
|||||||
// [FromBody]
|
// [FromBody]
|
||||||
// public long DataFilterId { get; set; }
|
// public long DataFilterId { get; set; }
|
||||||
|
|
||||||
[FromBody]
|
|
||||||
public bool Mini { get; set; }
|
public bool? Mini { get; set; }
|
||||||
|
|
||||||
[FromBody, Required]
|
[FromBody, Required]
|
||||||
public string DataListKey { get; set; }
|
public string DataListKey { get; set; }
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="listOptions">List key, Paging, filtering and sorting options</param>
|
/// <param name="listOptions">List key, Paging, filtering and sorting options</param>
|
||||||
/// <returns>Collection with paging data</returns>
|
/// <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)
|
public async Task<IActionResult> List([FromBody] ListOptions listOptions)
|
||||||
{
|
{
|
||||||
if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
@@ -62,7 +63,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
try
|
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);
|
return Ok(r);
|
||||||
}
|
}
|
||||||
catch (System.UnauthorizedAccessException)
|
catch (System.UnauthorizedAccessException)
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ namespace AyaNova.DataList
|
|||||||
{
|
{
|
||||||
internal static class DataListFetcher
|
internal static class DataListFetcher
|
||||||
{
|
{
|
||||||
internal static async Task<ApiDataListResponse> GetResponseAsync(string DataListKey, AyContext ct, IUrlHelper Url,
|
internal static async Task<ApiDataListResponse> GetResponseAsync(string DataListKey, AyContext ct, ListOptions listOptions, long UserId, AuthorizationRoles UserRoles)
|
||||||
string routeName, ListOptions listOptions, long UserId, AuthorizationRoles UserRoles)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
// var AyaObjectFields = AyaObjectFieldDefinitions.AyaObjectFields(AyaObjectFieldDefinitions.TEST_WIDGET_USER_EMAIL_ADDRESS_LIST_KEY);
|
// var AyaObjectFields = AyaObjectFieldDefinitions.AyaObjectFields(AyaObjectFieldDefinitions.TEST_WIDGET_USER_EMAIL_ADDRESS_LIST_KEY);
|
||||||
@@ -26,7 +25,7 @@ namespace AyaNova.DataList
|
|||||||
}
|
}
|
||||||
|
|
||||||
//check rights
|
//check rights
|
||||||
if (listOptions.Mini)
|
if (listOptions.Mini != null && listOptions.Mini == true)
|
||||||
{
|
{
|
||||||
if (!UserRoles.HasAnyFlags(DataList.MiniListAllowedRoles))
|
if (!UserRoles.HasAnyFlags(DataList.MiniListAllowedRoles))
|
||||||
throw new System.UnauthorizedAccessException("User roles insufficient for this mini format datalist");
|
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)
|
//convert to strings array (https://stackoverflow.com/a/33836599/8939)
|
||||||
string[] templateFieldList;
|
string[] templateFieldList;
|
||||||
if (listOptions.Mini)
|
if (listOptions.Mini != null && listOptions.Mini == true)
|
||||||
{
|
{
|
||||||
templateFieldList = ((JArray)jtemplate["mini"]).ToObject<string[]>();
|
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
|
//BUILD THE COLUMNS RETURN PROPERTY JSON FRAGMENT
|
||||||
Newtonsoft.Json.Linq.JArray ColumnsJSON = null;
|
Newtonsoft.Json.Linq.JArray ColumnsJSON = null;
|
||||||
if (listOptions.Mini)
|
if (listOptions.Mini != null && listOptions.Mini == true)
|
||||||
{
|
{
|
||||||
ColumnsJSON = DataList.GenerateMINIListColumnsJSON();
|
ColumnsJSON = DataList.GenerateMINIListColumnsJSON();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
//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
|
//parse the template
|
||||||
@@ -22,7 +22,7 @@ namespace AyaNova.DataList
|
|||||||
|
|
||||||
//convert to strings array (https://stackoverflow.com/a/33836599/8939)
|
//convert to strings array (https://stackoverflow.com/a/33836599/8939)
|
||||||
string[] templateFieldList;
|
string[] templateFieldList;
|
||||||
if (mini)
|
if (mini!=null && mini==true)
|
||||||
{
|
{
|
||||||
templateFieldList = ((JArray)jtemplate["mini"]).ToObject<string[]>();
|
templateFieldList = ((JArray)jtemplate["mini"]).ToObject<string[]>();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user