This commit is contained in:
2020-02-27 19:48:43 +00:00
parent 5b0ce90157
commit 79b94b4ac2
5 changed files with 88 additions and 78 deletions

View File

@@ -3,6 +3,7 @@ using System.Linq;
using System.Text; using System.Text;
using AyaNova.Biz; using AyaNova.Biz;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Microsoft.EntityFrameworkCore;
namespace AyaNova.DataList namespace AyaNova.DataList
{ {
@@ -44,6 +45,10 @@ namespace AyaNova.DataList
public Newtonsoft.Json.Linq.JArray GenerateListColumnsJSONFromListView(JArray listViewArray) public Newtonsoft.Json.Linq.JArray GenerateListColumnsJSONFromListView(JArray listViewArray)
{ {
//custom fields handling
var ct = AyaNova.Util.ServiceProviderProvider.DBContext;
var FormCustomization = ct.FormCustom.AsNoTracking().SingleOrDefault(x => x.FormKey == AyaType.Widget.ToString());
var ListViewFieldKeys = GetFieldListFromListView(listViewArray); var ListViewFieldKeys = GetFieldListFromListView(listViewArray);
//Generate JSON fragment to return with column definitions //Generate JSON fragment to return with column definitions
@@ -71,7 +76,12 @@ namespace AyaNova.DataList
sb.Append(","); sb.Append(",");
sb.Append("{"); sb.Append("{");
//Build required part of column definition //Build required part of column definition
if (!o.IsCustomField)
sb.Append($"\"cm\":\"{o.LtKey}\",\"dt\":{(int)o.UiFieldDataType}"); sb.Append($"\"cm\":\"{o.LtKey}\",\"dt\":{(int)o.UiFieldDataType}");
else
{
//insert specific type for this custom field
}
//Has a AyObjectType? (linkable / openable) //Has a AyObjectType? (linkable / openable)
if (o.AyaObjectType != 0) if (o.AyaObjectType != 0)

View File

@@ -1,7 +1,4 @@
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using System.Text;
namespace AyaNova.Biz namespace AyaNova.Biz
{ {
@@ -15,8 +12,8 @@ namespace AyaNova.Biz
//DEFINE VALID KEYS HERE //DEFINE VALID KEYS HERE
public const string WIDGET_KEY = "widget"; // public const string WIDGET_KEY = "widget";
public const string USER_KEY = "user"; // public const string USER_KEY = "user";
public static List<string> AyaFormFieldDefinitionKeys public static List<string> AyaFormFieldDefinitionKeys
@@ -24,12 +21,13 @@ namespace AyaNova.Biz
get get
{ {
List<string> l = new List<string>{ List<string> l = new List<string>{
WIDGET_KEY, USER_KEY AyaType.Widget.ToString(),AyaType.User.ToString()
}; };
return l; return l;
} }
} }
public static bool IsValidFormFieldDefinitionKey(string key) public static bool IsValidFormFieldDefinitionKey(string key)
{ {
return AyaFormFieldDefinitionKeys.Contains(key); return AyaFormFieldDefinitionKeys.Contains(key);
@@ -42,9 +40,11 @@ namespace AyaNova.Biz
***************************** Otherwise the hidden field can't be set and the object can't be saved EVER ***************************** Otherwise the hidden field can't be set and the object can't be saved EVER
*/ */
List<AyaFormFieldDefinition> l = new List<AyaFormFieldDefinition>(); List<AyaFormFieldDefinition> l = new List<AyaFormFieldDefinition>();
switch (key)
if (key == AyaType.Widget.ToString())
{ {
case WIDGET_KEY:
#region WIDGET_KEY #region WIDGET_KEY
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetName", FieldKey = "Name", Hideable = false }); l.Add(new AyaFormFieldDefinition { LtKey = "WidgetName", FieldKey = "Name", Hideable = false });
@@ -77,9 +77,12 @@ namespace AyaNova.Biz
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom14", FieldKey = "WidgetCustom14", 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 = "WidgetCustom15", FieldKey = "WidgetCustom15", IsCustomField = true });
l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom16", FieldKey = "WidgetCustom16", IsCustomField = true }); l.Add(new AyaFormFieldDefinition { LtKey = "WidgetCustom16", FieldKey = "WidgetCustom16", IsCustomField = true });
break; return l;
#endregion #endregion
case USER_KEY: }
if (key == AyaType.User.ToString())
{
#region USER_KEY #region USER_KEY
l.Add(new AyaFormFieldDefinition { LtKey = "Name", FieldKey = "Name", Hideable = false }); l.Add(new AyaFormFieldDefinition { LtKey = "Name", FieldKey = "Name", Hideable = false });
l.Add(new AyaFormFieldDefinition { LtKey = "UserEmployeeNumber", FieldKey = "EmployeeNumber" }); l.Add(new AyaFormFieldDefinition { LtKey = "UserEmployeeNumber", FieldKey = "EmployeeNumber" });
@@ -105,15 +108,12 @@ namespace AyaNova.Biz
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom14", FieldKey = "UserCustom14", 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 = "UserCustom15", FieldKey = "UserCustom15", IsCustomField = true });
l.Add(new AyaFormFieldDefinition { LtKey = "UserCustom16", FieldKey = "UserCustom16", 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; return l;
#endregion
}
throw new System.ArgumentOutOfRangeException($"AyaFormFieldDefinitions: {key} is not valid");
} }
public static string TranslateLTCustomFieldToInternalCustomFieldName(string lTCustomFieldName) public static string TranslateLTCustomFieldToInternalCustomFieldName(string lTCustomFieldName)

View File

@@ -381,7 +381,7 @@ namespace AyaNova.Biz
AddError(ApiErrorCode.VALIDATION_LENGTH_EXCEEDED, "EmployeeNumber", "255 max"); AddError(ApiErrorCode.VALIDATION_LENGTH_EXCEEDED, "EmployeeNumber", "255 max");
//Any form customizations to validate? //Any form customizations to validate?
var FormCustomization = await ct.FormCustom.SingleOrDefaultAsync(x => x.FormKey == AyaFormFieldDefinitions.USER_KEY); var FormCustomization = await ct.FormCustom.SingleOrDefaultAsync(x => x.FormKey == AyaType.User.ToString());
if (FormCustomization != null) if (FormCustomization != null)
{ {
//Yeppers, do the validation, there are two, the custom fields and the regular fields that might be set to required //Yeppers, do the validation, there are two, the custom fields and the regular fields that might be set to required

View File

@@ -285,7 +285,7 @@ namespace AyaNova.Biz
} }
//Any form customizations to validate? //Any form customizations to validate?
var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(x => x.FormKey == AyaFormFieldDefinitions.WIDGET_KEY); var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(x => x.FormKey == AyaType.Widget.ToString());
if (FormCustomization != null) if (FormCustomization != null)
{ {
//Yeppers, do the validation, there are two, the custom fields and the regular fields that might be set to required //Yeppers, do the validation, there are two, the custom fields and the regular fields that might be set to required

View File

@@ -85,7 +85,7 @@ namespace AyaNova.Util
var fc = new FormCustom() var fc = new FormCustom()
{ {
FormKey = AyaFormFieldDefinitions.WIDGET_KEY, FormKey = AyaType.Widget.ToString(),
Template = @"[ Template = @"[
{ {
""fld"": ""Notes"", ""fld"": ""Notes"",