This commit is contained in:
2020-01-15 15:49:03 +00:00
parent fb87ddc312
commit 14c38d5c6a
3 changed files with 26 additions and 12 deletions

View File

@@ -92,8 +92,8 @@ namespace AyaNova.Api.Controllers
/// </summary> /// </summary>
/// <param name="pagingOptions">Paging, filtering and sorting options</param> /// <param name="pagingOptions">Paging, filtering and sorting options</param>
/// <returns>Collection with paging data</returns> /// <returns>Collection with paging data</returns>
[HttpGet("List", Name = nameof(WidgetList))] [HttpGet("List", Name = nameof(List))]
public ActionResult WidgetList([FromQuery] ListOptions pagingOptions) public ActionResult List([FromQuery] ListOptions pagingOptions)
{ {
if (serverState.IsClosed) if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
@@ -106,8 +106,8 @@ namespace AyaNova.Api.Controllers
// ApiPagedResponse<NameIdItem> pr = biz.GetList(Url, nameof(WidgetList), pagingOptions); // ApiPagedResponse<NameIdItem> pr = biz.GetList(Url, nameof(WidgetList), pagingOptions);
// return Ok(new ApiOkWithPagingResponse<NameIdItem>(pr)); // return Ok(new ApiOkWithPagingResponse<NameIdItem>(pr));
JObject j = biz.GetList(Url, nameof(WidgetList), pagingOptions).Result; string ret= biz.GetList(Url, nameof(List), pagingOptions).Result;
return Ok(j); return Ok(ret);
} }

View File

@@ -1,11 +1,12 @@
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json.Linq;
namespace AyaNova.Biz namespace AyaNova.Biz
{ {
//************************************************ //************************************************
// This contains all the fields that are: // This contains all the fields that are:
// Customizable on forms // - Customizable on forms
// In grid list templates // - In grid list templates
//In addition it serves as a source for valid object keys in AvailableObjectKeys //In addition it serves as a source for valid object keys in AvailableObjectKeys
// //
public static class ObjectFields public static class ObjectFields
@@ -110,7 +111,7 @@ namespace AyaNova.Biz
default: 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; 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 }//eoc ObjectFields
@@ -146,7 +159,7 @@ namespace AyaNova.Biz
public string EnumType { get; set; } public string EnumType { get; set; }
//if field is a reference to another object (i.e. a client in a workorders list) //if field is a reference to another object (i.e. a client in a workorders list)
//then the type to open is set here //then the type to open is set here
public int AyObjectType {get;set;} public int AyObjectType { get; set; }
public ObjectField() public ObjectField()
@@ -159,7 +172,7 @@ namespace AyaNova.Biz
Sortable = true; Sortable = true;
MiniAvailable = true; MiniAvailable = true;
//Set openable object type to no type which is the default and means it's not a link to another object //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;
} }
} }

View File

@@ -270,7 +270,7 @@ namespace AyaNova.Biz
//get many (paged) //get many (paged)
internal async Task<JObject> GetList(IUrlHelper Url, string routeName, ListOptions listOptions) internal async Task<string> GetList(IUrlHelper Url, string routeName, ListOptions listOptions)
{ {
listOptions.Offset = listOptions.Offset ?? ListOptions.DefaultOffset; listOptions.Offset = listOptions.Offset ?? ListOptions.DefaultOffset;
listOptions.Limit = listOptions.Limit ?? ListOptions.DefaultLimit; 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 //all mini lists will have an id so include the type to open
ColumnsJSON=@"{[ {""cm"":""Widget"",""dt"":""text"",""ay"":"+ AyaType.Widget.ToString()+ "}]}"; ColumnsJSON=@"{[ {""cm"":""Widget"",""dt"":""text"",""ay"":"+ AyaType.Widget.ToString()+ "}]}";
}else{ }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 //TODO: BUILD THE RETURN LIST OF DATA ITEMS
@@ -350,8 +350,9 @@ namespace AyaNova.Biz
dynamic ret = new JObject(); dynamic ret = new JObject();
ret.items = items; ret.items = items;
ret.pageLinks = pageLinks; ret.pageLinks = pageLinks;
ret.columns=ColumnsJSON;
return ret; return ret.ToString();
// ApiPagedResponse<Widget> pr = new ApiPagedResponse<Widget>(items, pageLinks); // ApiPagedResponse<Widget> pr = new ApiPagedResponse<Widget>(items, pageLinks);
// return pr; // return pr;
} }