This commit is contained in:
2020-01-14 00:43:25 +00:00
parent a4e68c9d60
commit b988f39a70
7 changed files with 43 additions and 12 deletions

View File

@@ -6,11 +6,14 @@ namespace AyaNova.Biz
// This contains all the fields that are:
// Customizable on forms
// In grid list templates
//In addition it serves as a source for valid form keys in AvailableFormKeys
//In addition it serves as a source for valid object keys in AvailableObjectKeys
//
public static class ObjectFields
{
//DEFINE VALID KEYS HERE
//For objects that are both list and edit form it's just the name of the object
//For objects that are compound list objects or reporting objects it's whatever uniquely but clearly identifies that
public const string WIDGET_KEY = "widget";
public const string USER_KEY = "user";
@@ -31,21 +34,31 @@ namespace AyaNova.Biz
return AvailableObjectKeys.Contains(key);
}
public static List<ObjectField> FormFields(string key)
public static List<ObjectField> ObjectFieldsList(string key)
{
/*
***************************** WARNING: Be careful here, if a standard field is hideable and also it's DB SCHEMA is set to NON NULLABLE then the CLIENT end needs to set a default
***************************** Otherwise the hidden field can't be set and the object can't be saved EVER
Defaults of paramterless constructor:
SharedLTKey = false;
Hideable = true;
Custom = false;
Filterable = true;
Sortable = true;
MiniAvailable = true;
*/
List<ObjectField> l = new List<ObjectField>();
switch (key)
{
case WIDGET_KEY:
l.Add(new ObjectField("WidgetName", "Name", false, false));//is not shared localized text key and not hideable as it is in the validation rules for widget
l.Add(new ObjectField("WidgetSerial", "Serial"));//not in validation rules BUT, is HIDEABLE and is set to NOT NULLABLE in the schema so this field MUST MUST have a default value in client
l.Add(new ObjectField("WidgetDollarAmount", "DollarAmount"));
l.Add(new ObjectField("WidgetCount", "Count"));
l.Add(new ObjectField("WidgetRoles", "Roles"));//not required but must be a valid default
l.Add(new ObjectField { Key = "WidgetName", PropertyName = "Name", DataType = AyDataType.Text, Hideable = false });
l.Add(new ObjectField { Key = "WidgetSerial", PropertyName = "Serial", DataType = AyDataType.Integer });
l.Add(new ObjectField { Key = "WidgetDollarAmount", PropertyName = "DollarAmount", DataType = AyDataType.Currency });
l.Add(new ObjectField { Key = "WidgetCount", PropertyName = "Count", DataType = AyDataType.Integer });
l.Add(new ObjectField { Key = "WidgetRoles", PropertyName = "Roles", DataType = AyDataType.Enum, EnumType = typeof(AuthorizationRoles).ToString() });
l.Add(new ObjectField { Key = "WidgetStartDate", PropertyName = "StartDate", DataType = AyDataType.Date });
l.Add(new ObjectField("WidgetStartDate", "StartDate"));//have rule for date precedence but can both be empty so allowing to hide is ok
l.Add(new ObjectField("WidgetEndDate", "EndDate"));
l.Add(new ObjectField("WidgetNotes", "Notes"));
@@ -131,9 +144,20 @@ namespace AyaNova.Biz
public bool Sortable { get; set; }
public bool MiniAvailable { get; set; }
public string DataType { get; set; }
//If it's an enum DataType then this is the specific enum type which sb the name of the class that holds the enum in the server project
public string EnumType { get; set; }
public ObjectField() { }
public ObjectField()
{
//most common defaults
SharedLTKey = false;
Hideable = true;
Custom = false;
Filterable = true;
Sortable = true;
MiniAvailable = true;
}
public ObjectField(string key, string propertyName, bool sharedLTKey = false, bool hideable = true, bool custom = false)
{