This commit is contained in:
@@ -25,7 +25,7 @@ A master enum of all event types in RAVEN.
|
|||||||
Co-used by this log feature, but also used by notification system
|
Co-used by this log feature, but also used by notification system
|
||||||
Also used by localized text feature to fetch text about event for display in log and notification etc
|
Also used by localized text feature to fetch text about event for display in log and notification etc
|
||||||
May be used for other things in future.
|
May be used for other things in future.
|
||||||
Common event types that apply to any object and then specific event types that apply to particular types of objects but all in teh same master enum
|
Common event types that apply to any object and then specific event types that apply to particular types of objects but all in the same master enum
|
||||||
|
|
||||||
EventType
|
EventType
|
||||||
ALL OBJECTS
|
ALL OBJECTS
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ namespace AyaNova.DataList
|
|||||||
|
|
||||||
|
|
||||||
var ListViewFieldKeys = GetFieldListFromListView(listViewArray);
|
var ListViewFieldKeys = GetFieldListFromListView(listViewArray);
|
||||||
|
var CustomFieldDefinitions = GetCustomFieldDefinitionsForList();
|
||||||
|
|
||||||
//Generate JSON fragment to return with column definitions
|
//Generate JSON fragment to return with column definitions
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@@ -106,50 +107,15 @@ namespace AyaNova.DataList
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// //make sure the template parses and all the fields specified are really existant
|
|
||||||
// //this is more for dev errors or api users becuase the client shouldn't generate bad templates
|
|
||||||
// public bool ValidateTemplate(string template)
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// //parse the template
|
|
||||||
// var jtemplate = JObject.Parse(template);
|
|
||||||
// var fullFields = ((JArray)jtemplate["full"]).ToObject<string[]>();
|
|
||||||
// var miniFields = ((JArray)jtemplate["mini"]).ToObject<string[]>();
|
|
||||||
|
|
||||||
// foreach (string s in fullFields)
|
|
||||||
// {
|
|
||||||
// AyaDataListFieldDefinition o = FieldDefinitions.FirstOrDefault(x => x.FieldKey == s);
|
|
||||||
// if (o == null)
|
|
||||||
// {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// foreach (string s in miniFields)
|
|
||||||
// {
|
|
||||||
// AyaDataListFieldDefinition o = FieldDefinitions.FirstOrDefault(x => x.FieldKey == s);
|
|
||||||
// if (o == null)
|
|
||||||
// {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// catch
|
|
||||||
// {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
//Find and return a dictionary of all custom fields definitions for all types in list
|
//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
|
//used to build the column array and define specific type defined for custom fields so client datatable
|
||||||
//knows how to format it
|
//knows how to format it
|
||||||
private Dictionary<string, JArray> GetCustomFieldDefinitionsForList()
|
private Dictionary<string, UiFieldDataType> GetCustomFieldDefinitionsForList()
|
||||||
{
|
{
|
||||||
Dictionary<string, JArray> ret = new Dictionary<string, JArray>();
|
//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>();
|
||||||
|
List<string> typesProcessed = new List<string>();
|
||||||
//custom fields handling
|
//custom fields handling
|
||||||
foreach (AyaDataListFieldDefinition d in this.FieldDefinitions)
|
foreach (AyaDataListFieldDefinition d in this.FieldDefinitions)
|
||||||
{
|
{
|
||||||
@@ -158,8 +124,10 @@ namespace AyaNova.DataList
|
|||||||
//this relies on the convention I'm using of AyaType name as the first part of all custom fields lT keys, e.g.
|
//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
|
//WidgetCustom1 -> Widget
|
||||||
var ayatypename = d.LtKey.Split("Custom")[0];
|
var ayatypename = d.LtKey.Split("Custom")[0];
|
||||||
if (!ret.ContainsKey(ayatypename))
|
if (!typesProcessed.Contains(ayatypename))
|
||||||
{
|
{
|
||||||
|
//make sure we do each type only once
|
||||||
|
typesProcessed.Add(ayatypename);
|
||||||
//fetch it and set it
|
//fetch it and set it
|
||||||
using (var ct = AyaNova.Util.ServiceProviderProvider.DBContext)
|
using (var ct = AyaNova.Util.ServiceProviderProvider.DBContext)
|
||||||
{
|
{
|
||||||
@@ -170,18 +138,75 @@ namespace AyaNova.DataList
|
|||||||
throw new System.ArgumentNullException($"AyaDataList:GetCustomFieldDefinitionsForList, Custom field object type {ayatypename} has no FormCustom defined");
|
throw new System.ArgumentNullException($"AyaDataList:GetCustomFieldDefinitionsForList, Custom field object type {ayatypename} has no FormCustom defined");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (fc != null)
|
//production handling of missing formcustom
|
||||||
ret.Add(ayatypename, JArray.Parse(fc.Template));
|
if (fc == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//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>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*{[
|
||||||
|
{
|
||||||
|
"fld": "Notes",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fld": "WidgetCustom1",
|
||||||
|
"required": false,
|
||||||
|
"type": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fld": "WidgetCustom2",
|
||||||
|
"required": true,
|
||||||
|
"type": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fld": "WidgetCustom3",
|
||||||
|
"required": false,
|
||||||
|
"type": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fld": "WidgetCustom4",
|
||||||
|
"required": false,
|
||||||
|
"type": 6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fld": "WidgetCustom5",
|
||||||
|
"required": false,
|
||||||
|
"type": 8
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fld": "WidgetCustom6",
|
||||||
|
"required": false,
|
||||||
|
"type": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fld": "WidgetCustom7",
|
||||||
|
"required": false,
|
||||||
|
"type": 3
|
||||||
|
}
|
||||||
|
]}*/
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class NameType
|
||||||
|
{
|
||||||
|
string name { get; set; }
|
||||||
|
UiFieldDataType datatype { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
}//eoc
|
}//eoc
|
||||||
|
|
||||||
}//eons
|
}//eons
|
||||||
Reference in New Issue
Block a user