From ddbc8d547144441467a474150cea347102fd60d6 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 11 Feb 2020 23:46:28 +0000 Subject: [PATCH] --- .../AyaNova/ControllerHelpers/ListOptions.cs | 4 +- .../AyaNova/Controllers/DataListController.cs | 5 ++- server/AyaNova/DataList/DataListFetcher.cs | 44 ++----------------- .../DataList/DataListSqlSelectBuilder.cs | 4 +- 4 files changed, 11 insertions(+), 46 deletions(-) diff --git a/server/AyaNova/ControllerHelpers/ListOptions.cs b/server/AyaNova/ControllerHelpers/ListOptions.cs index 230f09d6..7843845d 100644 --- a/server/AyaNova/ControllerHelpers/ListOptions.cs +++ b/server/AyaNova/ControllerHelpers/ListOptions.cs @@ -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; } diff --git a/server/AyaNova/Controllers/DataListController.cs b/server/AyaNova/Controllers/DataListController.cs index cfaa24e2..5347bfdc 100644 --- a/server/AyaNova/Controllers/DataListController.cs +++ b/server/AyaNova/Controllers/DataListController.cs @@ -48,7 +48,8 @@ namespace AyaNova.Api.Controllers /// /// List key, Paging, filtering and sorting options /// Collection with paging data - [HttpPost("List", Name = nameof(List))] + // [HttpPost("List", Name = nameof(List))] + [HttpPost] public async Task 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) diff --git a/server/AyaNova/DataList/DataListFetcher.cs b/server/AyaNova/DataList/DataListFetcher.cs index 7b2f3198..d2d9e0b2 100644 --- a/server/AyaNova/DataList/DataListFetcher.cs +++ b/server/AyaNova/DataList/DataListFetcher.cs @@ -13,8 +13,7 @@ namespace AyaNova.DataList { internal static class DataListFetcher { - internal static async Task GetResponseAsync(string DataListKey, AyContext ct, IUrlHelper Url, - string routeName, ListOptions listOptions, long UserId, AuthorizationRoles UserRoles) + internal static async Task 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(); } @@ -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(); } diff --git a/server/AyaNova/DataList/DataListSqlSelectBuilder.cs b/server/AyaNova/DataList/DataListSqlSelectBuilder.cs index a6fe44f2..aab2bc9e 100644 --- a/server/AyaNova/DataList/DataListSqlSelectBuilder.cs +++ b/server/AyaNova/DataList/DataListSqlSelectBuilder.cs @@ -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 objectFieldsList, string template, bool mini) + internal static string Build(List 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(); }