This commit is contained in:
2020-01-15 21:50:29 +00:00
parent f90eb44130
commit addafcb9a5
3 changed files with 23 additions and 19 deletions

View File

@@ -135,7 +135,7 @@ namespace AyaNova.Biz
//Accept a json template
//return a column list suitable for api list return
public static string GenerateListColumnJSONFromTemplate(string ObjectKey, string template)
public static string GenerateListColumnJSONFromTemplate(AyaType defaultLinkType, string ObjectKey, string template)
{
//parse the template
var jtemplate = JObject.Parse(template);
@@ -148,7 +148,9 @@ namespace AyaNova.Biz
StringBuilder sb = new StringBuilder();
sb.Append("[");
var isFirstColumn = true;
//_df_ First column is always the _df_ column
sb.Append($"{{\"cm\":\"_df_\",\"dt\":{(int)defaultLinkType}}}");
foreach (string s in fullFields)
{
ObjectField o = fields.FirstOrDefault(x => x.Key == s);

View File

@@ -329,19 +329,17 @@ namespace AyaNova.Biz
//TODO: BUILD THE COLUMNS RETURN PROPERTY JSON FRAGMENT
//for MINI format we just use a static column definition built in to this list object
//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)
{
//all mini lists will have an id so include the type to open
ColumnsJSON = $"[ {{\"cm\":\"Widget\",\"dt\":{(int)AyaDataType.Text},\"ay\":{(int)AyaType.Widget}}}]";
ColumnsJSON = $"[ {{\"cm\":\"_df_\",\"dt\":0,\"ay\":{(int)AyaType.Widget}}},{{\"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);
ColumnsJSON = ObjectFields.GenerateListColumnJSONFromTemplate(AyaType.Widget, ObjectFields.WIDGET_KEY, MOCK_WIDGET_DISPLAY_TEMPLATE_JSON);
}
//TODO: BUILD THE RETURN LIST OF DATA ITEMS