@optimiser/common 1.0.309 → 1.0.310

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.
Files changed (2) hide show
  1. package/dist/lib/utility.js +99 -90
  2. package/package.json +1 -1
@@ -1863,88 +1863,97 @@ function BuildGridFieldProjection(project, field, group) {
1863
1863
  var searchConcatArry = [];
1864
1864
  switch (field.Schema.UIDataType) {
1865
1865
  // below code was added by Shahzaib on 05/09/2022
1866
- case "lookup":
1867
- case "multilookup":
1868
- case "dropdown":
1869
- case "multiselect":
1870
- alias = fldName + constants_1.default.LookupAlias;
1871
- project[fldName] = 1;
1872
- project[alias] = 1;
1873
- project[searchAlias] = 1;
1874
- break;
1875
- // Below code was commented by Shahzaib on 05/09/2022, searchAlias was added instead of it.
1876
1866
  // case "lookup":
1877
- // alias = fldName + constants.LookupAlias;
1878
- // project[fldName] = 1;
1879
- // project[alias] = 1;
1880
- // for (let i = 0; i < field.Schema.LookupFields.length; i++) {
1881
- // if (field.Schema.ExcludeLookupFieldsOnSearch && field.Schema.ExcludeLookupFieldsOnSearch.filter((x: AnyObjectInterface) => x == field.Schema.LookupFields[i]).length != 0) {
1882
- // continue;
1883
- // }
1884
- // // searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], ""] });
1885
- // // added by Shahzaib, make int to string and concat
1886
- // searchConcatArry.push({ "$ifNull": [{$toString : '$' + alias + '.' + field.Schema.LookupFields[i]}, ""] });
1887
- // if (i < field.Schema.LookupFields.length - 1) {
1888
- // searchConcatArry.push(" ");
1889
- // }
1890
- // };
1891
- // project[fldName + '_SearchValue'] = { $concat: searchConcatArry };
1892
- // break;
1893
1867
  // case "multilookup":
1894
- // alias = fldName + constants.LookupAlias;
1895
- // project[fldName] = 1;
1896
- // project[alias] = 1;
1897
- // for (let i = 0; i < field.Schema.LookupFields.length; i++) {
1898
- // searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], [" "]] });
1899
- // if (i < field.Schema.LookupFields.length - 1) {
1900
- // searchConcatArry.push([" "]);
1901
- // }
1902
- // };
1903
- // //project[fldName + '_SearchValue'] = { $concatArrays: searchConcatArry };
1904
- // project[fldName + '_SearchValue'] = {
1905
- // $reduce: {
1906
- // input: { $concatArrays: searchConcatArry },
1907
- // initialValue: "",
1908
- // //in: { $concat: ["$$value", "$$this"] } // Commented by and below line was added by Shahzaib, make int to string
1909
- // in: { $concat: ["$$value", { $toString : "$$this" }] }
1910
- // }
1911
- // };
1912
- // break;
1913
1868
  // case "dropdown":
1914
- // alias = fldName + constants.LookupAlias;
1915
- // project[fldName] = 1;
1916
- // project[alias] = 1;
1917
- // if (field.Schema.LookupObject) {
1918
- // for (let i = 0; i < field.Schema.LookupFields.length; i++) {
1919
- // //searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], ""] });
1920
- // // added by Mohan, make int to string and concat
1921
- // searchConcatArry.push({ "$ifNull": [{$toString : '$' + alias + '.' + field.Schema.LookupFields[i]}, ""] });
1922
- // if (i < field.Schema.LookupFields.length - 1) {
1923
- // searchConcatArry.push(" ");
1924
- // }
1925
- // };
1926
- // project[fldName + '_SearchValue'] = { $concat: searchConcatArry };
1927
- // } else {
1928
- // project[fldName + '_SearchValue'] = '$' + alias + '.Value';
1929
- // }
1930
- // break;
1931
1869
  // case "multiselect":
1932
1870
  // alias = fldName + constants.LookupAlias;
1933
1871
  // project[fldName] = 1;
1934
1872
  // project[alias] = 1;
1935
- // if (field.Schema.LookupObject) {
1936
- // for (let i = 0; i < field.Schema.LookupFields.length; i++) {
1937
- // searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], [" "] ] });
1938
- // if (i < field.Schema.LookupFields.length - 1) {
1939
- // searchConcatArry.push([" "]);
1940
- // }
1941
- // };
1942
- // project[fldName + '_SearchValue'] = { $concatArrays: searchConcatArry };
1943
- // } else {
1944
- // searchConcatArry.push('$' + alias + '.Value');
1945
- // project[fldName + '_SearchValue'] = { $concatArrays: searchConcatArry };
1946
- // }
1873
+ // project[searchAlias] = 1;
1947
1874
  // break;
1875
+ // Below code was commented by Shahzaib on 05/09/2022, searchAlias was added instead of it.
1876
+ case "lookup":
1877
+ alias = fldName + constants_1.default.LookupAlias;
1878
+ project[fldName] = 1;
1879
+ project[alias] = 1;
1880
+ var _loop_13 = function (i) {
1881
+ if (field.Schema.ExcludeLookupFieldsOnSearch && field.Schema.ExcludeLookupFieldsOnSearch.filter(function (x) { return x == field.Schema.LookupFields[i]; }).length != 0) {
1882
+ return "continue";
1883
+ }
1884
+ // searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], ""] });
1885
+ // added by Shahzaib, make int to string and concat
1886
+ searchConcatArry.push({ "$ifNull": [{ $toString: '$' + alias + '.' + field.Schema.LookupFields[i] }, ""] });
1887
+ if (i < field.Schema.LookupFields.length - 1) {
1888
+ searchConcatArry.push(" ");
1889
+ }
1890
+ };
1891
+ for (var i = 0; i < field.Schema.LookupFields.length; i++) {
1892
+ _loop_13(i);
1893
+ }
1894
+ ;
1895
+ project[fldName + '_SearchValue'] = { $concat: searchConcatArry };
1896
+ break;
1897
+ case "multilookup":
1898
+ alias = fldName + constants_1.default.LookupAlias;
1899
+ project[fldName] = 1;
1900
+ project[alias] = 1;
1901
+ for (var i = 0; i < field.Schema.LookupFields.length; i++) {
1902
+ searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], [" "]] });
1903
+ if (i < field.Schema.LookupFields.length - 1) {
1904
+ searchConcatArry.push([" "]);
1905
+ }
1906
+ }
1907
+ ;
1908
+ //project[fldName + '_SearchValue'] = { $concatArrays: searchConcatArry };
1909
+ project[fldName + '_SearchValue'] = {
1910
+ $reduce: {
1911
+ input: { $concatArrays: searchConcatArry },
1912
+ initialValue: "",
1913
+ //in: { $concat: ["$$value", "$$this"] } // Commented by and below line was added by Shahzaib, make int to string
1914
+ in: { $concat: ["$$value", { $toString: "$$this" }] }
1915
+ }
1916
+ };
1917
+ break;
1918
+ case "dropdown":
1919
+ alias = fldName + constants_1.default.LookupAlias;
1920
+ project[fldName] = 1;
1921
+ project[alias] = 1;
1922
+ if (field.Schema.LookupObject) {
1923
+ for (var i = 0; i < field.Schema.LookupFields.length; i++) {
1924
+ //searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], ""] });
1925
+ // added by Mohan, make int to string and concat
1926
+ searchConcatArry.push({ "$ifNull": [{ $toString: '$' + alias + '.' + field.Schema.LookupFields[i] }, ""] });
1927
+ if (i < field.Schema.LookupFields.length - 1) {
1928
+ searchConcatArry.push(" ");
1929
+ }
1930
+ }
1931
+ ;
1932
+ project[fldName + '_SearchValue'] = { $concat: searchConcatArry };
1933
+ }
1934
+ else {
1935
+ project[fldName + '_SearchValue'] = '$' + alias + '.Value';
1936
+ }
1937
+ break;
1938
+ case "multiselect":
1939
+ alias = fldName + constants_1.default.LookupAlias;
1940
+ project[fldName] = 1;
1941
+ project[alias] = 1;
1942
+ if (field.Schema.LookupObject) {
1943
+ for (var i = 0; i < field.Schema.LookupFields.length; i++) {
1944
+ searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], [" "]] });
1945
+ if (i < field.Schema.LookupFields.length - 1) {
1946
+ searchConcatArry.push([" "]);
1947
+ }
1948
+ }
1949
+ ;
1950
+ project[fldName + '_SearchValue'] = { $concatArrays: searchConcatArry };
1951
+ }
1952
+ else {
1953
+ searchConcatArry.push('$' + alias + '.Value');
1954
+ project[fldName + '_SearchValue'] = { $concatArrays: searchConcatArry };
1955
+ }
1956
+ break;
1948
1957
  case "file":
