diff --git a/server/AyaNova/biz/ObjectFields.cs b/server/AyaNova/biz/ObjectFields.cs index 8c932739..428b30e5 100644 --- a/server/AyaNova/biz/ObjectFields.cs +++ b/server/AyaNova/biz/ObjectFields.cs @@ -144,40 +144,9 @@ namespace AyaNova.Biz //convert to strings (https://stackoverflow.com/a/33836599/8939) var fullFields = ((JArray)jtemplate["full"]).ToObject(); - -// var jsonObj = new { -// name = taskName, -// products = new[] { -// new { product = "ndvi_image", actions = new [] { new { mapbox = "processed" } }, -// new { product = "true_color", actions = new [] { new { mapbox = "processed" } } -// }, -// recurring = true, -// query = new { -// date_from = dateFromString, -// date_to = dateToString, -// aoi = polygon -// }, -// aoi_coverage_percentage = 90 -// }; - -// var jsonString = JsonConvert.SerializeObject(jsonObj); - - - //Generate JSON fragment to return with column definitions StringBuilder sb = new StringBuilder(); - // ColumnsJSON=@"""columns"":[ {""cm"":""Widget"",""dt"":""text"",""ay"":"+ AyaType.Widget.ToString()+ "},{..etc..}]"; - - //GOAL: This works in javascript: - //JSON.parse( "{\"columns\": [{\"cm\":\"WidgetName\",\"dt\":\"4\"},{\"cm\":\"WidgetSerial\",\"dt\":\"5\"},{\"cm\":\"WidgetDollarAmount\",\"dt\":\"8\"},{\"cm\":\"WidgetRoles\",\"dt\":\"10\"},{\"cm\":\"WidgetStartDate\",\"dt\":\"1\"},{\"cm\":\"Active\",\"dt\":\"6\"}]}") - //\"columns\": [{\"cm\":\"WidgetName\",\"dt\":\"4\"},{\"cm\":\"WidgetSerial\",\"dt\":\"5\"},{\"cm\":\"WidgetDollarAmount\",\"dt\":\"8\"},{\"cm\":\"WidgetRoles\",\"dt\":\"10\"},{\"cm\":\"WidgetStartDate\",\"dt\":\"1\"},{\"cm\":\"Active\",\"dt\":\"6\"}] - - //CURRENTLY: this is what is actually coming out: - // "columns": "[{\"cm\":\"WidgetName\",\"dt\":\"4\"},{\"cm\":\"WidgetSerial\",\"dt\":\"5\"},{\"cm\":\"WidgetDollarAmount\",\"dt\":\"8\"},{\"cm\":\"WidgetRoles\",\"dt\":\"10\"},{\"cm\":\"WidgetStartDate\",\"dt\":\"1\"},{\"cm\":\"Active\",\"dt\":\"6\"}]" - - - sb.Append("["); var isFirstColumn = true; foreach (string s in fullFields) @@ -193,7 +162,7 @@ namespace AyaNova.Biz //Build required part of column definition sb.Append($"\"cm\":\"{o.Key}\",\"dt\":{(int)o.DataType}"); - //Has a AyObjectType (linkable / openable?) + //Has a AyObjectType? (linkable / openable) if (o.AyObjectType != 0) sb.Append($",\"ay\":{(int)o.AyObjectType}"); diff --git a/server/AyaNova/biz/WidgetBiz.cs b/server/AyaNova/biz/WidgetBiz.cs index 39cd5ae8..a43864ba 100644 --- a/server/AyaNova/biz/WidgetBiz.cs +++ b/server/AyaNova/biz/WidgetBiz.cs @@ -331,14 +331,17 @@ namespace AyaNova.Biz //for FULL we build it from the template automatically //eg: columns:{[ {name:"lt_client_name",datatype:text,ayatype:client},{name:"lt_client_notes",datatype:text},{name:"lt_last_workorder",datatype:number,ayatype:workorder}]} //if FULL Pass the template to the ObjectFields which will build the return JSON for here and will also ensure the fields are correct, if any are unknown it will just ignore them but maybe log it? - string ColumnsJSON=string.Empty; - if(listOptions.Mini){ + 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()+ "}]"; - //"{\"columns\":[{\"cm\":\"Widget\",\"dt\":\"text\",\"ay\":2}]}" - // "columns": "[ {\"cm\":\"Widget\",\"dt\":\"text\",\"ay\":Widget}]" - }else{ - ColumnsJSON=ObjectFields.GenerateListColumnJSONFromTemplate(ObjectFields.WIDGET_KEY,MOCK_WIDGET_DISPLAY_TEMPLATE_JSON); + ColumnsJSON = $"[ {{\"cm\":\"Widget\",\"dt\":{(int)AyaDataType.Text},\"ay\":{(int)AyaType.Widget}}}]"; + //"[{\"cm\":\"WidgetName\",\"dt\":4},{\"cm\":\"WidgetSerial\",\"dt\":5},{\"cm\":\"WidgetDollarAmount\",\"dt\":8},{\"cm\":\"WidgetRoles\",\"dt\":10},{\"cm\":\"WidgetStartDate\",\"dt\":1},{\"cm\":\"Active\",\"dt\":6}]" + } + else + { + //TODO: need at least one column to be the openable object here or else nothing will open + ColumnsJSON = ObjectFields.GenerateListColumnJSONFromTemplate(ObjectFields.WIDGET_KEY, MOCK_WIDGET_DISPLAY_TEMPLATE_JSON); } //TODO: BUILD THE RETURN LIST OF DATA ITEMS