diff --git a/server/AyaNova/biz/FormCustomBiz.cs b/server/AyaNova/biz/FormCustomBiz.cs index e2ab83da..1808dee0 100644 --- a/server/AyaNova/biz/FormCustomBiz.cs +++ b/server/AyaNova/biz/FormCustomBiz.cs @@ -62,8 +62,8 @@ namespace AyaNova.Biz // FormCustom outObj = inObj; - outObj.Template=JsonUtil.CompactJson(outObj.Template); - + outObj.Template = JsonUtil.CompactJson(outObj.Template); + await ct.FormCustom.AddAsync(outObj); await ct.SaveChangesAsync(); @@ -104,7 +104,7 @@ namespace AyaNova.Biz //put internal bool Put(FormCustom dbObj, FormCustom inObj) { - + //Replace the db object with the PUT object CopyObject.Copy(inObj, dbObj, "Id"); //Set "original" value of concurrency token to input token @@ -115,7 +115,7 @@ namespace AyaNova.Biz if (HasErrors) return false; - dbObj.Template=JsonUtil.CompactJson(dbObj.Template); + dbObj.Template = JsonUtil.CompactJson(dbObj.Template); //Log modification EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct); @@ -175,7 +175,7 @@ namespace AyaNova.Biz //Parse the json, expecting something like this: //[{fld:"ltkeyfieldname",hide:"true/false",required:"true/false", type:"bool"},{fld:"ltkeyfieldname",hide:"true/false",required:"true/false", type:"text"] //Array at root is valid json and saves a bit of bandwidth so minimal is best - var v = JArray.Parse(inObj.Template); + var v = JArray.Parse(inObj.Template); for (int i = 0; i < v.Count; i++) { @@ -218,11 +218,12 @@ namespace AyaNova.Biz } //validate if it's a custom field that it has a type specified - if (MasterFormField.Custom && formFieldItem["type"]==null){ - AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Template", $"Template array item {i}, \"type\" property value is MISSING for custom filed, Custom fields MUST have types specified"); - } - - + if (MasterFormField.Custom && formFieldItem["type"] == null) + { + AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Template", $"Template array item {i}, \"type\" property value is MISSING for custom filed, Custom fields MUST have types specified"); + } + + if (formFieldItem["type"] != null) { @@ -238,7 +239,7 @@ namespace AyaNova.Biz } -TODO: why is required required if it's just a regular field being hidden? + //other code depends on seeing the required value even if it's not set to true if (formFieldItem["required"] == null) AddError(ApiErrorCode.VALIDATION_REQUIRED, "Template", $"Template array item {i}, object is missing required \"required\" property "); diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index 1851c7ad..39e86360 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -89,6 +89,7 @@ namespace AyaNova.Util }, { ""fld"": ""WidgetSerial"", + ""required"": ""false"", ""hide"": ""true"" }, {