@optimiser/common 1.0.328 → 1.0.329
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/utility.js +35 -29
- package/package.json +1 -1
package/dist/lib/utility.js
CHANGED
|
@@ -5055,39 +5055,45 @@ exports.ValidateUserInput = ValidateUserInput;
|
|
|
5055
5055
|
* @return message in string
|
|
5056
5056
|
*/
|
|
5057
5057
|
function CheckConditionalField(field, record, action) {
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
if (field.Schema.
|
|
5062
|
-
|
|
5058
|
+
try {
|
|
5059
|
+
var msg = '';
|
|
5060
|
+
var fieldData = record[field.Name];
|
|
5061
|
+
if (field.Schema.ConditionalAction == 'enabled' && field.IsRequired == true) {
|
|
5062
|
+
if (field.Schema.UIDataType != 'autoincrement' && (fieldData === '' || fieldData === null || (fieldData === undefined && action == "add"))) {
|
|
5063
|
+
msg = ((field.DisplayName || field.Schema.DisplayName) || field.Name) + ' is required!';
|
|
5064
|
+
}
|
|
5063
5065
|
}
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5066
|
+
else if (record != undefined && eval(field.Schema.ConditionalExpression) == true) {
|
|
5067
|
+
switch (field.Schema.ConditionalAction) {
|
|
5068
|
+
case "mandatory":
|
|
5069
|
+
case "enabled-mandatory":
|
|
5070
|
+
case "show-enabled-mandatory":
|
|
5071
|
+
case "show-disabled-mandatory":
|
|
5072
|
+
if (field.Schema.UIDataType != 'autoincrement' && (fieldData === '' || fieldData === null || (fieldData === undefined && action == "add"))) {
|
|
5073
|
+
msg = ((field.DisplayName || field.Schema.DisplayName) || field.Name) + ' is conditionally required!';
|
|
5074
|
+
}
|
|
5075
|
+
break;
|
|
5076
|
+
}
|
|
5075
5077
|
}
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5078
|
+
else {
|
|
5079
|
+
switch (field.Schema.ConditionalAction) {
|
|
5080
|
+
case "show-disabled-mandatory":
|
|
5081
|
+
case "show-disabled-nonmandatory":
|
|
5082
|
+
break;
|
|
5083
|
+
case "show-enabled-mandatory":
|
|
5084
|
+
case "show-enabled-nonmandatory":
|
|
5085
|
+
if (fieldData) {
|
|
5086
|
+
msg = ((field.DisplayName || field.Schema.DisplayName) || field.Name) + ' is a hidden field and should not contain value.';
|
|
5087
|
+
}
|
|
5088
|
+
break;
|
|
5089
|
+
}
|
|
5088
5090
|
}
|
|
5091
|
+
return msg;
|
|
5092
|
+
}
|
|
5093
|
+
catch (error) {
|
|
5094
|
+
console.error("Internal Error in CheckConditionalField Function : ", error);
|
|
5095
|
+
return '';
|
|
5089
5096
|
}
|
|
5090
|
-
return msg;
|
|
5091
5097
|
}
|
|
5092
5098
|
/**
|
|
5093
5099
|
* TODO: Create lookup of fields of list schema for Vat Setting data
|