This commit is contained in:
@@ -45,9 +45,7 @@ namespace AyaNova.DataList
|
||||
public Newtonsoft.Json.Linq.JArray GenerateListColumnsJSONFromListView(JArray listViewArray)
|
||||
{
|
||||
|
||||
//custom fields handling
|
||||
var ct = AyaNova.Util.ServiceProviderProvider.DBContext;
|
||||
var FormCustomization = ct.FormCustom.AsNoTracking().SingleOrDefault(x => x.FormKey == AyaType.Widget.ToString());
|
||||
|
||||
|
||||
var ListViewFieldKeys = GetFieldListFromListView(listViewArray);
|
||||
|
||||
@@ -145,6 +143,45 @@ namespace AyaNova.DataList
|
||||
// return true;
|
||||
// }
|
||||
|
||||
|
||||
//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, JArray> GetCustomFieldDefinitionsForList()
|
||||
{
|
||||
Dictionary<string, JArray> ret = new Dictionary<string, JArray>();
|
||||
//custom fields handling
|
||||
foreach (AyaDataListFieldDefinition d in this.FieldDefinitions)
|
||||
{
|
||||
if (d.IsCustomField)
|
||||
{
|
||||
//this relies on the convention I'm using of AyaType name as the first part of all custom fields lT keys, e.g.
|
||||
//WidgetCustom1 -> Widget
|
||||
var ayatypename = d.LtKey.Split("Custom")[0];
|
||||
if (!ret.ContainsKey(ayatypename))
|
||||
{
|
||||
//fetch it and set it
|
||||
using (var ct = AyaNova.Util.ServiceProviderProvider.DBContext)
|
||||
{
|
||||
var fc = ct.FormCustom.AsNoTracking().SingleOrDefault(x => x.FormKey == ayatypename);
|
||||
#if (DEBUG)
|
||||
if (fc == null)
|
||||
{
|
||||
throw new System.ArgumentNullException($"AyaDataList:GetCustomFieldDefinitionsForList, Custom field object type {ayatypename} has no FormCustom defined");
|
||||
}
|
||||
#endif
|
||||
if (fc != null)
|
||||
ret.Add(ayatypename, JArray.Parse(fc.Template));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
}//eoc
|
||||
|
||||
}//eons
|
||||
Reference in New Issue
Block a user