diff --git a/devdocs/specs/core-main-grids.txt b/devdocs/specs/core-main-grids.txt index 75d68ff4..55e76ca5 100644 --- a/devdocs/specs/core-main-grids.txt +++ b/devdocs/specs/core-main-grids.txt @@ -28,9 +28,8 @@ Client - Each row contains a bunch of row objects - Each column from the db is converted to an object and is formatted like this: - {v:[field value],id:42[optional id value if openable]}, {v:[field value],id:42[optional id value if openable]}...etc - - First row object is ALWAYS the Default object - - Key: "_df_" FIRST COLUMN: the DATA list returned MUST contain as the first column a column labelled "_df_" column which is not intended for display - - Default column contains the same format as a normal column but doesn't display and is intended for the client to know what type and ID of object to open + - First row object is ALWAYS the Default object and is not intended for display + - First column contains the same format as a normal column but doesn't display and is intended for the client to know what type and ID of object to open - This is necessary in cases where they have made selections that preclude knowing what link to open, so if there is no links in the row this is the default for the entire row - This also saves bandwidth as a list that has no other types can not bother setting the type or id for any other columns @@ -50,6 +49,10 @@ Server - SERVER SENDS LIST OF COLUMNS - The server needs to tell the client which columns are coming back with the list and what types etc so the client can just adapt to any template setting - column list has type of object behind each column if applicable and user has rights to open so client can make hyperlinks + - FIRST column in column list is always the DEFAULT column corresponding to the first "default" column in the data row + - cm value is always "_df_" + - dt value is always 0 (dt:0) + - AyaType is always the default type to open, if it's nothing there is nothing to open (not likely) - SERVER SENDS DATA - Data in a standard format all grid lists json format, not based on set objects (I think I can do that, probably a hybrid object with JSON data) - Each row has each column as a object comprising of: @@ -58,16 +61,17 @@ Server - To save bandwidth abbreviations are used in the column definitions: - 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:{ - columns:{[ {cm:"lt_client_name",dt:text,ay:2},{cm:"lt_client_notes",dt:text},{cm:"lt_last_workorder",dt:number,ay:workorder}]} - rows:{[ {},{v:"Green mechanics",id:32},"...notes...",{v:"42",id:42}, ...thousands more etc.... ]} - } - - For example (XS list) - data:{ - columns:{[ {cm:"lt_client",dt:text,ay:client}]} - rows:{ {display:"Green mechanics",id:32}, ...thousands more etc.... } - } + - First column is the DEFAULT column that corresponds to the + - For example (wide list): + data:{ + columns:{[ {cm:"lt_client_name",dt:text,ay:2},{cm:"lt_client_notes",dt:text},{cm:"lt_last_workorder",dt:number,ay:workorder}]} + rows:{[ {},{v:"Green mechanics",id:32},"...notes...",{v:"42",id:42}, ...thousands more etc.... ]} + } + - For example (XS list) + data:{ + columns:{[ {cm:"lt_client",dt:text,ay:client}]} + rows:{ {display:"Green mechanics",id:32}, ...thousands more etc.... } + } - has separate property defining all columns in list, their datatype and ayatype if openable diff --git a/server/AyaNova/biz/ObjectFields.cs b/server/AyaNova/biz/ObjectFields.cs index 428b30e5..edb58ef3 100644 --- a/server/AyaNova/biz/ObjectFields.cs +++ b/server/AyaNova/biz/ObjectFields.cs @@ -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); diff --git a/server/AyaNova/biz/WidgetBiz.cs b/server/AyaNova/biz/WidgetBiz.cs index a43864ba..8fdebcd7 100644 --- a/server/AyaNova/biz/WidgetBiz.cs +++ b/server/AyaNova/biz/WidgetBiz.cs @@ -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