@optimiser/common 1.0.312 → 1.0.314
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 +101 -103
- package/package.json +1 -1
package/dist/lib/utility.js
CHANGED
|
@@ -1869,97 +1869,88 @@ function BuildGridFieldProjection(project, field, group) {
|
|
|
1869
1869
|
var searchConcatArry = [];
|
|
1870
1870
|
switch (field.Schema.UIDataType) {
|
|
1871
1871
|
// below code was added by Shahzaib on 05/09/2022
|
|
1872
|
-
// case "lookup":
|
|
1873
|
-
// case "multilookup":
|
|
1874
|
-
// case "dropdown":
|
|
1875
|
-
// case "multiselect":
|
|
1876
|
-
// alias = fldName + constants.LookupAlias;
|
|
1877
|
-
// project[fldName] = 1;
|
|
1878
|
-
// project[alias] = 1;
|
|
1879
|
-
// project[searchAlias] = 1;
|
|
1880
|
-
// break;
|
|
1881
|
-
// Below code was commented by Shahzaib on 05/09/2022, searchAlias was added instead of it.
|
|
1882
1872
|
case "lookup":
|
|
1883
|
-
alias = fldName + constants_1.default.LookupAlias;
|
|
1884
|
-
project[fldName] = 1;
|
|
1885
|
-
project[alias] = 1;
|
|
1886
|
-
var _loop_13 = function (i) {
|
|
1887
|
-
if (field.Schema.ExcludeLookupFieldsOnSearch && field.Schema.ExcludeLookupFieldsOnSearch.filter(function (x) { return x == field.Schema.LookupFields[i]; }).length != 0) {
|
|
1888
|
-
return "continue";
|
|
1889
|
-
}
|
|
1890
|
-
// searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], ""] });
|
|
1891
|
-
// added by Shahzaib, make int to string and concat
|
|
1892
|
-
searchConcatArry.push({ "$ifNull": [{ $toString: '$' + alias + '.' + field.Schema.LookupFields[i] }, ""] });
|
|
1893
|
-
if (i < field.Schema.LookupFields.length - 1) {
|
|
1894
|
-
searchConcatArry.push(" ");
|
|
1895
|
-
}
|
|
1896
|
-
};
|
|
1897
|
-
for (var i = 0; i < field.Schema.LookupFields.length; i++) {
|
|
1898
|
-
_loop_13(i);
|
|
1899
|
-
}
|
|
1900
|
-
;
|
|
1901
|
-
project[fldName + '_SearchValue'] = { $concat: searchConcatArry };
|
|
1902
|
-
break;
|
|
1903
1873
|
case "multilookup":
|
|
1904
|
-
alias = fldName + constants_1.default.LookupAlias;
|
|
1905
|
-
project[fldName] = 1;
|
|
1906
|
-
project[alias] = 1;
|
|
1907
|
-
for (var i = 0; i < field.Schema.LookupFields.length; i++) {
|
|
1908
|
-
searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], [" "]] });
|
|
1909
|
-
if (i < field.Schema.LookupFields.length - 1) {
|
|
1910
|
-
searchConcatArry.push([" "]);
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
;
|
|
1914
|
-
//project[fldName + '_SearchValue'] = { $concatArrays: searchConcatArry };
|
|
1915
|
-
project[fldName + '_SearchValue'] = {
|
|
1916
|
-
$reduce: {
|
|
1917
|
-
input: { $concatArrays: searchConcatArry },
|
|
1918
|
-
initialValue: "",
|
|
1919
|
-
//in: { $concat: ["$$value", "$$this"] } // Commented by and below line was added by Shahzaib, make int to string
|
|
1920
|
-
in: { $concat: ["$$value", { $toString: "$$this" }] }
|
|
1921
|
-
}
|
|
1922
|
-
};
|
|
1923
|
-
break;
|
|
1924
1874
|
case "dropdown":
|
|
1925
|
-
alias = fldName + constants_1.default.LookupAlias;
|
|
1926
|
-
project[fldName] = 1;
|
|
1927
|
-
project[alias] = 1;
|
|
1928
|
-
if (field.Schema.LookupObject) {
|
|
1929
|
-
for (var i = 0; i < field.Schema.LookupFields.length; i++) {
|
|
1930
|
-
//searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], ""] });
|
|
1931
|
-
// added by Mohan, make int to string and concat
|
|
1932
|
-
searchConcatArry.push({ "$ifNull": [{ $toString: '$' + alias + '.' + field.Schema.LookupFields[i] }, ""] });
|
|
1933
|
-
if (i < field.Schema.LookupFields.length - 1) {
|
|
1934
|
-
searchConcatArry.push(" ");
|
|
1935
|
-
}
|
|
1936
|
-
}
|
|
1937
|
-
;
|
|
1938
|
-
project[fldName + '_SearchValue'] = { $concat: searchConcatArry };
|
|
1939
|
-
}
|
|
1940
|
-
else {
|
|
1941
|
-
project[fldName + '_SearchValue'] = '$' + alias + '.Value';
|
|
1942
|
-
}
|
|
1943
|
-
break;
|
|
1944
1875
|
case "multiselect":
|
|
1945
1876
|
alias = fldName + constants_1.default.LookupAlias;
|
|
1946
1877
|
project[fldName] = 1;
|
|
1947
1878
|
project[alias] = 1;
|
|
1948
|
-
|
|
1949
|
-
for (var i = 0; i < field.Schema.LookupFields.length; i++) {
|
|
1950
|
-
searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], [" "]] });
|
|
1951
|
-
if (i < field.Schema.LookupFields.length - 1) {
|
|
1952
|
-
searchConcatArry.push([" "]);
|
|
1953
|
-
}
|
|
1954
|
-
}
|
|
1955
|
-
;
|
|
1956
|
-
project[fldName + '_SearchValue'] = { $concatArrays: searchConcatArry };
|
|
1957
|
-
}
|
|
1958
|
-
else {
|
|
1959
|
-
searchConcatArry.push('$' + alias + '.Value');
|
|
1960
|
-
project[fldName + '_SearchValue'] = { $concatArrays: searchConcatArry };
|
|
1961
|
-
}
|
|
1879
|
+
project[searchAlias] = 1;
|
|
1962
1880
|
break;
|
|
1881
|
+
// Below code was commented by Shahzaib on 05/09/2022, searchAlias was added instead of it.
|
|
1882
|
+
// case "lookup":
|
|
1883
|
+
// alias = fldName + constants.LookupAlias;
|
|
1884
|
+
// project[fldName] = 1;
|
|
1885
|
+
// project[alias] = 1;
|
|
1886
|
+
// for (let i = 0; i < field.Schema.LookupFields.length; i++) {
|
|
1887
|
+
// if (field.Schema.ExcludeLookupFieldsOnSearch && field.Schema.ExcludeLookupFieldsOnSearch.filter((x: AnyObjectInterface) => x == field.Schema.LookupFields[i]).length != 0) {
|
|
1888
|
+
// continue;
|
|
1889
|
+
// }
|
|
1890
|
+
// // searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], ""] });
|
|
1891
|
+
// // added by Shahzaib, make int to string and concat
|
|
1892
|
+
// searchConcatArry.push({ "$ifNull": [{$toString : '$' + alias + '.' + field.Schema.LookupFields[i]}, ""] });
|
|
1893
|
+
// if (i < field.Schema.LookupFields.length - 1) {
|
|
1894
|
+
// searchConcatArry.push(" ");
|
|
1895
|
+
// }
|
|
1896
|
+
// };
|
|
1897
|
+
// project[fldName + '_SearchValue'] = { $concat: searchConcatArry };
|
|
1898
|
+
// break;
|
|
1899
|
+
// case "multilookup":
|
|
1900
|
+
// alias = fldName + constants.LookupAlias;
|
|
1901
|
+
// project[fldName] = 1;
|
|
1902
|
+
// project[alias] = 1;
|
|
1903
|
+
// for (let i = 0; i < field.Schema.LookupFields.length; i++) {
|
|
1904
|
+
// searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], [" "]] });
|
|
1905
|
+
// if (i < field.Schema.LookupFields.length - 1) {
|
|
1906
|
+
// searchConcatArry.push([" "]);
|
|
1907
|
+
// }
|
|
1908
|
+
// };
|
|
1909
|
+
// //project[fldName + '_SearchValue'] = { $concatArrays: searchConcatArry };
|
|
1910
|
+
// project[fldName + '_SearchValue'] = {
|
|
1911
|
+
// $reduce: {
|
|
1912
|
+
// input: { $concatArrays: searchConcatArry },
|
|
1913
|
+
// initialValue: "",
|
|
1914
|
+
// //in: { $concat: ["$$value", "$$this"] } // Commented by and below line was added by Shahzaib, make int to string
|
|
1915
|
+
// in: { $concat: ["$$value", { $toString : "$$this" }] }
|
|
1916
|
+
// }
|
|
1917
|
+
// };
|
|
1918
|
+
// break;
|
|
1919
|
+
// case "dropdown":
|
|
1920
|
+
// alias = fldName + constants.LookupAlias;
|
|
1921
|
+
// project[fldName] = 1;
|
|
1922
|
+
// project[alias] = 1;
|
|
1923
|
+
// if (field.Schema.LookupObject) {
|
|
1924
|
+
// for (let i = 0; i < field.Schema.LookupFields.length; i++) {
|
|
1925
|
+
// //searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], ""] });
|
|
1926
|
+
// // added by Mohan, make int to string and concat
|
|
1927
|
+
// searchConcatArry.push({ "$ifNull": [{$toString : '$' + alias + '.' + field.Schema.LookupFields[i]}, ""] });
|
|
1928
|
+
// if (i < field.Schema.LookupFields.length - 1) {
|
|
1929
|
+
// searchConcatArry.push(" ");
|
|
1930
|
+
// }
|
|
1931
|
+
// };
|
|
1932
|
+
// project[fldName + '_SearchValue'] = { $concat: searchConcatArry };
|
|
1933
|
+
// } else {
|
|
1934
|
+
// project[fldName + '_SearchValue'] = '$' + alias + '.Value';
|
|
1935
|
+
// }
|
|
1936
|
+
// break;
|
|
1937
|
+
// case "multiselect":
|
|
1938
|
+
// alias = fldName + constants.LookupAlias;
|
|
1939
|
+
// project[fldName] = 1;
|
|
1940
|
+
// project[alias] = 1;
|
|
1941
|
+
// if (field.Schema.LookupObject) {
|
|
1942
|
+
// for (let i = 0; i < field.Schema.LookupFields.length; i++) {
|
|
1943
|
+
// searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], [" "] ] });
|
|
1944
|
+
// if (i < field.Schema.LookupFields.length - 1) {
|
|
1945
|
+
// searchConcatArry.push([" "]);
|
|
1946
|
+
// }
|
|
1947
|
+
// };
|
|
1948
|
+
// project[fldName + '_SearchValue'] = { $concatArrays: searchConcatArry };
|
|
1949
|
+
// } else {
|
|
1950
|
+
// searchConcatArry.push('$' + alias + '.Value');
|
|
1951
|
+
// project[fldName + '_SearchValue'] = { $concatArrays: searchConcatArry };
|
|
1952
|
+
// }
|
|
1953
|
+
// break;
|
|
1963
1954
|
case "file":
|
|
1964
1955
|
case "image":
|
|
1965
1956
|
alias = fldName + constants_1.default.LookupAlias;
|
|
@@ -2144,9 +2135,16 @@ function FilterConditions(condition, match, fields) {
|
|
|
2144
2135
|
match.$or = new Array();
|
|
2145
2136
|
sets = match.$or;
|
|
2146
2137
|
}
|
|
2147
|
-
var
|
|
2138
|
+
var _loop_13 = function (i) {
|
|
2148
2139
|
var _a, _b, _c;
|
|
2149
2140
|
var obj = condition.Filters[i];
|
|
2141
|
+
if (condition.DateFormat) {
|
|
2142
|
+
obj.DateFormat = condition.DateFormat;
|
|
2143
|
+
}
|
|
2144
|
+
if (condition.FiscalFrom || condition.FiscalMonth) {
|
|
2145
|
+
obj.FiscalFrom = condition.FiscalFrom;
|
|
2146
|
+
obj.FiscalMonth = condition.FiscalMonth;
|
|
2147
|
+
}
|
|
2150
2148
|
if (obj.Type == "Child") {
|
|
2151
2149
|
var childMatch = {};
|
|
2152
2150
|
sets.push(childMatch);
|
|
@@ -2201,13 +2199,13 @@ function FilterConditions(condition, match, fields) {
|
|
|
2201
2199
|
var operator = obj.Operator;
|
|
2202
2200
|
var startCompareDate = void 0, endCompareDate = void 0;
|
|
2203
2201
|
if (operator === "custom") {
|
|
2204
|
-
startCompareDate = moment_1.default((_a = obj.Value) === null || _a === void 0 ? void 0 : _a.From,
|
|
2205
|
-
endCompareDate = moment_1.default((_b = obj.Value) === null || _b === void 0 ? void 0 : _b.To,
|
|
2202
|
+
startCompareDate = moment_1.default((_a = obj.Value) === null || _a === void 0 ? void 0 : _a.From, obj.DateFormat).startOf('day');
|
|
2203
|
+
endCompareDate = moment_1.default((_b = obj.Value) === null || _b === void 0 ? void 0 : _b.To, obj.DateFormat).endOf('day');
|
|
2206
2204
|
}
|
|
2207
2205
|
else {
|
|
2208
2206
|
var _d = helper_1.GetDateRangeFromOperatorValue(operator, obj.FiscalMonth, obj.FiscalFrom), startDate = _d.startDate, endDate = _d.endDate;
|
|
2209
|
-
startCompareDate = moment_1.default(startDate,
|
|
2210
|
-
endCompareDate = moment_1.default(endDate,
|
|
2207
|
+
startCompareDate = moment_1.default(startDate, obj.DateFormat).startOf('day');
|
|
2208
|
+
endCompareDate = moment_1.default(endDate, obj.DateFormat).endOf('day');
|
|
2211
2209
|
}
|
|
2212
2210
|
matchValue = { '$gte': new Date(moment_1.default(startCompareDate).toISOString()), '$lte': new Date(moment_1.default(endCompareDate).toISOString()) };
|
|
2213
2211
|
}
|
|
@@ -2328,7 +2326,7 @@ function FilterConditions(condition, match, fields) {
|
|
|
2328
2326
|
}
|
|
2329
2327
|
};
|
|
2330
2328
|
for (var i = 0; i < condition.Filters.length; i++) {
|
|
2331
|
-
|
|
2329
|
+
_loop_13(i);
|
|
2332
2330
|
}
|
|
2333
2331
|
}
|
|
2334
2332
|
}
|
|
@@ -2336,7 +2334,7 @@ exports.FilterConditions = FilterConditions;
|
|
|
2336
2334
|
function GirdHeaderFilters(filters, fields) {
|
|
2337
2335
|
try {
|
|
2338
2336
|
var sets = [];
|
|
2339
|
-
var
|
|
2337
|
+
var _loop_14 = function (i) {
|
|
2340
2338
|
var obj = filters[i];
|
|
2341
2339
|
var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
|
|
2342
2340
|
if (field) {
|
|
@@ -2389,7 +2387,7 @@ function GirdHeaderFilters(filters, fields) {
|
|
|
2389
2387
|
}
|
|
2390
2388
|
};
|
|
2391
2389
|
for (var i = 0; i < filters.length; i++) {
|
|
2392
|
-
|
|
2390
|
+
_loop_14(i);
|
|
2393
2391
|
}
|
|
2394
2392
|
return { '$and': sets };
|
|
2395
2393
|
}
|
|
@@ -2401,7 +2399,7 @@ exports.GirdHeaderFilters = GirdHeaderFilters;
|
|
|
2401
2399
|
function FieldsGridHeaderFilters(filters, fields) {
|
|
2402
2400
|
var sets = [];
|
|
2403
2401
|
var lookupFieldsSets = [];
|
|
2404
|
-
var
|
|
2402
|
+
var _loop_15 = function (i) {
|
|
2405
2403
|
var _a;
|
|
2406
2404
|
var obj = filters[i];
|
|
2407
2405
|
var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
|
|
@@ -2445,7 +2443,7 @@ function FieldsGridHeaderFilters(filters, fields) {
|
|
|
2445
2443
|
}
|
|
2446
2444
|
};
|
|
2447
2445
|
for (var i = 0; i < filters.length; i++) {
|
|
2448
|
-
|
|
2446
|
+
_loop_15(i);
|
|
2449
2447
|
}
|
|
2450
2448
|
return { '$and': sets, 'lookupConditions': lookupFieldsSets };
|
|
2451
2449
|
}
|
|
@@ -2483,7 +2481,7 @@ function AddLog(req, objectName, logAction, objLogProp, db, next) {
|
|
|
2483
2481
|
exports.AddLog = AddLog;
|
|
2484
2482
|
function CheckFilterFieldsProjection(condition, fields, pageData, project) {
|
|
2485
2483
|
if (condition != undefined && condition.Filters.length > 0) {
|
|
2486
|
-
var
|
|
2484
|
+
var _loop_16 = function (i) {
|
|
2487
2485
|
var objFilter = condition.Filters[i];
|
|
2488
2486
|
if (objFilter.Type == "Child") {
|
|
2489
2487
|
CheckFilterFieldsProjection(objFilter, fields, pageData, project);
|
|
@@ -2501,7 +2499,7 @@ function CheckFilterFieldsProjection(condition, fields, pageData, project) {
|
|
|
2501
2499
|
}
|
|
2502
2500
|
};
|
|
2503
2501
|
for (var i = 0; i < condition.Filters.length; i++) {
|
|
2504
|
-
|
|
2502
|
+
_loop_16(i);
|
|
2505
2503
|
}
|
|
2506
2504
|
}
|
|
2507
2505
|
}
|
|
@@ -4178,7 +4176,7 @@ exports.GetDayIndex = GetDayIndex;
|
|
|
4178
4176
|
function GetUserProfile(msp_d, db, mdb, next) {
|
|
4179
4177
|
var _a;
|
|
4180
4178
|
return __awaiter(this, void 0, void 0, function () {
|
|
4181
|
-
var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, companylicenceDetail, receptionLicense, moduleList,
|
|
4179
|
+
var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, companylicenceDetail, receptionLicense, moduleList, _loop_17, i, error_4;
|
|
4182
4180
|
return __generator(this, function (_b) {
|
|
4183
4181
|
switch (_b.label) {
|
|
4184
4182
|
case 0:
|
|
@@ -4257,14 +4255,14 @@ function GetUserProfile(msp_d, db, mdb, next) {
|
|
|
4257
4255
|
moduleList = userProfile_1[0].ModuleList;
|
|
4258
4256
|
userProfile_1[0].HasControlPanelAccess = [];
|
|
4259
4257
|
if (userProfile_1[0].Permissions) {
|
|
4260
|
-
|
|
4258
|
+
_loop_17 = function (i) {
|
|
4261
4259
|
userProfile_1[0].Permissions[i].ModuleData = moduleList.find(function (x) { return x._id == userProfile_1[0].Permissions[i].ModuleID; });
|
|
4262
4260
|
if ((_a = userProfile_1[0].Permissions[i].Operations) === null || _a === void 0 ? void 0 : _a.includes("Control Panel")) {
|
|
4263
4261
|
userProfile_1[0].HasControlPanelAccess.push(userProfile_1[0].Permissions[i].ModuleID);
|
|
4264
4262
|
}
|
|
4265
4263
|
};
|
|
4266
4264
|
for (i = 0; i < userProfile_1[0].Permissions.length; i++) {
|
|
4267
|
-
|
|
4265
|
+
_loop_17(i);
|
|
4268
4266
|
}
|
|
4269
4267
|
}
|
|
4270
4268
|
if (moduleList.length == 0) {
|
|
@@ -4561,7 +4559,7 @@ function IsAnotherObjectField(pageData, fieldName) {
|
|
|
4561
4559
|
*/
|
|
4562
4560
|
function ValidateUserInput(options) {
|
|
4563
4561
|
return __awaiter(this, void 0, void 0, function () {
|
|
4564
|
-
var inputFields, pageData, documentID, db, action, objectSchema, objectName, pageFields, schemaFields, inputField, msg,
|
|
4562
|
+
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;
|
|
4565
4563
|
return __generator(this, function (_b) {
|
|
4566
4564
|
switch (_b.label) {
|
|
4567
4565
|
case 0:
|
|
@@ -4582,7 +4580,7 @@ function ValidateUserInput(options) {
|
|
|
4582
4580
|
inputField = Object.keys(inputFields);
|
|
4583
4581
|
msg = '';
|
|
4584
4582
|
if (inputField && inputField.length) {
|
|
4585
|
-
|
|
4583
|
+
_loop_18 = function (name_1) {
|
|
4586
4584
|
var field = pageFields.find(function (x) { return x.Name == name_1; });
|
|
4587
4585
|
if (field == undefined && !IsSystemField(objectName, name_1)) {
|
|
4588
4586
|
msg = name_1 + " is not valid field!";
|
|
@@ -4591,12 +4589,12 @@ function ValidateUserInput(options) {
|
|
|
4591
4589
|
};
|
|
4592
4590
|
for (_i = 0, inputField_1 = inputField; _i < inputField_1.length; _i++) {
|
|
4593
4591
|
name_1 = inputField_1[_i];
|
|
4594
|
-
state_1 =
|
|
4592
|
+
state_1 = _loop_18(name_1);
|
|
4595
4593
|
if (state_1 === "break")
|
|
4596
4594
|
break;
|
|
4597
4595
|
}
|
|
4598
4596
|
}
|
|
4599
|
-
|
|
4597
|
+
_loop_19 = function (pageField) {
|
|
4600
4598
|
var fieldName, fieldData, field, searchQuery, result, _a, 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;
|
|
4601
4599
|
return __generator(this, function (_d) {
|
|
4602
4600
|
switch (_d.label) {
|
|
@@ -4982,7 +4980,7 @@ function ValidateUserInput(options) {
|
|
|
4982
4980
|
case 1:
|
|
4983
4981
|
if (!(_a < pageFields_1.length)) return [3 /*break*/, 4];
|
|
4984
4982
|
pageField = pageFields_1[_a];
|
|
4985
|
-
return [5 /*yield**/,
|
|
4983
|
+
return [5 /*yield**/, _loop_19(pageField)];
|
|
4986
4984
|
case 2:
|
|
4987
4985
|
state_2 = _b.sent();
|
|
4988
4986
|
if (state_2 === "break")
|