145 lines
6.5 KiB
C#
145 lines
6.5 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace AyaNova.Biz
|
|
{
|
|
public static class FormAvailableFields
|
|
{
|
|
|
|
public const string WIDGET_FORM_KEY = "widget";
|
|
public const string USER_FORM_KEY = "user";
|
|
|
|
|
|
public static List<string> AvailableFormKeys
|
|
{
|
|
get
|
|
{
|
|
List<string> l = new List<string>{
|
|
WIDGET_FORM_KEY, USER_FORM_KEY
|
|
};
|
|
return l;
|
|
}
|
|
}
|
|
|
|
public static bool IsValidFormKey(string key)
|
|
{
|
|
return AvailableFormKeys.Contains(key);
|
|
}
|
|
|
|
public static List<FormField> FormFields(string key)
|
|
{
|
|
|
|
List<FormField> l = new List<FormField>();
|
|
switch (key)
|
|
{
|
|
case WIDGET_FORM_KEY:
|
|
l.Add(new FormField("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 FormField("WidgetSerial", "Serial"));//not in validation rules...you get the idea
|
|
l.Add(new FormField("WidgetDollarAmount", "DollarAmount"));
|
|
l.Add(new FormField("WidgetCount", "Count"));
|
|
l.Add(new FormField("WidgetRoles", "Roles"));
|
|
l.Add(new FormField("WidgetStartDate", "StartDate", false, false));
|
|
l.Add(new FormField("WidgetEndDate", "EndDate", false, false));
|
|
l.Add(new FormField("WidgetNotes", "Notes"));
|
|
l.Add(new FormField("Active", "Active", true));
|
|
l.Add(new FormField("Tags", "Tags", true));
|
|
l.Add(new FormField("WidgetCustom1", false, true, true));
|
|
l.Add(new FormField("WidgetCustom2", false, true, true));
|
|
l.Add(new FormField("WidgetCustom3", false, true, true));
|
|
l.Add(new FormField("WidgetCustom4", false, true, true));
|
|
l.Add(new FormField("WidgetCustom5", false, true, true));
|
|
l.Add(new FormField("WidgetCustom6", false, true, true));
|
|
l.Add(new FormField("WidgetCustom7", false, true, true));
|
|
l.Add(new FormField("WidgetCustom8", false, true, true));
|
|
l.Add(new FormField("WidgetCustom9", false, true, true));
|
|
l.Add(new FormField("WidgetCustom10", false, true, true));
|
|
l.Add(new FormField("WidgetCustom11", false, true, true));
|
|
l.Add(new FormField("WidgetCustom12", false, true, true));
|
|
l.Add(new FormField("WidgetCustom13", false, true, true));
|
|
l.Add(new FormField("WidgetCustom14", false, true, true));
|
|
l.Add(new FormField("WidgetCustom15", false, true, true));
|
|
l.Add(new FormField("WidgetCustom16", false, true, true));
|
|
break;
|
|
|
|
case USER_FORM_KEY:
|
|
l.Add(new FormField("Name", true, false));//is not shared localized text key and not hideable as it is in the validation rules for widget
|
|
l.Add(new FormField("EmployeeNumber"));
|
|
l.Add(new FormField("Roles", false, false));
|
|
l.Add(new FormField("UserNotes", "UserNotes"));
|
|
l.Add(new FormField("UserType", false, false));
|
|
l.Add(new FormField("Active", true, false));
|
|
l.Add(new FormField("Tags", true, false));
|
|
l.Add(new FormField("UserCustom1", false, true, true));
|
|
l.Add(new FormField("UserCustom2", false, true, true));
|
|
l.Add(new FormField("UserCustom3", false, true, true));
|
|
l.Add(new FormField("UserCustom4", false, true, true));
|
|
l.Add(new FormField("UserCustom5", false, true, true));
|
|
l.Add(new FormField("UserCustom6", false, true, true));
|
|
l.Add(new FormField("UserCustom7", false, true, true));
|
|
l.Add(new FormField("UserCustom8", false, true, true));
|
|
l.Add(new FormField("UserCustom9", false, true, true));
|
|
l.Add(new FormField("UserCustom10", false, true, true));
|
|
l.Add(new FormField("UserCustom11", false, true, true));
|
|
l.Add(new FormField("UserCustom12", false, true, true));
|
|
l.Add(new FormField("UserCustom13", false, true, true));
|
|
l.Add(new FormField("UserCustom14", false, true, true));
|
|
l.Add(new FormField("UserCustom15", false, true, true));
|
|
l.Add(new FormField("UserCustom16", false, true, true));
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
throw new System.ArgumentOutOfRangeException($"FormAvailableFields: {key} is not a valid form key");
|
|
}
|
|
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 FormAvailableFields
|
|
|
|
public class FormField
|
|
{
|
|
public string Key { get; set; }
|
|
public string PropertyName { get; set; }
|
|
//NOTE: Not hideable fields don't require a PropertyName value because they are already required and will be validated
|
|
public bool Hideable { get; set; }
|
|
public bool SharedLTKey { get; set; }
|
|
public bool Custom { get; set; }
|
|
|
|
|
|
public FormField(string key, string propertyName, bool sharedLTKey = false, bool hideable = true, bool custom = false)
|
|
{
|
|
Key = key;
|
|
Hideable = hideable;
|
|
Custom = custom;
|
|
SharedLTKey = sharedLTKey;
|
|
PropertyName = propertyName;//Only if hideable do they require this as non-hideable ones are automatically validated anyway and this is only required for validation
|
|
}
|
|
|
|
public FormField(string key, bool sharedLTKey = false, bool hideable = true, bool custom = false)
|
|
{
|
|
Key = key;
|
|
Hideable = hideable;
|
|
Custom = custom;
|
|
SharedLTKey = sharedLTKey;
|
|
PropertyName = null;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}//ens
|