195 lines
12 KiB
C#
195 lines
12 KiB
C#
using System.Linq;
|
|
using System.Collections.Generic;
|
|
using Newtonsoft.Json.Linq;
|
|
using System.Text;
|
|
|
|
namespace AyaNova.Biz
|
|
{
|
|
//************************************************
|
|
// This contains all the fields that are customizable on forms
|
|
// it is used for both validation and driving the UI etc
|
|
//See the DataList folder / namespace for LIST related similar class
|
|
|
|
public static class AyaFormFieldDefinitions
|
|
{
|
|
|
|
//DEFINE VALID KEYS HERE
|
|
|
|
public const string WIDGET_KEY = "widget";
|
|
public const string USER_KEY = "user";
|
|
|
|
|
|
public static List<string> AyaFormFieldDefinitionKeys
|
|
{
|
|
get
|
|
{
|
|
List<string> l = new List<string>{
|
|
WIDGET_KEY, USER_KEY
|
|
};
|
|
return l;
|
|
}
|
|
}
|
|
|
|
public static bool IsValidFormFieldDefinitionKey(string key)
|
|
{
|
|
return AyaFormFieldDefinitionKeys.Contains(key);
|
|
}
|
|
|
|
public static List<AyaFormFieldDefinition> AyaObjectFields(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
|
|
*/
|
|
List<AyaFormFieldDefinition> l = new List<AyaFormFieldDefinition>();
|
|
switch (key)
|
|
{
|
|
case WIDGET_KEY:
|
|
#region WIDGET_KEY
|
|
|
|
//first column is the non visible Default Id column so that the client knows what to open when there is no field with ID selected that matches underlying record type
|
|
//in this case the default of id is sufficient for this list
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "df", AyaObjectType = (int)AyaType.Widget });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetName", FieldKey = "Name", UiFieldDataType = (int)AyaUiFieldDataType.Text, Hideable = false });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetSerial", FieldKey = "Serial", UiFieldDataType = (int)AyaUiFieldDataType.Integer });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetDollarAmount", FieldKey = "DollarAmount", UiFieldDataType = (int)AyaUiFieldDataType.Currency });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCount", FieldKey = "Count", UiFieldDataType = (int)AyaUiFieldDataType.Integer });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetRoles", FieldKey = "Roles", UiFieldDataType = (int)AyaUiFieldDataType.Enum, EnumType = typeof(AuthorizationRoles).ToString() });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetStartDate", FieldKey = "StartDate", UiFieldDataType = (int)AyaUiFieldDataType.DateTime });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetEndDate", FieldKey = "EndDate", UiFieldDataType = (int)AyaUiFieldDataType.DateTime });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetNotes", FieldKey = "Notes", UiFieldDataType = (int)AyaUiFieldDataType.Text });
|
|
//More to do on this, maybe the datatype should be a LINK or something for UI purposes
|
|
//circle back on this when there is enough infrastructure to test
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "User", FieldKey = "userid", UiFieldDataType = (int)AyaUiFieldDataType.Text, AyaObjectType = (int)AyaType.User });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "Active", FieldKey = "Active", UiFieldDataType = (int)AyaUiFieldDataType.Bool, Hideable = false });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "Tags", FieldKey = "Tags", UiFieldDataType = (int)AyaUiFieldDataType.Tags });
|
|
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom1", FieldKey = "WidgetCustom1", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom2", FieldKey = "WidgetCustom2", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom3", FieldKey = "WidgetCustom3", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom4", FieldKey = "WidgetCustom4", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom5", FieldKey = "WidgetCustom5", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom6", FieldKey = "WidgetCustom6", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom7", FieldKey = "WidgetCustom7", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom8", FieldKey = "WidgetCustom8", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom9", FieldKey = "WidgetCustom9", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom10", FieldKey = "WidgetCustom10", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom11", FieldKey = "WidgetCustom11", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom12", FieldKey = "WidgetCustom12", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom13", FieldKey = "WidgetCustom13", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom14", FieldKey = "WidgetCustom14", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom15", FieldKey = "WidgetCustom15", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom16", FieldKey = "WidgetCustom16", IsCustomField = true });
|
|
break;
|
|
#endregion
|
|
case USER_KEY:
|
|
#region USER_KEY
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "df", AyaObjectType = (int)AyaType.User });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "Name", FieldKey = "Name", UiFieldDataType = (int)AyaUiFieldDataType.Text, Hideable = false });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserEmployeeNumber", FieldKey = "EmployeeNumber", UiFieldDataType = (int)AyaUiFieldDataType.Text });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "AuthorizationRoles", FieldKey = "Roles", Hideable = false, UiFieldDataType = (int)AyaUiFieldDataType.Enum, EnumType = typeof(AuthorizationRoles).ToString() });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserNotes", FieldKey = "Notes", UiFieldDataType = (int)AyaUiFieldDataType.Text });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserUserType", FieldKey = "UserType", Hideable = false, UiFieldDataType = (int)AyaUiFieldDataType.Enum, EnumType = typeof(UserType).ToString() });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "Active", FieldKey = "Active", UiFieldDataType = (int)AyaUiFieldDataType.Bool, Hideable = false });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "Tags", FieldKey = "Tags", UiFieldDataType = (int)AyaUiFieldDataType.Tags });
|
|
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom1", FieldKey = "UserCustom1", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom2", FieldKey = "UserCustom2", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom3", FieldKey = "UserCustom3", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom4", FieldKey = "UserCustom4", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom5", FieldKey = "UserCustom5", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom6", FieldKey = "UserCustom6", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom7", FieldKey = "UserCustom7", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom8", FieldKey = "UserCustom8", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom9", FieldKey = "UserCustom9", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom10", FieldKey = "UserCustom10", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom11", FieldKey = "UserCustom11", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom12", FieldKey = "UserCustom12", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom13", FieldKey = "UserCustom13", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom14", FieldKey = "UserCustom14", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom15", FieldKey = "UserCustom15", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom16", FieldKey = "UserCustom16", IsCustomField = true });
|
|
break;
|
|
#endregion
|
|
|
|
|
|
|
|
default:
|
|
throw new System.ArgumentOutOfRangeException($"AyaFormFieldDefinitions: {key} is not valid");
|
|
}
|
|
return l;
|
|
}
|
|
|
|
|
|
// public static string TranslateLTCustomFieldToInternalCustomFieldName(string lTCustomFieldName)
|
|
// {
|
|
// var i = System.Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace(
|
|
// lTCustomFieldName, // Our input
|
|
// "[^0-9]", // Select everything that is not in the range of 0-9
|
|
// "" // Replace that with an empty string.
|
|
// ));
|
|
|
|
// return $"c{i}";
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}//eoc ObjectFields
|
|
|
|
public class AyaFormFieldDefinition
|
|
{
|
|
//CLIENT / SERVER Unique identifier used at BOTH client and server
|
|
//also the sql displaycolumnname if identical
|
|
public string FieldKey { get; set; }
|
|
|
|
//CLIENT Use only for display
|
|
public string LtKey { get; set; }
|
|
|
|
//CLIENT form customization
|
|
public bool Hideable { get; set; }
|
|
|
|
//CLIENT / SERVER - client display server validation purposes
|
|
public bool IsCustomField { get; set; }
|
|
|
|
// //CLIENT / SERVER - client display server validation purposes
|
|
// public bool IsFilterable { get; set; }
|
|
|
|
// //CLIENT / SERVER - client display server validation purposes
|
|
// public bool IsSortable { get; set; }
|
|
|
|
//CLIENT Use only for display
|
|
public int UiFieldDataType { get; set; }
|
|
|
|
//CLIENT Use only for display
|
|
public string EnumType { get; set; }
|
|
|
|
//CLIENT / SERVER - client display and to indicate what object to open , Server for formatting return object
|
|
public int AyaObjectType { get; set; }
|
|
|
|
|
|
|
|
|
|
public AyaFormFieldDefinition()
|
|
{
|
|
//most common defaults
|
|
Hideable = true;
|
|
IsCustomField = false;
|
|
// IsFilterable = true;
|
|
// IsSortable = true;
|
|
//Set openable object type to no type which is the default and means it's not a link to another object
|
|
AyaObjectType = (int)AyaType.NoType;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}//ens
|