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}");