1949
1958
  case "image":
1950
1959
  alias = fldName + constants_1.default.LookupAlias;
@@ -2129,7 +2138,7 @@ function FilterConditions(condition, match, fields) {
2129
2138
  match.$or = new Array();
2130
2139
  sets = match.$or;
2131
2140
  }
2132
- var _loop_13 = function (i) {
2141
+ var _loop_14 = function (i) {
2133
2142
  var _a, _b, _c;
2134
2143
  var obj = condition.Filters[i];
2135
2144
  if (obj.Type == "Child") {
@@ -2313,7 +2322,7 @@ function FilterConditions(condition, match, fields) {
2313
2322
  }
2314
2323
  };
2315
2324
  for (var i = 0; i < condition.Filters.length; i++) {
2316
- _loop_13(i);
2325
+ _loop_14(i);
2317
2326
  }
2318
2327
  }
2319
2328
  }
@@ -2321,7 +2330,7 @@ exports.FilterConditions = FilterConditions;
2321
2330
  function GirdHeaderFilters(filters, fields) {
2322
2331
  try {
2323
2332
  var sets = [];
2324
- var _loop_14 = function (i) {
2333
+ var _loop_15 = function (i) {
2325
2334
  var obj = filters[i];
2326
2335
  var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
2327
2336
  if (field) {
@@ -2374,7 +2383,7 @@ function GirdHeaderFilters(filters, fields) {
2374
2383
  }
2375
2384
  };
2376
2385
  for (var i = 0; i < filters.length; i++) {
2377
- _loop_14(i);
2386
+ _loop_15(i);
2378
2387
  }
2379
2388
  return { '$and': sets };
2380
2389
  }
@@ -2386,7 +2395,7 @@ exports.GirdHeaderFilters = GirdHeaderFilters;
2386
2395
  function FieldsGridHeaderFilters(filters, fields) {
2387
2396
  var sets = [];
2388
2397
  var lookupFieldsSets = [];
2389
- var _loop_15 = function (i) {
2398
+ var _loop_16 = function (i) {
2390
2399
  var _a;
2391
2400
  var obj = filters[i];
2392
2401
  var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
@@ -2430,7 +2439,7 @@ function FieldsGridHeaderFilters(filters, fields) {
2430
2439
  }
2431
2440
  };
2432
2441
  for (var i = 0; i < filters.length; i++) {
2433
- _loop_15(i);
2442
+ _loop_16(i);
2434
2443
  }
2435
2444
  return { '$and': sets, 'lookupConditions': lookupFieldsSets };
2436
2445
  }
@@ -2468,7 +2477,7 @@ function AddLog(req, objectName, logAction, objLogProp, db, next) {
2468
2477
  exports.AddLog = AddLog;
2469
2478
  function CheckFilterFieldsProjection(condition, fields, pageData, project) {
2470
2479
  if (condition != undefined && condition.Filters.length > 0) {
2471
- var _loop_16 = function (i) {
2480
+ var _loop_17 = function (i) {
2472
2481
  var objFilter = condition.Filters[i];
2473
2482
  if (objFilter.Type == "Child") {
2474
2483
  CheckFilterFieldsProjection(objFilter, fields, pageData, project);
@@ -2486,7 +2495,7 @@ function CheckFilterFieldsProjection(condition, fields, pageData, project) {
2486
2495
  }
2487
2496
  };
2488
2497
  for (var i = 0; i < condition.Filters.length; i++) {
2489
- _loop_16(i);
2498
+ _loop_17(i);
2490
2499
  }
2491
2500
  }
2492
2501
  }
@@ -4163,7 +4172,7 @@ exports.GetDayIndex = GetDayIndex;
4163
4172
  function GetUserProfile(msp_d, db, mdb, next) {
4164
4173
  var _a;
4165
4174
  return __awaiter(this, void 0, void 0, function () {
4166
- var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, companylicenceDetail, receptionLicense, moduleList, _loop_17, i, error_4;
4175
+ var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, companylicenceDetail, receptionLicense, moduleList, _loop_18, i, error_4;
4167
4176
  return __generator(this, function (_b) {
4168
4177
  switch (_b.label) {
4169
4178
  case 0:
@@ -4242,14 +4251,14 @@ function GetUserProfile(msp_d, db, mdb, next) {
4242
4251
  moduleList = userProfile_1[0].ModuleList;
4243
4252
  userProfile_1[0].HasControlPanelAccess = [];
4244
4253
  if (userProfile_1[0].Permissions) {
4245
- _loop_17 = function (i) {
4254
+ _loop_18 = function (i) {
4246
4255
  userProfile_1[0].Permissions[i].ModuleData = moduleList.find(function (x) { return x._id == userProfile_1[0].Permissions[i].ModuleID; });
4247
4256
  if ((_a = userProfile_1[0].Permissions[i].Operations) === null || _a === void 0 ? void 0 : _a.includes("Control Panel")) {
4248
4257
  userProfile_1[0].HasControlPanelAccess.push(userProfile_1[0].Permissions[i].ModuleID);
4249
4258
  }
4250
4259
  };
4251
4260
  for (i = 0; i < userProfile_1[0].Permissions.length; i++) {
4252
- _loop_17(i);
4261
+ _loop_18(i);
4253
4262
  }
4254
4263
  }
4255
4264
  if (moduleList.length == 0) {
@@ -4546,7 +4555,7 @@ function IsAnotherObjectField(pageData, fieldName) {
4546
4555
  */
4547
4556
  function ValidateUserInput(options) {
4548
4557
  return __awaiter(this, void 0, void 0, function () {
4549
- var inputFields, pageData, documentID, db, action, objectSchema, objectName, pageFields, schemaFields, inputField, msg, _loop_18, _i, inputField_1, name_1, state_1, _loop_19, isValid, validateResp, _a, pageFields_1, pageField, state_2, countryData, err_3;
4558
+ var inputFields, pageData, documentID, db, action, objectSchema, objectName, pageFields, schemaFields, inputField, msg, _loop_19, _i, inputField_1, name_1, state_1, _loop_20, isValid, validateResp, _a, pageFields_1, pageField, state_2, countryData, err_3;
4550
4559
  return __generator(this, function (_b) {
4551
4560
  switch (_b.label) {
4552
4561
  case 0:
@@ -4567,7 +4576,7 @@ function ValidateUserInput(options) {
4567
4576
  inputField = Object.keys(inputFields);
4568
4577
  msg = '';
4569
4578
  if (inputField && inputField.length) {
4570
- _loop_18 = function (name_1) {
4579
+ _loop_19 = function (name_1) {
4571
4580
  var field = pageFields.find(function (x) { return x.Name == name_1; });
4572
4581
  if (field == undefined && !IsSystemField(objectName, name_1)) {
4573
4582
  msg = name_1 + " is not valid field!";
@@ -4576,12 +4585,12 @@ function ValidateUserInput(options) {
4576
4585
  };
4577
4586
  for (_i = 0, inputField_1 = inputField; _i < inputField_1.length; _i++) {
4578
4587
  name_1 = inputField_1[_i];
4579
- state_1 = _loop_18(name_1);
4588
+ state_1 = _loop_19(name_1);
4580
4589
  if (state_1 === "break")
4581
4590
  break;
4582
4591
  }
4583
4592
  }
4584
- _loop_19 = function (pageField) {
4593
+ _loop_20 = function (pageField) {
4585
4594
  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;
4586
4595
  return __generator(this, function (_d) {
4587
4596
  switch (_d.label) {
@@ -4957,7 +4966,7 @@ function ValidateUserInput(options) {
4957
4966
  case 1:
4958
4967
  if (!(_a < pageFields_1.length)) return [3 /*break*/, 4];
4959
4968
  pageField = pageFields_1[_a];
4960
- return [5 /*yield**/, _loop_19(pageField)];
4969
+ return [5 /*yield**/, _loop_20(pageField)];
4961
4970
  case 2:
4962
4971
  state_2 = _b.sent();
4963
4972
  if (state_2 === "break")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.309",
3
+ "version": "1.0.310",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {