161 lines
9.2 KiB
C#
161 lines
9.2 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace AyaNova.Biz
|
|
{
|
|
//************************************************
|
|
// This contains all the fields that are customizable on all object edit 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
|
|
{
|
|
//CoreBizObject add here
|
|
List<string> l = new List<string>{
|
|
AyaType.Widget.ToString(),AyaType.User.ToString()
|
|
};
|
|
return l;
|
|
}
|
|
}
|
|
|
|
|
|
public static bool IsValidFormFieldDefinitionKey(string key)
|
|
{
|
|
return AyaFormFieldDefinitionKeys.Contains(key);
|
|
}
|
|
|
|
public static List<AyaFormFieldDefinition> AyaFormFields(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>();
|
|
//CoreBizObject add here
|
|
if (key == AyaType.Widget.ToString())
|
|
{
|
|
|
|
|
|
#region WIDGET_KEY
|
|
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetName", FieldKey = "Name", Hideable = false });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetSerial", FieldKey = "Serial" });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetDollarAmount", FieldKey = "DollarAmount" });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetCount", FieldKey = "Count" });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserType", FieldKey = "UserType" });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetStartDate", FieldKey = "StartDate" });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetEndDate", FieldKey = "EndDate" });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetNotes", FieldKey = "Notes" });
|
|
//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 { TKey = "User", FieldKey = "UserId" });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "Active", FieldKey = "Active", Hideable = false });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "Tags", FieldKey = "Tags" });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "Wiki", FieldKey = "Wiki" });
|
|
//TODO: attachments form field?
|
|
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetCustom1", FieldKey = "WidgetCustom1", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetCustom2", FieldKey = "WidgetCustom2", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetCustom3", FieldKey = "WidgetCustom3", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetCustom4", FieldKey = "WidgetCustom4", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetCustom5", FieldKey = "WidgetCustom5", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetCustom6", FieldKey = "WidgetCustom6", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetCustom7", FieldKey = "WidgetCustom7", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetCustom8", FieldKey = "WidgetCustom8", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetCustom9", FieldKey = "WidgetCustom9", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetCustom10", FieldKey = "WidgetCustom10", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetCustom11", FieldKey = "WidgetCustom11", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetCustom12", FieldKey = "WidgetCustom12", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetCustom13", FieldKey = "WidgetCustom13", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetCustom14", FieldKey = "WidgetCustom14", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetCustom15", FieldKey = "WidgetCustom15", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "WidgetCustom16", FieldKey = "WidgetCustom16", IsCustomField = true });
|
|
return l;
|
|
#endregion
|
|
}
|
|
|
|
if (key == AyaType.User.ToString())
|
|
{
|
|
#region USER_KEY
|
|
l.Add(new AyaFormFieldDefinition { TKey = "Name", FieldKey = "Name", Hideable = false });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserEmployeeNumber", FieldKey = "EmployeeNumber" });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "AuthorizationRoles", FieldKey = "Roles", Hideable = false });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserNotes", FieldKey = "Notes" });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserType", FieldKey = "UserType", Hideable = false });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "Active", FieldKey = "Active", Hideable = false });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "Tags", FieldKey = "Tags" });
|
|
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserCustom1", FieldKey = "UserCustom1", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserCustom2", FieldKey = "UserCustom2", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserCustom3", FieldKey = "UserCustom3", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserCustom4", FieldKey = "UserCustom4", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserCustom5", FieldKey = "UserCustom5", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserCustom6", FieldKey = "UserCustom6", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserCustom7", FieldKey = "UserCustom7", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserCustom8", FieldKey = "UserCustom8", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserCustom9", FieldKey = "UserCustom9", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserCustom10", FieldKey = "UserCustom10", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserCustom11", FieldKey = "UserCustom11", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserCustom12", FieldKey = "UserCustom12", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserCustom13", FieldKey = "UserCustom13", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserCustom14", FieldKey = "UserCustom14", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserCustom15", FieldKey = "UserCustom15", IsCustomField = true });
|
|
l.Add(new AyaFormFieldDefinition { TKey = "UserCustom16", FieldKey = "UserCustom16", IsCustomField = true });
|
|
return l;
|
|
#endregion
|
|
}
|
|
|
|
throw new System.ArgumentOutOfRangeException($"AyaFormFieldDefinitions: {key} is not valid");
|
|
|
|
}
|
|
|
|
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 TKey { get; set; }
|
|
|
|
//CLIENT form customization
|
|
public bool Hideable { get; set; }
|
|
|
|
//CLIENT / SERVER - client display server validation purposes
|
|
public bool IsCustomField { get; set; }
|
|
|
|
|
|
public AyaFormFieldDefinition()
|
|
{
|
|
//most common defaults
|
|
Hideable = true;
|
|
IsCustomField = false;
|
|
}
|
|
}//eoc
|
|
|
|
|
|
}//ens
|