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

@@ -119,7 +119,7 @@ namespace AyaNova.Api.Controllers
if (ObjectFields.IsValidObjectKey(formkey))
{
return Ok(ApiOkResponse.Response(ObjectFields.FormFields(formkey), true));
return Ok(ApiOkResponse.Response(ObjectFields.ObjectFields(formkey), true));
}
else
{

View File

@@ -4,11 +4,15 @@ namespace AyaNova.Biz
{
public static class AyDataType
{
//Date and time types, all stored internally as a date and time timestamp, but may display as date only or time only
public const string DateTime = "datetime";
public const string Date = "date";
public const string Time = "time";
public const string Text = "text";
public const string Integer = "int";
public const string Bool = "bool";
public const string Decimal = "decimal";
public const string Currency = "currency";
public const string Tags = "tags";
public const string Enum = "enum";//enums are just integers in the db so the sql code handles it like an int, but the client needs to know it's an enum

View File

@@ -16,7 +16,7 @@ namespace AyaNova.Biz
return;
var FormTemplate = JArray.Parse(formCustom.Template);
var ThisFormCustomFieldsList = ObjectFields.FormFields(formCustom.FormKey).Where(x => x.Custom == true).Select(x => x.Key).ToList();
var ThisFormCustomFieldsList = ObjectFields.ObjectFields(formCustom.FormKey).Where(x => x.Custom == true).Select(x => x.Key).ToList();
//If the customFields string is empty then only validation is if any of the fields are required to be filled in
if (!hasCustomData)

View File

@@ -270,7 +270,10 @@ namespace AyaNova.Biz
}
break;
//Note there are three types here for display purposes but all are stored in the db as a timestamp the same with date and time components
case AyDataType.Date:
case AyDataType.DateTime:
case AyDataType.Time:
{
//Note: it is assumed all dates come into here from the CLIENT in UTC iso8601 format
//suitable for the database to handle as all database dates are in UTC

View File

@@ -192,7 +192,7 @@ namespace AyaNova.Biz
if ((!PropertyHasErrors("FormKey") && !string.IsNullOrWhiteSpace(inObj.Template)))
{
var ValidCustomFieldTypes = CustomFieldType.ValidCustomFieldTypes;
var ValidFormFields = ObjectFields.FormFields(inObj.FormKey);
var ValidFormFields = ObjectFields.ObjectFields(inObj.FormKey);
try
{
//Parse the json, expecting something like this:

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)
{

View File

@@ -18,7 +18,7 @@ namespace AyaNova.Biz
//var OuterJson=JObject.Parse(formCustom.Template);
var FormTemplate = JArray.Parse(formCustom.Template);
// var FormTemplate=(JArray)OuterJson["template"];
var FormFields = ObjectFields.FormFields(formCustom.FormKey);
var FormFields = ObjectFields.ObjectFields(formCustom.FormKey);
// var ThisFormNormalFieldsList = FormFields.Where(x => x.Custom == false).Select(x => x.Key).ToList();
foreach (JObject jo in FormTemplate)