@optimiser/common 1.0.286 → 1.0.287

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 +55 -50
  2. package/package.json +1 -1
@@ -1826,51 +1826,56 @@ function BuildGridFieldProjection(project, field, group) {
1826
1826
  var searchConcatArry = [];
1827
1827
  switch (field.Schema.UIDataType) {
1828
1828
  // below code was added by Shahzaib on 05/09/2022
1829
- case "lookup":
1830
- case "multilookup":
1831
- alias = fldName + constants_1.default.LookupAlias;
1832
- project[fldName] = 1;
1833
- project[alias] = 1;
1834
- project[searchAlias] = 1;
1835
- break;
1836
- // Below code was commented by Shahzaib on 05/09/2022, searchAlias was added instead of it.
1837
1829
  // case "lookup":
1838
- // alias = fldName + constants.LookupAlias;
1839
- // project[fldName] = 1;
1840
- // project[alias] = 1;
1841
- // for (let i = 0; i < field.Schema.LookupFields.length; i++) {
1842
- // if (field.Schema.ExcludeLookupFieldsOnSearch && field.Schema.ExcludeLookupFieldsOnSearch.filter((x: AnyObjectInterface) => x == field.Schema.LookupFields[i]).length != 0) {
1843
- // continue;
1844
- // }
1845
- // // searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], ""] });
1846
- // // added by Shahzaib, make int to string and concat
1847
- // searchConcatArry.push({ "$ifNull": [{$toString : '$' + alias + '.' + field.Schema.LookupFields[i]}, ""] });
1848
- // if (i < field.Schema.LookupFields.length - 1) {
1849
- // searchConcatArry.push(" ");
1850
- // }
1851
- // };
1852
- // project[fldName + '_SearchValue'] = { $concat: searchConcatArry };
1853
- // break;
1854
1830
  // case "multilookup":
1855
1831
  // alias = fldName + constants.LookupAlias;
1856
1832
  // project[fldName] = 1;
1857
1833
  // project[alias] = 1;
1858
- // for (let i = 0; i < field.Schema.LookupFields.length; i++) {
1859
- // searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], [" "]] });
1860
- // if (i < field.Schema.LookupFields.length - 1) {
1861
- // searchConcatArry.push([" "]);
1862
- // }
1863
- // };
1864
- // //project[fldName + '_SearchValue'] = { $concatArrays: searchConcatArry };
1865
- // project[fldName + '_SearchValue'] = {
1866
- // $reduce: {
1867
- // input: { $concatArrays: searchConcatArry },
1868
- // initialValue: "",
1869
- // //in: { $concat: ["$$value", "$$this"] } // Commented by and below line was added by Shahzaib, make int to string
1870
- // in: { $concat: ["$$value", { $toString : "$$this" }] }
1871
- // }
1872
- // };
1834
+ // project[searchAlias] = 1;
1873
1835
  // break;
1836
+ // Below code was commented by Shahzaib on 05/09/2022, searchAlias was added instead of it.
1837
+ case "lookup":
1838
+ alias = fldName + constants_1.default.LookupAlias;
1839
+ project[fldName] = 1;
1840
+ project[alias] = 1;
1841
+ var _loop_13 = function (i) {
1842
+ if (field.Schema.ExcludeLookupFieldsOnSearch && field.Schema.ExcludeLookupFieldsOnSearch.filter(function (x) { return x == field.Schema.LookupFields[i]; }).length != 0) {
1843
+ return "continue";
1844
+ }
1845
+ // searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], ""] });
1846
+ // added by Shahzaib, make int to string and concat
1847
+ searchConcatArry.push({ "$ifNull": [{ $toString: '$' + alias + '.' + field.Schema.LookupFields[i] }, ""] });
1848
+ if (i < field.Schema.LookupFields.length - 1) {
1849
+ searchConcatArry.push(" ");
1850
+ }
1851
+ };
1852
+ for (var i = 0; i < field.Schema.LookupFields.length; i++) {
1853
+ _loop_13(i);
1854
+ }
1855
+ ;
1856
+ project[fldName + '_SearchValue'] = { $concat: searchConcatArry };
1857
+ break;
1858
+ case "multilookup":
1859
+ alias = fldName + constants_1.default.LookupAlias;
1860
+ project[fldName] = 1;
1861
+ project[alias] = 1;
1862
+ for (var i = 0; i < field.Schema.LookupFields.length; i++) {
1863
+ searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], [" "]] });
1864
+ if (i < field.Schema.LookupFields.length - 1) {
1865
+ searchConcatArry.push([" "]);
1866
+ }
1867
+ }
1868
+ ;
1869
+ //project[fldName + '_SearchValue'] = { $concatArrays: searchConcatArry };
1870
+ project[fldName + '_SearchValue'] = {
1871
+ $reduce: {
1872
+ input: { $concatArrays: searchConcatArry },
1873
+ initialValue: "",
1874
+ //in: { $concat: ["$$value", "$$this"] } // Commented by and below line was added by Shahzaib, make int to string
1875
+ in: { $concat: ["$$value", { $toString: "$$this" }] }
1876
+ }
1877
+ };
1878
+ break;
1874
1879
  case "dropdown":
1875
1880
  alias = fldName + constants_1.default.LookupAlias;
1876
1881
  project[fldName] = 1;
@@ -2094,7 +2099,7 @@ function FilterConditions(condition, match, fields) {
2094
2099
  match.$or = new Array();
2095
2100
  sets = match.$or;
2096
2101
  }
2097
- var _loop_13 = function (i) {
2102
+ var _loop_14 = function (i) {
2098
2103
  var obj = condition.Filters[i];
2099
2104
  if (obj.Type == "Child") {
2100
2105
  var childMatch = {};
@@ -2263,7 +2268,7 @@ function FilterConditions(condition, match, fields) {
2263
2268
  }
2264
2269
  };
2265
2270
  for (var i = 0; i < condition.Filters.length; i++) {
2266
- _loop_13(i);
2271
+ _loop_14(i);
2267
2272
  }
2268
2273
  }
2269
2274
  }
@@ -2271,7 +2276,7 @@ exports.FilterConditions = FilterConditions;
2271
2276
  function GirdHeaderFilters(filters, fields) {
2272
2277
  try {
2273
2278
  var sets = [];
2274
- var _loop_14 = function (i) {
2279
+ var _loop_15 = function (i) {
2275
2280
  var obj = filters[i];
2276
2281
  var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
2277
2282
  if (field) {
@@ -2324,7 +2329,7 @@ function GirdHeaderFilters(filters, fields) {
2324
2329
  }
2325
2330
  };
2326
2331
  for (var i = 0; i < filters.length; i++) {
2327
- _loop_14(i);
2332
+ _loop_15(i);
2328
2333
  }
2329
2334
  return { '$and': sets };
2330
2335
  }
@@ -2336,7 +2341,7 @@ exports.GirdHeaderFilters = GirdHeaderFilters;
2336
2341
  function FieldsGridHeaderFilters(filters, fields) {
2337
2342
  var sets = [];
2338
2343
  var lookupFieldsSets = [];
2339
- var _loop_15 = function (i) {
2344
+ var _loop_16 = function (i) {
2340
2345
  var _a;
2341
2346
  var obj = filters[i];
2342
2347
  var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
@@ -2380,7 +2385,7 @@ function FieldsGridHeaderFilters(filters, fields) {
2380
2385
  }
2381
2386
  };
2382
2387
  for (var i = 0; i < filters.length; i++) {
2383
- _loop_15(i);
2388
+ _loop_16(i);
2384
2389
  }
2385
2390
  return { '$and': sets, 'lookupConditions': lookupFieldsSets };
2386
2391
  }
@@ -2418,7 +2423,7 @@ function AddLog(req, objectName, logAction, objLogProp, db, next) {
2418
2423
  exports.AddLog = AddLog;
2419
2424
  function CheckFilterFieldsProjection(condition, fields, pageData, project) {
2420
2425
  if (condition != undefined && condition.Filters.length > 0) {
2421
- var _loop_16 = function (i) {
2426
+ var _loop_17 = function (i) {
2422
2427
  var objFilter = condition.Filters[i];
2423
2428
  if (objFilter.Type == "Child") {
2424
2429
  CheckFilterFieldsProjection(objFilter, fields, pageData, project);
@@ -2436,7 +2441,7 @@ function CheckFilterFieldsProjection(condition, fields, pageData, project) {
2436
2441
  }
2437
2442
  };
2438
2443
  for (var i = 0; i < condition.Filters.length; i++) {
2439
- _loop_16(i);
2444
+ _loop_17(i);
2440
2445
  }
2441
2446
  }
2442
2447
  }
@@ -4049,7 +4054,7 @@ exports.GetDayIndex = GetDayIndex;
4049
4054
  function GetUserProfile(msp_d, db, mdb, next) {
4050
4055
  var _a;
4051
4056
  return __awaiter(this, void 0, void 0, function () {
4052
- var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, companylicenceDetail, receptionLicense, moduleList, _loop_17, i, error_4;
4057
+ var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, companylicenceDetail, receptionLicense, moduleList, _loop_18, i, error_4;
4053
4058
  return __generator(this, function (_b) {
4054
4059
  switch (_b.label) {
4055
4060
  case 0:
@@ -4128,14 +4133,14 @@ function GetUserProfile(msp_d, db, mdb, next) {
4128
4133
  moduleList = userProfile_1[0].ModuleList;
4129
4134
  userProfile_1[0].HasControlPanelAccess = [];
4130
4135
  if (userProfile_1[0].Permissions) {
4131
- _loop_17 = function (i) {
4136
+ _loop_18 = function (i) {
4132
4137
  userProfile_1[0].Permissions[i].ModuleData = moduleList.find(function (x) { return x._id == userProfile_1[0].Permissions[i].ModuleID; });
4133
4138
  if ((_a = userProfile_1[0].Permissions[i].Operations) === null || _a === void 0 ? void 0 : _a.includes("Control Panel")) {
4134
4139
  userProfile_1[0].HasControlPanelAccess.push(userProfile_1[0].Permissions[i].ModuleID);
4135
4140
  }
4136
4141
  };
4137
4142
  for (i = 0; i < userProfile_1[0].Permissions.length; i++) {
4138
- _loop_17(i);
4143
+ _loop_18(i);
4139
4144
  }
4140
4145
  }
4141
4146
  if (moduleList.length == 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.286",
3
+ "version": "1.0.287",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {