diff --git a/devdocs/specs/core-main-grids.txt b/devdocs/specs/core-main-grids.txt index 7411a157..86329b32 100644 --- a/devdocs/specs/core-main-grids.txt +++ b/devdocs/specs/core-main-grids.txt @@ -45,7 +45,7 @@ Server - Display value (the data to show, not formatted yet, that's up to the client) - Optional: ID value (if the object is openable **** MUST CHECK RIGHTS ALSO HERE **** then this is the id to open for the client to put a hyperlink on that column) - To save bandwidth abbreviations are used in the column definitions: - - ColumnsJSON=@"{[ {""cm"":""Widget"",""dt"":""text"",""ay"":"+ AyaType.Widget.ToString()+ "}]}"; + - ColumnsJSON=@"""columns"":[ {""cm"":""Widget"",""dt"":""text"",""ay"":"+ AyaType.Widget.ToString()+ "}]"; - cm=column name locale key, dt=AyDataType, ay=AyaType to open on click of that column field (optional, not present if not openable) - For example (wide list): data:{ @@ -136,9 +136,9 @@ Download "next": "http://localhost:7575/api/v8/Widget/ListWidgets?pageNo=2&pageSize=3", "last": "http://localhost:7575/api/v8/Widget/ListWidgets?pageNo=34&pageSize=3" }, - "columns":{ + "columns":[ {name:"lt_client_name",datatype:text,ayatype:client},{name:"lt_client_notes",datatype:text},{name:"lt_last_workorder",datatype:number,ayatype:workorder} - } + ] } diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs index 62a51dc3..49fba252 100644 --- a/server/AyaNova/Startup.cs +++ b/server/AyaNova/Startup.cs @@ -408,7 +408,7 @@ namespace AyaNova // ******************** TESTING WIPE DB ***************************** // //Set this to true to wipe the db and reinstall a trial license and re-seed the data - var TESTING_REFRESH_DB = true;//####################################################################################### + var TESTING_REFRESH_DB = false;//####################################################################################### #if (DEBUG) //TESTING diff --git a/server/AyaNova/biz/ObjectFields.cs b/server/AyaNova/biz/ObjectFields.cs index e1e3fabb..d4e3acae 100644 --- a/server/AyaNova/biz/ObjectFields.cs +++ b/server/AyaNova/biz/ObjectFields.cs @@ -1,5 +1,7 @@ +using System.Linq; using System.Collections.Generic; using Newtonsoft.Json.Linq; +using System.Text; namespace AyaNova.Biz { @@ -52,6 +54,7 @@ namespace AyaNova.Biz switch (key) { case WIDGET_KEY: + #region WIDGET_KEY l.Add(new ObjectField { Key = "WidgetName", PropertyName = "Name", DataType = AyDataType.Text, Hideable = false }); l.Add(new ObjectField { Key = "WidgetSerial", PropertyName = "Serial", DataType = AyDataType.Integer }); l.Add(new ObjectField { Key = "WidgetDollarAmount", PropertyName = "DollarAmount", DataType = AyDataType.Currency }); @@ -80,8 +83,9 @@ namespace AyaNova.Biz l.Add(new ObjectField { Key = "WidgetCustom15", PropertyName = "WidgetCustom15", Custom = true }); l.Add(new ObjectField { Key = "WidgetCustom16", PropertyName = "WidgetCustom16", Custom = true }); break; - + #endregion case USER_KEY: + #region USER_KEY l.Add(new ObjectField { Key = "Name", PropertyName = "Name", SharedLTKey = true, DataType = AyDataType.Text, Hideable = false }); l.Add(new ObjectField { Key = "UserEmployeeNumber", PropertyName = "EmployeeNumber", DataType = AyDataType.Text }); l.Add(new ObjectField { Key = "AuthorizationRoles", PropertyName = "Roles", Hideable = false, DataType = AyDataType.Enum, EnumType = typeof(AuthorizationRoles).ToString() }); @@ -107,7 +111,7 @@ namespace AyaNova.Biz l.Add(new ObjectField { Key = "UserCustom15", PropertyName = "UserCustom15", Custom = true }); l.Add(new ObjectField { Key = "UserCustom16", PropertyName = "UserCustom16", Custom = true }); break; - + #endregion default: @@ -135,9 +139,27 @@ namespace AyaNova.Biz { //parse the template var jtemplate = JObject.Parse(template); - var fields= ObjectFieldsList(ObjectKey); + var fields = ObjectFieldsList(ObjectKey); - return ""; + //convert to strings (https://stackoverflow.com/a/33836599/8939) + var fullFields = ((JArray)jtemplate["full"]).ToObject(); + + //Generate JSON fragment to return with column definitions + StringBuilder sb=new StringBuilder(); + // StringWriter sw = new StringWriter(); + // JsonTextWriter writer = new JsonTextWriter(sw); + // writer.WriteStartObject();//{ + // ColumnsJSON=@"""columns"":[ {""cm"":""Widget"",""dt"":""text"",""ay"":"+ AyaType.Widget.ToString()+ "}]"; + foreach (string s in fullFields) + { + ObjectField o = fields.FirstOrDefault(x => x.Key == s); + if (o != null) + {//Here is where we can vet the field name, if it doesn't exist though, for now we'll just ignore it + + } + } + // writer.WriteEndObject();//} + return sw.ToString(); } diff --git a/server/AyaNova/biz/WidgetBiz.cs b/server/AyaNova/biz/WidgetBiz.cs index c41ab6b2..6a524e54 100644 --- a/server/AyaNova/biz/WidgetBiz.cs +++ b/server/AyaNova/biz/WidgetBiz.cs @@ -334,7 +334,7 @@ namespace AyaNova.Biz string ColumnsJSON=string.Empty; if(listOptions.Mini){ //all mini lists will have an id so include the type to open - ColumnsJSON=@"{[ {""cm"":""Widget"",""dt"":""text"",""ay"":"+ AyaType.Widget.ToString()+ "}]}"; + ColumnsJSON=@"""columns"":[ {""cm"":""Widget"",""dt"":""text"",""ay"":"+ AyaType.Widget.ToString()+ "}]"; }else{ ColumnsJSON=ObjectFields.GenerateListColumnJSONFromTemplate(ObjectFields.WIDGET_KEY,MOCK_WIDGET_DISPLAY_TEMPLATE_JSON); }