This commit is contained in:
2020-02-13 23:41:44 +00:00
parent 5cb9e4fb22
commit b79c98cc9d

View File

@@ -33,10 +33,7 @@ namespace AyaNova.DataList
List<string> ret = new List<string>(); List<string> ret = new List<string>();
for (int i = 0; i < listViewArray.Count; i++) for (int i = 0; i < listViewArray.Count; i++)
{ {
var cm = listViewArray[i]; var cm = listViewArray[i];
//Get some info about this column / field
ret.Append(cm["fld"].Value<string>()); ret.Append(cm["fld"].Value<string>());
} }
return ret; return ret;
@@ -45,55 +42,50 @@ namespace AyaNova.DataList
public Newtonsoft.Json.Linq.JArray GenerateListColumnsJSONFromListView(JArray listViewArray) public Newtonsoft.Json.Linq.JArray GenerateListColumnsJSONFromListView(JArray listViewArray)
{ {
throw new System.NotImplementedException("AyaDataList:GenerateListColumnsJSONFromListView not coded yet ");
// //parse the template
// var jtemplate = JObject.Parse(listView);
var ListViewFieldKeys = GetFieldListFromListView(listViewArray);
// //convert to strings (https://stackoverflow.com/a/33836599/8939) //Generate JSON fragment to return with column definitions
// var fullFields = ((JArray)jtemplate["full"]).ToObject<string[]>(); StringBuilder sb = new StringBuilder();
// //Generate JSON fragment to return with column definitions sb.Append("[");
// StringBuilder sb = new StringBuilder(); //df First column is always the df column
sb.Append($"{{\"cm\":\"df\",\"dt\":0,\"ay\":{(int)DefaultListObjectType}}}");
// sb.Append("["); foreach (string s in ListViewFieldKeys)
// //df First column is always the df column {
// sb.Append($"{{\"cm\":\"df\",\"dt\":0,\"ay\":{(int)DefaultListObjectType}}}"); AyaDataListFieldDefinition o = FieldDefinitions.FirstOrDefault(x => x.FieldKey == s);
#if (DEBUG)
//Developers little helper
if (o == null)
{
throw new System.ArgumentNullException($"DEV ERROR in AyaDataList::GenerateListColumnsJSONFromListView - field {s} specified in ListView was NOT found in ObjectFields list");
}
#endif
// foreach (string s in fullFields) if (o != null)
// { {//Here is where we can vet the field name, if it doesn't exist. For production we'll just ignore those ones
// AyaDataListFieldDefinition o = FieldDefinitions.FirstOrDefault(x => x.FieldKey == s);
// #if (DEBUG)
// //Developers little helper
// if (o == null)
// {
// throw new System.ArgumentNullException($"DEV ERROR in AyaDataList::GenerateListColumnsJSONFromTemplate - field {s} specified in template was NOT found in ObjectFields list");
// }
// #endif
// if (o != null) sb.Append(",");
// {//Here is where we can vet the field name, if it doesn't exist. For production we'll just ignore those ones sb.Append("{");
//Build required part of column definition
sb.Append($"\"cm\":\"{o.LtKey}\",\"dt\":{(int)o.UiFieldDataType}");
// sb.Append(","); //Has a AyObjectType? (linkable / openable)
// sb.Append("{"); if (o.AyaObjectType != 0)
// //Build required part of column definition sb.Append($",\"ay\":{(int)o.AyaObjectType}");
// sb.Append($"\"cm\":\"{o.LtKey}\",\"dt\":{(int)o.UiFieldDataType}");
// //Has a AyObjectType? (linkable / openable) //Has a Enumtype?
// if (o.AyaObjectType != 0) if (!string.IsNullOrEmpty(o.EnumType))
// sb.Append($",\"ay\":{(int)o.AyaObjectType}"); sb.Append($",\"et\":\"{AyaNova.Util.StringUtil.TrimTypeName(o.EnumType)}\"");
// //Has a Enumtype? sb.Append("}");
// if (!string.IsNullOrEmpty(o.EnumType))
// sb.Append($",\"et\":\"{AyaNova.Util.StringUtil.TrimTypeName(o.EnumType)}\"");
// sb.Append("}"); }
}
sb.Append("]");
// } return JArray.Parse(sb.ToString());
// }
// sb.Append("]");
// return JArray.Parse(sb.ToString());
} }