@optimiser/common 1.0.311 → 1.0.313

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 +107 -106
  2. package/package.json +1 -1
@@ -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
- if (field.Schema.LookupObject) {
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,7 +2135,7 @@ function FilterConditions(condition, match, fields) {
2144
2135
  match.$or = new Array();
2145
2136
  sets = match.$or;
2146
2137
  }
2147
- var _loop_14 = function (i) {
2138
+ var _loop_13 = function (i) {
2148
2139
  var _a, _b, _c;
2149
2140
  var obj = condition.Filters[i];
2150
2141
  if (obj.Type == "Child") {
@@ -2201,13 +2192,13 @@ function FilterConditions(condition, match, fields) {
2201
2192
  var operator = obj.Operator;
2202
2193
  var startCompareDate = void 0, endCompareDate = void 0;
2203
2194
  if (operator === "custom") {
2204
- startCompareDate = moment_1.default((_a = obj.Value) === null || _a === void 0 ? void 0 : _a.From, "DD-MMM-YYYY").startOf('day');
2205
- endCompareDate = moment_1.default((_b = obj.Value) === null || _b === void 0 ? void 0 : _b.To, "DD-MMM-YYYY").endOf('day');
2195
+ startCompareDate = moment_1.default((_a = obj.Value) === null || _a === void 0 ? void 0 : _a.From, obj.DateFormat).startOf('day');
2196
+ endCompareDate = moment_1.default((_b = obj.Value) === null || _b === void 0 ? void 0 : _b.To, obj.DateFormat).endOf('day');
2206
2197
  }
2207
2198
  else {
2208
2199
  var _d = helper_1.GetDateRangeFromOperatorValue(operator, obj.FiscalMonth, obj.FiscalFrom), startDate = _d.startDate, endDate = _d.endDate;
2209
- startCompareDate = moment_1.default(startDate, "DD-MMM-YYYY").startOf('day');
2210
- endCompareDate = moment_1.default(endDate, "DD-MMM-YYYY").endOf('day');
2200
+ startCompareDate = moment_1.default(startDate, obj.DateFormat).startOf('day');
2201
+ endCompareDate = moment_1.default(endDate, obj.DateFormat).endOf('day');
2211
2202
  }
2212
2203
  matchValue = { '$gte': new Date(moment_1.default(startCompareDate).toISOString()), '$lte': new Date(moment_1.default(endCompareDate).toISOString()) };
2213
2204
  }
@@ -2328,7 +2319,7 @@ function FilterConditions(condition, match, fields) {
2328
2319
  }
2329
2320
  };
2330
2321
  for (var i = 0; i < condition.Filters.length; i++) {
2331
- _loop_14(i);
2322
+ _loop_13(i);
2332
2323
  }
2333
2324
  }
2334
2325
  }
@@ -2336,7 +2327,7 @@ exports.FilterConditions = FilterConditions;
2336
2327
  function GirdHeaderFilters(filters, fields) {
2337
2328
  try {
2338
2329
  var sets = [];
2339
- var _loop_15 = function (i) {
2330
+ var _loop_14 = function (i) {
2340
2331
  var obj = filters[i];
2341
2332
  var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
2342
2333
  if (field) {
@@ -2389,7 +2380,7 @@ function GirdHeaderFilters(filters, fields) {
2389
2380
  }
2390
2381
  };
2391
2382
  for (var i = 0; i < filters.length; i++) {
2392
- _loop_15(i);
2383
+ _loop_14(i);
2393
2384
  }
2394
2385
  return { '$and': sets };
2395
2386
  }
@@ -2401,7 +2392,7 @@ exports.GirdHeaderFilters = GirdHeaderFilters;
2401
2392
  function FieldsGridHeaderFilters(filters, fields) {
2402
2393
  var sets = [];
2403
2394
  var lookupFieldsSets = [];
2404
- var _loop_16 = function (i) {
2395
+ var _loop_15 = function (i) {
2405
2396
  var _a;
2406
2397
  var obj = filters[i];
2407
2398
  var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
@@ -2445,7 +2436,7 @@ function FieldsGridHeaderFilters(filters, fields) {
2445
2436
  }
2446
2437
  };
2447
2438
  for (var i = 0; i < filters.length; i++) {
2448
- _loop_16(i);
2439
+ _loop_15(i);
2449
2440
  }
2450
2441
  return { '$and': sets, 'lookupConditions': lookupFieldsSets };
2451
2442
  }
@@ -2483,7 +2474,7 @@ function AddLog(req, objectName, logAction, objLogProp, db, next) {
2483
2474
  exports.AddLog = AddLog;
2484
2475
  function CheckFilterFieldsProjection(condition, fields, pageData, project) {
2485
2476
  if (condition != undefined && condition.Filters.length > 0) {
2486
- var _loop_17 = function (i) {
2477
+ var _loop_16 = function (i) {
2487
2478
  var objFilter = condition.Filters[i];
2488
2479
  if (objFilter.Type == "Child") {
2489
2480
  CheckFilterFieldsProjection(objFilter, fields, pageData, project);
@@ -2501,7 +2492,7 @@ function CheckFilterFieldsProjection(condition, fields, pageData, project) {
2501
2492
  }
2502
2493
  };
2503
2494
  for (var i = 0; i < condition.Filters.length; i++) {
2504
- _loop_17(i);
2495
+ _loop_16(i);
2505
2496
  }
2506
2497
  }
2507
2498
  }
@@ -4178,7 +4169,7 @@ exports.GetDayIndex = GetDayIndex;
4178
4169
  function GetUserProfile(msp_d, db, mdb, next) {
4179
4170
  var _a;
4180
4171
  return __awaiter(this, void 0, void 0, function () {
4181
- var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, companylicenceDetail, receptionLicense, moduleList, _loop_18, i, error_4;
4172
+ var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, companylicenceDetail, receptionLicense, moduleList, _loop_17, i, error_4;
4182
4173
  return __generator(this, function (_b) {
4183
4174
  switch (_b.label) {
4184
4175
  case 0:
@@ -4257,14 +4248,14 @@ function GetUserProfile(msp_d, db, mdb, next) {
4257
4248
  moduleList = userProfile_1[0].ModuleList;
4258
4249
  userProfile_1[0].HasControlPanelAccess = [];
4259
4250
  if (userProfile_1[0].Permissions) {
4260
- _loop_18 = function (i) {
4251
+ _loop_17 = function (i) {
4261
4252
  userProfile_1[0].Permissions[i].ModuleData = moduleList.find(function (x) { return x._id == userProfile_1[0].Permissions[i].ModuleID; });
4262
4253
  if ((_a = userProfile_1[0].Permissions[i].Operations) === null || _a === void 0 ? void 0 : _a.includes("Control Panel")) {
4263
4254
  userProfile_1[0].HasControlPanelAccess.push(userProfile_1[0].Permissions[i].ModuleID);
4264
4255
  }
4265
4256
  };
4266
4257
  for (i = 0; i < userProfile_1[0].Permissions.length; i++) {
4267
- _loop_18(i);
4258
+ _loop_17(i);
4268
4259
  }
4269
4260
  }
4270
4261
  if (moduleList.length == 0) {
@@ -4561,7 +4552,7 @@ function IsAnotherObjectField(pageData, fieldName) {
4561
4552
  */
4562
4553
  function ValidateUserInput(options) {
4563
4554
  return __awaiter(this, void 0, void 0, function () {
4564
- 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;
4555
+ 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
4556
  return __generator(this, function (_b) {
4566
4557
  switch (_b.label) {
4567
4558
  case 0:
@@ -4582,7 +4573,7 @@ function ValidateUserInput(options) {
4582
4573
  inputField = Object.keys(inputFields);
4583
4574
  msg = '';
4584
4575
  if (inputField && inputField.length) {
4585
- _loop_19 = function (name_1) {
4576
+ _loop_18 = function (name_1) {
4586
4577
  var field = pageFields.find(function (x) { return x.Name == name_1; });
4587
4578
  if (field == undefined && !IsSystemField(objectName, name_1)) {
4588
4579
  msg = name_1 + " is not valid field!";
@@ -4591,12 +4582,12 @@ function ValidateUserInput(options) {
4591
4582
  };
4592
4583
  for (_i = 0, inputField_1 = inputField; _i < inputField_1.length; _i++) {
4593
4584
  name_1 = inputField_1[_i];
4594
- state_1 = _loop_19(name_1);
4585
+ state_1 = _loop_18(name_1);
4595
4586
  if (state_1 === "break")
4596
4587
  break;
4597
4588
  }
4598
4589
  }
4599
- _loop_20 = function (pageField) {
4590
+ _loop_19 = function (pageField) {
4600
4591
  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
4592
  return __generator(this, function (_d) {
4602
4593
  switch (_d.label) {
@@ -4698,9 +4689,19 @@ function ValidateUserInput(options) {
4698
4689
  return [3 /*break*/, 53];
4699
4690
  case 5:
4700
4691
  {
4701
- isValid = /^([0-1]?[0-9]|2[0-4]):([0-5][0-9])(:[0-5][0-9])?$/.test(fieldData);
4702
- if (!isValid) {
4703
- msg = 'Invalid time for ' + field.DisplayName + '!';
4692
+ if (field.ShowNextDayHoursUpto) {
4693
+ //When we are showing hours of Next days in Time Control
4694
+ //Then we are validating only length of time and it must contain collon in it.
4695
+ isValid = /^([0-3]?[0-9]|4[0-7]):([0-5][0-9])(:[0-5][0-9])?$/.test(fieldData);
4696
+ if (!isValid) {
4697
+ msg = 'Invalid time for ' + field.DisplayName + '!';
4698
+ }
4699
+ }
4700
+ else {
4701
+ isValid = /^([0-1]?[0-9]|2[0-4]):([0-5][0-9])(:[0-5][0-9])?$/.test(fieldData);
4702
+ if (!isValid) {
4703
+ msg = 'Invalid time for ' + field.DisplayName + '!';
4704
+ }
4704
4705
  }
4705
4706
  }
4706
4707
  return [3 /*break*/, 53];
@@ -4972,7 +4973,7 @@ function ValidateUserInput(options) {
4972
4973
  case 1:
4973
4974
  if (!(_a < pageFields_1.length)) return [3 /*break*/, 4];
4974
4975
  pageField = pageFields_1[_a];
4975
- return [5 /*yield**/, _loop_20(pageField)];
4976
+ return [5 /*yield**/, _loop_19(pageField)];
4976
4977
  case 2:
4977
4978
  state_2 = _b.sent();
4978
4979
  if (state_2 === "break")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.311",
3
+ "version": "1.0.313",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {