diff --git a/devdocs/specs/core-main-grids.txt b/devdocs/specs/core-main-grids.txt index 2249fe69..59897529 100644 --- a/devdocs/specs/core-main-grids.txt +++ b/devdocs/specs/core-main-grids.txt @@ -28,7 +28,7 @@ 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 - - _df_ First row object is ALWAYS the Default "_df_" object and is not intended for display + - df First row object is ALWAYS the Default "df" 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,7 +50,7 @@ Server - 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_" + - 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 @@ -61,7 +61,7 @@ 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) - - First column in each row is *ALWAYS* the DEFAULT column that corresponds to the _df_ column specified in objectfields with it's sql attributes + - First column in each row is *ALWAYS* the DEFAULT column that corresponds to the df column specified in objectfields with it's sql attributes - 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}]} diff --git a/server/AyaNova/biz/ObjectFields.cs b/server/AyaNova/biz/ObjectFields.cs index 5fe940a8..fdd5978b 100644 --- a/server/AyaNova/biz/ObjectFields.cs +++ b/server/AyaNova/biz/ObjectFields.cs @@ -156,7 +156,7 @@ namespace AyaNova.Biz //first column is the non visible Default Id column so that the client knows what to open when there is no field with ID selected that matches underlying record type //in this case the default of id is sufficient for this list - l.Add(new ObjectField { Key = "_df_", AyObjectType = (int)AyaType.Widget }); + l.Add(new ObjectField { Key = "df", AyObjectType = (int)AyaType.Widget }); l.Add(new ObjectField { Key = "WidgetName", PropertyName = "Name", DataType = (int)AyaDataType.Text, Hideable = false }); l.Add(new ObjectField { Key = "WidgetSerial", PropertyName = "Serial", DataType = (int)AyaDataType.Integer }); l.Add(new ObjectField { Key = "WidgetDollarAmount", PropertyName = "DollarAmount", DataType = (int)AyaDataType.Currency }); @@ -188,7 +188,7 @@ namespace AyaNova.Biz #endregion case USER_KEY: #region USER_KEY - l.Add(new ObjectField { Key = "_df_", AyObjectType = (int)AyaType.User }); + l.Add(new ObjectField { Key = "df", AyObjectType = (int)AyaType.User }); l.Add(new ObjectField { Key = "Name", PropertyName = "Name", SharedLTKey = true, DataType = (int)AyaDataType.Text, Hideable = false }); l.Add(new ObjectField { Key = "UserEmployeeNumber", PropertyName = "EmployeeNumber", DataType = (int)AyaDataType.Text }); l.Add(new ObjectField { Key = "AuthorizationRoles", PropertyName = "Roles", Hideable = false, DataType = (int)AyaDataType.Enum, EnumType = typeof(AuthorizationRoles).ToString() }); @@ -240,7 +240,7 @@ namespace AyaNova.Biz //Standard mini COLUMN definition public static string GenerateMINIListColumnsJSON(AyaType defaultLinkType) { - return $"[ {{\"cm\":\"_df_\",\"dt\":0,\"ay\":{(int)defaultLinkType}}},{{\"cm\":\"Widget\",\"dt\":{(int)AyaDataType.Text},\"ay\":{(int)defaultLinkType}}}]"; + return $"[ {{\"cm\":\"df\",\"dt\":0,\"ay\":{(int)defaultLinkType}}},{{\"cm\":\"Widget\",\"dt\":{(int)AyaDataType.Text},\"ay\":{(int)defaultLinkType}}}]"; } @@ -261,8 +261,8 @@ namespace AyaNova.Biz StringBuilder sb = new StringBuilder(); sb.Append("["); - //_df_ First column is always the _df_ column - sb.Append($"{{\"cm\":\"_df_\",\"dt\":0,\"ay\":{(int)defaultLinkType}}}"); + //df First column is always the df column + sb.Append($"{{\"cm\":\"df\",\"dt\":0,\"ay\":{(int)defaultLinkType}}}"); foreach (string s in fullFields) { @@ -349,17 +349,7 @@ namespace AyaNova.Biz } } - public string GetSqlIdColumnName() - { - if (string.IsNullOrEmpty(SqlIdColumn)) - { - return "id"; - } - else - { - return SqlIdColumn; - } - } + } diff --git a/server/AyaNova/biz/SqlSelectBuilder.cs b/server/AyaNova/biz/SqlSelectBuilder.cs index 853ad4c6..6f931e8c 100644 --- a/server/AyaNova/biz/SqlSelectBuilder.cs +++ b/server/AyaNova/biz/SqlSelectBuilder.cs @@ -36,14 +36,22 @@ namespace AyaNova.Biz StringBuilder sb = new StringBuilder(); sb.Append("SELECT "); - //Default ID column for each row (always is _df_) - ObjectField def = objectFieldsList.FirstOrDefault(x => x.Key == "_df_"); + //Default ID column for each row (always is aliased as df) + ObjectField def = objectFieldsList.FirstOrDefault(x => x.Key == "df"); if (def == null) { - throw new System.ArgumentNullException($"SqlSelectBuilder: objectFieldList for key \"{objectKey}\" is missing the _df_ default field"); + throw new System.ArgumentNullException($"SqlSelectBuilder: objectFieldList for key \"{objectKey}\" is missing the df default field"); } - sb.Append(def.SqlIdColumn); - sb.Append(" AS _df_ "); + if (string.IsNullOrEmpty(def.SqlIdColumn)) + { + sb.Append("id");//default when no alternate column is specified + } + else + { + sb.Append(def.SqlIdColumn); + } + + sb.Append(" AS df "); foreach (string ColumnName in templateFieldList) { @@ -56,18 +64,10 @@ namespace AyaNova.Biz } #endif if (o != null) - {//Here is where we can vet the field name, if it doesn't exist though, for now we'll just ignore those ones + {//Ignore missing fields in production sb.Append(","); - sb.Append("{"); - //Build required part of column definition - sb.Append($"\"cm\":\"{o.Key}\",\"dt\":{(int)o.DataType}"); - - //Has a AyObjectType? (linkable / openable) - if (o.AyObjectType != 0) - sb.Append($",\"ay\":{(int)o.AyObjectType}"); - - sb.Append("}"); + sb.Append(o.GetSqlColumnName()); } }