This commit is contained in:
2020-01-15 20:31:23 +00:00
parent 879c9c7368
commit 0f07201172
2 changed files with 11 additions and 39 deletions

View File

@@ -144,40 +144,9 @@ namespace AyaNova.Biz
//convert to strings (https://stackoverflow.com/a/33836599/8939)
var fullFields = ((JArray)jtemplate["full"]).ToObject<string[]>();
// 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}");

View File

@@ -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