diff --git a/server/AyaNova/Controllers/WidgetController.cs b/server/AyaNova/Controllers/WidgetController.cs index 6e8b0314..2b7a0590 100644 --- a/server/AyaNova/Controllers/WidgetController.cs +++ b/server/AyaNova/Controllers/WidgetController.cs @@ -92,8 +92,8 @@ namespace AyaNova.Api.Controllers /// /// Paging, filtering and sorting options /// Collection with paging data - [HttpGet("List", Name = nameof(WidgetList))] - public ActionResult WidgetList([FromQuery] ListOptions pagingOptions) + [HttpGet("List", Name = nameof(List))] + public ActionResult List([FromQuery] ListOptions pagingOptions) { if (serverState.IsClosed) return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); @@ -106,8 +106,8 @@ namespace AyaNova.Api.Controllers // ApiPagedResponse pr = biz.GetList(Url, nameof(WidgetList), pagingOptions); // return Ok(new ApiOkWithPagingResponse(pr)); - JObject j = biz.GetList(Url, nameof(WidgetList), pagingOptions).Result; - return Ok(j); + string ret= biz.GetList(Url, nameof(List), pagingOptions).Result; + return Ok(ret); } diff --git a/server/AyaNova/biz/ObjectFields.cs b/server/AyaNova/biz/ObjectFields.cs index 40bc5e81..e1e3fabb 100644 --- a/server/AyaNova/biz/ObjectFields.cs +++ b/server/AyaNova/biz/ObjectFields.cs @@ -1,11 +1,12 @@ using System.Collections.Generic; +using Newtonsoft.Json.Linq; namespace AyaNova.Biz { //************************************************ // This contains all the fields that are: - // Customizable on forms - // In grid list templates + // - Customizable on forms + // - In grid list templates //In addition it serves as a source for valid object keys in AvailableObjectKeys // public static class ObjectFields @@ -110,7 +111,7 @@ namespace AyaNova.Biz default: - throw new System.ArgumentOutOfRangeException($"ObjectFields: {key} is not a valid form key"); + throw new System.ArgumentOutOfRangeException($"ObjectFields: {key} is not a valid object key"); } return l; } @@ -128,6 +129,18 @@ namespace AyaNova.Biz } + //Accept a json template + //return a column list suitable for api list return + public static string GenerateListColumnJSONFromTemplate(string ObjectKey, string template) + { + //parse the template + var jtemplate = JObject.Parse(template); + var fields= ObjectFieldsList(ObjectKey); + + return ""; + } + + }//eoc ObjectFields @@ -146,7 +159,7 @@ namespace AyaNova.Biz public string EnumType { get; set; } //if field is a reference to another object (i.e. a client in a workorders list) //then the type to open is set here - public int AyObjectType {get;set;} + public int AyObjectType { get; set; } public ObjectField() @@ -159,7 +172,7 @@ namespace AyaNova.Biz Sortable = true; MiniAvailable = true; //Set openable object type to no type which is the default and means it's not a link to another object - AyObjectType=(int)AyaType.NoType; + AyObjectType = (int)AyaType.NoType; } } diff --git a/server/AyaNova/biz/WidgetBiz.cs b/server/AyaNova/biz/WidgetBiz.cs index 7b320a64..c41ab6b2 100644 --- a/server/AyaNova/biz/WidgetBiz.cs +++ b/server/AyaNova/biz/WidgetBiz.cs @@ -270,7 +270,7 @@ namespace AyaNova.Biz //get many (paged) - internal async Task GetList(IUrlHelper Url, string routeName, ListOptions listOptions) + internal async Task GetList(IUrlHelper Url, string routeName, ListOptions listOptions) { listOptions.Offset = listOptions.Offset ?? ListOptions.DefaultOffset; listOptions.Limit = listOptions.Limit ?? ListOptions.DefaultLimit; @@ -336,7 +336,7 @@ namespace AyaNova.Biz //all mini lists will have an id so include the type to open ColumnsJSON=@"{[ {""cm"":""Widget"",""dt"":""text"",""ay"":"+ AyaType.Widget.ToString()+ "}]}"; }else{ - ColumnsJSON=@"{[ {""cm"":""Widget"",""dt"":""text"",""ay"":"+ AyaType.Widget.ToString()+ "}]}"; + ColumnsJSON=ObjectFields.GenerateListColumnJSONFromTemplate(ObjectFields.WIDGET_KEY,MOCK_WIDGET_DISPLAY_TEMPLATE_JSON); } //TODO: BUILD THE RETURN LIST OF DATA ITEMS @@ -350,8 +350,9 @@ namespace AyaNova.Biz dynamic ret = new JObject(); ret.items = items; ret.pageLinks = pageLinks; + ret.columns=ColumnsJSON; - return ret; + return ret.ToString(); // ApiPagedResponse pr = new ApiPagedResponse(items, pageLinks); // return pr; }