@optimiser/common 1.0.324 → 1.0.325
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 +53 -2
- package/package.json +2 -1
package/dist/lib/utility.js
CHANGED
|
@@ -4568,12 +4568,13 @@ function IsAnotherObjectField(pageData, fieldName) {
|
|
|
4568
4568
|
*/
|
|
4569
4569
|
function ValidateUserInput(options) {
|
|
4570
4570
|
return __awaiter(this, void 0, void 0, function () {
|
|
4571
|
-
var inputFields, pageData, documentID, db, action, objectSchema, objectName, pageFields, schemaFields, inputField, msg, _loop_18, _i, inputField_1, name_1, state_1, _loop_19, isValid, isValid, validateResp, _a, pageFields_1, pageField, state_2, countryData, err_3;
|
|
4571
|
+
var inputFields, fieldsJsonData, pageData, documentID, db, action, objectSchema, objectName, pageFields, schemaFields, inputField, msg, _loop_18, _i, inputField_1, name_1, state_1, _loop_19, isValid, isValid, validateResp, _a, pageFields_1, pageField, state_2, countryData, err_3;
|
|
4572
4572
|
return __generator(this, function (_b) {
|
|
4573
4573
|
switch (_b.label) {
|
|
4574
4574
|
case 0:
|
|
4575
4575
|
_b.trys.push([0, 7, , 8]);
|
|
4576
4576
|
inputFields = options.userInput;
|
|
4577
|
+
fieldsJsonData = bson_1.EJSON.parse(JSON.stringify(inputFields));
|
|
4577
4578
|
pageData = options.pageData;
|
|
4578
4579
|
documentID = options.objectID;
|
|
4579
4580
|
db = options.db;
|
|
@@ -4604,7 +4605,7 @@ function ValidateUserInput(options) {
|
|
|
4604
4605
|
}
|
|
4605
4606
|
}
|
|
4606
4607
|
_loop_19 = function (pageField) {
|
|
4607
|
-
var fieldName, fieldData, field, searchQuery, result, _a, minValue, maxValue, filter, searchObj, result, searchObj, totalRecord, _b, schemaData, result, searchObj, result, schemaData, result, searchObj, totalRecord, regexpression, phone, files, _i, fieldData_1, obj, searchObj, totalRecord, searchObj, result, _c, fieldData_2, obj;
|
|
4608
|
+
var fieldName, fieldData, field, searchQuery, result, fld, _a, minValue, maxValue, filter, searchObj, result, searchObj, totalRecord, _b, schemaData, result, searchObj, result, schemaData, result, searchObj, totalRecord, regexpression, phone, files, _i, fieldData_1, obj, searchObj, totalRecord, searchObj, result, _c, fieldData_2, obj;
|
|
4608
4609
|
return __generator(this, function (_d) {
|
|
4609
4610
|
switch (_d.label) {
|
|
4610
4611
|
case 0:
|
|
@@ -4652,6 +4653,14 @@ function ValidateUserInput(options) {
|
|
|
4652
4653
|
}
|
|
4653
4654
|
_d.label = 2;
|
|
4654
4655
|
case 2:
|
|
4656
|
+
// Added by Shahzaib to check conditional field criteria
|
|
4657
|
+
if (field.IsConditionalField) {
|
|
4658
|
+
fld = JSON.parse(JSON.stringify(pageField));
|
|
4659
|
+
fld.Schema = field;
|
|
4660
|
+
msg = CheckConditionalField(fld, fieldsJsonData, action);
|
|
4661
|
+
if (msg != "")
|
|
4662
|
+
return [2 /*return*/, "break"];
|
|
4663
|
+
}
|
|
4655
4664
|
if (!inputField.includes(fieldName)) return [3 /*break*/, 54];
|
|
4656
4665
|
if (!(fieldData || fieldData === 0 || fieldData === false)) return [3 /*break*/, 54];
|
|
4657
4666
|
_a = field.UIDataType;
|
|
@@ -5036,6 +5045,48 @@ function ValidateUserInput(options) {
|
|
|
5036
5045
|
});
|
|
5037
5046
|
}
|
|
5038
5047
|
exports.ValidateUserInput = ValidateUserInput;
|
|
5048
|
+
/**
|
|
5049
|
+
* TODO: Check conditional field criteria with user inputs
|
|
5050
|
+
*
|
|
5051
|
+
* @param {object} field Contains shcema
|
|
5052
|
+
* @param {object} record contains user inputs
|
|
5053
|
+
* @param {string} action shows add or update
|
|
5054
|
+
* @return message in string
|
|
5055
|
+
*/
|
|
5056
|
+
function CheckConditionalField(field, record, action) {
|
|
5057
|
+
var msg = '';
|
|
5058
|
+
var fieldData = record[field.Name];
|
|
5059
|
+
if (field.Schema.ConditionalAction == 'enabled' && field.IsRequired == true) {
|
|
5060
|
+
if (fieldData === '' || fieldData === null || (fieldData === undefined && action == "add")) {
|
|
5061
|
+
msg = ((field.DisplayName || field.Schema.DisplayName) || field.Name) + ' is required!';
|
|
5062
|
+
}
|
|
5063
|
+
}
|
|
5064
|
+
else if (record != undefined && eval(field.Schema.ConditionalExpression) == true) {
|
|
5065
|
+
switch (field.Schema.ConditionalAction) {
|
|
5066
|
+
case "mandatory":
|
|
5067
|
+
case "enabled-mandatory":
|
|
5068
|
+
case "show-enabled-mandatory":
|
|
5069
|
+
case "show-disabled-mandatory":
|
|
5070
|
+
if (fieldData === '' || fieldData === null || (fieldData === undefined && action == "add")) {
|
|
5071
|
+
msg = ((field.DisplayName || field.Schema.DisplayName) || field.Name) + ' is conditionally required!';
|
|
5072
|
+
}
|
|
5073
|
+
break;
|
|
5074
|
+
}
|
|
5075
|
+
}
|
|
5076
|
+
else {
|
|
5077
|
+
switch (field.Schema.ConditionalAction) {
|
|
5078
|
+
case "show-disabled-mandatory":
|
|
5079
|
+
case "show-disabled-nonmandatory":
|
|
5080
|
+
case "show-enabled-mandatory":
|
|
5081
|
+
case "show-enabled-nonmandatory":
|
|
5082
|
+
if (fieldData) {
|
|
5083
|
+
msg = ((field.DisplayName || field.Schema.DisplayName) || field.Name) + ' is a hidden field and should not contain value.';
|
|
5084
|
+
}
|
|
5085
|
+
break;
|
|
5086
|
+
}
|
|
5087
|
+
}
|
|
5088
|
+
return msg;
|
|
5089
|
+
}
|
|
5039
5090
|
/**
|
|
5040
5091
|
* TODO: Create lookup of fields of list schema for Vat Setting data
|
|
5041
5092
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optimiser/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.325",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/aws-sdk": "^2.7.0",
|
|
45
45
|
"@types/bson": "^4.0.2",
|
|
46
|
+
"@types/exceljs": "^1.3.0",
|
|
46
47
|
"@types/express": "^4.17.8",
|
|
47
48
|
"@types/ioredis": "^4.17.4",
|
|
48
49
|
"@types/moment": "^2.13.0",
|