This commit is contained in:
2021-02-20 16:53:35 +00:00
parent a36bda8b5f
commit 9a1f4e25f2
7 changed files with 22 additions and 21 deletions

View File

@@ -132,7 +132,7 @@ namespace AyaNova.Api.Controllers
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
return Ok(ApiOkResponse.Response(FormFieldReference.FormFieldKeys));
return Ok(ApiOkResponse.Response(FormFieldOptionalCustomizableReference.FormFieldKeys));
}

View File

@@ -50,9 +50,9 @@ namespace AyaNova.Api.Controllers
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
if (FormFieldReference.IsValidFormFieldKey(key))
if (FormFieldOptionalCustomizableReference.IsValidFormFieldKey(key))
{
return Ok(ApiOkResponse.Response(FormFieldReference.FormFieldReferenceList(key)));
return Ok(ApiOkResponse.Response(FormFieldOptionalCustomizableReference.FormFieldReferenceList(key)));
}
else
{

View File

@@ -84,7 +84,7 @@ namespace AyaNova.DataList
{
JObject j = JObject.Parse(cust);
//convert field name to cust name then get value
var InternalCustomFieldName = FormFieldReference.TranslateLTCustomFieldToInternalCustomFieldName(TemplateField);
var InternalCustomFieldName = FormFieldOptionalCustomizableReference.TranslateLTCustomFieldToInternalCustomFieldName(TemplateField);
//Sometimes a custom field is specified but doesn't exist in the collection so don't assume it's there
JToken o = j[InternalCustomFieldName];
if (o != null)

View File

@@ -16,7 +16,7 @@ namespace AyaNova.Biz
return;
var FormTemplate = JArray.Parse(formCustom.Template);
var ThisFormCustomFieldsList = FormFieldReference.FormFieldReferenceList(formCustom.FormKey).Where(z => z.IsCustomField == true).Select(z => z.TKey).ToList();
var ThisFormCustomFieldsList = FormFieldOptionalCustomizableReference.FormFieldReferenceList(formCustom.FormKey).Where(z => z.IsCustomField == true).Select(z => z.TKey).ToList();
//If the customFields string is empty then only validation is if any of the fields are required to be filled in
if (!hasCustomData)
@@ -52,7 +52,7 @@ namespace AyaNova.Biz
{
//Translate the LT field key to the actual customFieldData field key
var InternalCustomFieldName = FormFieldReference.TranslateLTCustomFieldToInternalCustomFieldName(iFldKey);
var InternalCustomFieldName = FormFieldOptionalCustomizableReference.TranslateLTCustomFieldToInternalCustomFieldName(iFldKey);
//Check if it's set to required
var isRequired = CustomFieldIsSetToRequired(FormTemplate, iFldKey);

View File

@@ -86,7 +86,7 @@ namespace AyaNova.Biz
}
//If it doesn't exist, vet the form key name is ok by checking with this list
if (!FormFieldReference.FormFieldKeys.Contains(formKey))
if (!FormFieldOptionalCustomizableReference.FormFieldKeys.Contains(formKey))
{
//Nope, whatever it is, it's not valid
return null;
@@ -156,7 +156,7 @@ namespace AyaNova.Biz
AddError(ApiErrorCode.VALIDATION_REQUIRED, "FormKey");
else
{
if (!FormFieldReference.IsValidFormFieldKey(inObj.FormKey))
if (!FormFieldOptionalCustomizableReference.IsValidFormFieldKey(inObj.FormKey))
{
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "FormKey");
}
@@ -183,7 +183,7 @@ namespace AyaNova.Biz
if ((!PropertyHasErrors("FormKey") && !string.IsNullOrWhiteSpace(inObj.Template)))
{
var ValidCustomFieldTypes = CustomFieldType.ValidCustomFieldTypes;
var ValidFormFields = FormFieldReference.FormFieldReferenceList(inObj.FormKey);
var ValidFormFields = FormFieldOptionalCustomizableReference.FormFieldReferenceList(inObj.FormKey);
try
{
//Parse the json, expecting something like this:
@@ -228,12 +228,13 @@ namespace AyaNova.Biz
if (MasterFormField != null)
{
if (formFieldItem["hide"] != null)
{
var fieldHideValue = formFieldItem["hide"].Value<bool>();
if (!MasterFormField.Hideable && fieldHideValue == true)
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Template", $"Template array item {i} (\"{MasterFormField.FieldKey}\"), \"hide\" property value of \"{fieldHideValue}\" is not valid, this field is core and cannot be hidden");
}
//removed due to removal of hidden property in ff reference since only customizable fields are hideable by default
// if (formFieldItem["hide"] != null)
// {
// var fieldHideValue = formFieldItem["hide"].Value<bool>();
// if (!MasterFormField.Hideable && fieldHideValue == true)
// AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Template", $"Template array item {i} (\"{MasterFormField.FieldKey}\"), \"hide\" property value of \"{fieldHideValue}\" is not valid, this field is core and cannot be hidden");
// }
//validate if it's a custom field that it has a type specified
if (MasterFormField.IsCustomField && formFieldItem["type"] == null)

View File

@@ -12,7 +12,7 @@ namespace AyaNova.Biz
//See the DataList folder / namespace for LIST related similar class
public static class FormFieldReference
public static class FormFieldOptionalCustomizableReference
{
private static Dictionary<string, List<FormField>> _formFields;
private static List<string> _formFieldKeys = null;
@@ -1057,14 +1057,14 @@ namespace AyaNova.Biz
public class FormField
{
//CLIENT / SERVER Unique identifier used at BOTH client and server
//also the sql displaycolumnname if identical
//MUST MATCH MODEL PROPERTY NAME EXACTLY
public string FieldKey { get; set; }
//CLIENT Use only for display
//CLIENT Use only for display in customization form
public string TKey { get; set; }
//CLIENT form customization
public bool Hideable { get; set; }
// public bool Hideable { get; set; }
//CLIENT / SERVER - client display server validation purposes
public bool IsCustomField { get; set; }
@@ -1073,7 +1073,7 @@ namespace AyaNova.Biz
public FormField()
{
//most common defaults
Hideable = true;
// Hideable = true;
IsCustomField = false;
}
}//eoc

View File

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