This commit is contained in:
2020-02-27 20:52:05 +00:00
parent ed666419ab
commit 5add4c6930

View File

@@ -45,8 +45,6 @@ namespace AyaNova.DataList
public Newtonsoft.Json.Linq.JArray GenerateListColumnsJSONFromListView(JArray listViewArray)
{
var ListViewFieldKeys = GetFieldListFromListView(listViewArray);
var CustomFieldDefinitions = GetCustomFieldDefinitionsForList();
@@ -80,6 +78,16 @@ namespace AyaNova.DataList
else
{
//insert specific type for this custom field
if (CustomFieldDefinitions.ContainsKey(o.LtKey))
{
var customFieldType = CustomFieldDefinitions[o.LtKey];
sb.Append($"\"cm\":\"{o.LtKey}\",\"dt\":{customFieldType}");
}
else
{
//this is normal as there may not be a definition for a Custom field but it's been requested so just treat it like text
sb.Append($"\"cm\":\"{o.LtKey}\",\"dt\":{(int)UiFieldDataType.Text}");
}
}
//Has a AyObjectType? (linkable / openable)
@@ -110,11 +118,11 @@ namespace AyaNova.DataList
//Find and return a dictionary of all custom fields definitions for all types in list
//used to build the column array and define specific type defined for custom fields so client datatable
//knows how to format it
private Dictionary<string, UiFieldDataType> GetCustomFieldDefinitionsForList()
private Dictionary<string, int> GetCustomFieldDefinitionsForList()
{
//all keys and types can go in the same list since they are unique to each type of list
//i.e. both users and widget custom fields can be in the same list
Dictionary<string, UiFieldDataType> ret = new Dictionary<string, UiFieldDataType>();
Dictionary<string, int> ret = new Dictionary<string, int>();
List<string> typesProcessed = new List<string>();
//custom fields handling
foreach (AyaDataListFieldDefinition d in this.FieldDefinitions)
@@ -144,9 +152,11 @@ namespace AyaNova.DataList
//iterate the fields and add each custom one with a type to the return dictionary
var flds = JArray.Parse(fc.Template);
foreach(JToken t in flds){
if(t["type"]!=null){
ret.Add(t["fld"].Value<string>(),t["type"].Value<UiFieldDataType>());
foreach (JToken t in flds)
{
if (t["type"] != null)
{
ret.Add(t["fld"].Value<string>(), t["type"].Value<int>());
}
}