@optimiser/common 1.0.268 → 1.0.271

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.
@@ -38,7 +38,7 @@ declare function BuildLookupFieldProjection(field: AnyObjectInterface, group: An
38
38
  declare function FilterConditions(condition: AnyObjectInterface, match: AnyObjectInterface, fields: AnyObjectInterface): void;
39
39
  declare function GirdHeaderFilters(filters: AnyObjectInterface, fields: AnyObjectInterface): {
40
40
  $and: AnyObjectInterface[];
41
- };
41
+ } | undefined;
42
42
  declare function FieldsGridHeaderFilters(filters: AnyObjectInterface, fields: AnyObjectInterface): {
43
43
  $and: AnyObjectInterface[];
44
44
  lookupConditions: {
@@ -564,9 +564,7 @@ function SyncChildObjectData(pageData, objectID, db) {
564
564
  _a.sent();
565
565
  SyncFieldInSameCollectionByObjectID(group.ChildObject, childID, db);
566
566
  _a.label = 5;
567
- case 5:
568
- SyncFieldInOtherCollection(syncFields, db);
569
- return [3 /*break*/, 14];
567
+ case 5: return [3 /*break*/, 14];
570
568
  case 6:
571
569
  childFieldsObj = {};
572
570
  _loop_6 = function (i_4) {
@@ -662,15 +660,15 @@ function SyncParentObjectData(pageData, objectID, db) {
662
660
  switch (_a.label) {
663
661
  case 0:
664
662
  objectName = pageData.ObjectName;
665
- if (!pageData.ParentObject) return [3 /*break*/, 5];
663
+ if (!pageData.ParentObject) return [3 /*break*/, 4];
666
664
  parent_1 = pageData.ParentObject;
667
665
  return [4 /*yield*/, db.collection(objectName).findOne({ '_id': objectID })];
668
666
  case 1:
669
667
  data = _a.sent();
670
- if (!(data && data._id)) return [3 /*break*/, 5];
671
- if (!(parent_1 && data.IsDefaultRecord)) return [3 /*break*/, 5];
668
+ if (!(data && data._id)) return [3 /*break*/, 4];
669
+ if (!(parent_1 && data.IsDefaultRecord)) return [3 /*break*/, 4];
672
670
  parentID = data[parent_1.ObjectField];
673
- if (!parentID) return [3 /*break*/, 5];
671
+ if (!parentID) return [3 /*break*/, 4];
674
672
  return [4 /*yield*/, db.collection(parent_1.ObjectName).findOne({ '_id': parentID })];
675
673
  case 2:
676
674
  parentData = _a.sent();
@@ -705,10 +703,7 @@ function SyncParentObjectData(pageData, objectID, db) {
705
703
  case 3:
706
704
  _a.sent();
707
705
  _a.label = 4;
708
- case 4:
709
- SyncFieldInOtherCollection(syncFields, db);
710
- _a.label = 5;
711
- case 5: return [2 /*return*/];
706
+ case 4: return [2 /*return*/];
712
707
  }
713
708
  });
714
709
  });
@@ -1806,7 +1801,9 @@ function BuildGridFieldProjection(project, field, group) {
1806
1801
  project[alias] = 1;
1807
1802
  if (field.Schema.LookupObject) {
1808
1803
  for (var i = 0; i < field.Schema.LookupFields.length; i++) {
1809
- searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], ""] });
1804
+ //searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], ""] });
1805
+ // added by Mohan, make int to string and concat
1806
+ searchConcatArry.push({ "$ifNull": [{ $toString: '$' + alias + '.' + field.Schema.LookupFields[i] }, ""] });
1810
1807
  if (i < field.Schema.LookupFields.length - 1) {
1811
1808
  searchConcatArry.push(" ");
1812
1809
  }
@@ -2179,60 +2176,65 @@ function FilterConditions(condition, match, fields) {
2179
2176
  }
2180
2177
  exports.FilterConditions = FilterConditions;
2181
2178
  function GirdHeaderFilters(filters, fields) {
2182
- var sets = [];
2183
- var _loop_14 = function (i) {
2184
- var obj = filters[i];
2185
- var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
2186
- if (field) {
2187
- var matchValue = null;
2188
- var fldName = field.UniqueID;
2189
- //added by nirbhay on 25.04.22 to add dropdown in any type of fields for filter
2190
- if (field.Schema.SearchType == 'dropdown') {
2191
- matchValue = { '$eq': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2192
- }
2193
- else if (["lookup", "multilookup"].includes(field.Schema.UIDataType)) {
2194
- fldName += '_SearchValue';
2195
- matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
2196
- }
2197
- else if (["dropdown", "multiselect"].includes(field.Schema.UIDataType)) {
2198
- if (field.Schema.LookupObject) {
2199
- matchValue = { '$in': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2179
+ try {
2180
+ var sets = [];
2181
+ var _loop_14 = function (i) {
2182
+ var obj = filters[i];
2183
+ var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
2184
+ if (field) {
2185
+ var matchValue = null;
2186
+ var fldName = field.UniqueID;
2187
+ //added by nirbhay on 25.04.22 to add dropdown in any type of fields for filter
2188
+ if (field.Schema.SearchType == 'dropdown') {
2189
+ matchValue = { '$eq': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2200
2190
  }
2201
- else {
2202
- matchValue = { '$in': obj.Value };
2191
+ else if (["lookup", "multilookup"].includes(field.Schema.UIDataType)) {
2192
+ fldName += '_SearchValue';
2193
+ matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
2203
2194
  }
2204
- }
2205
- else if (["date", "datetime"].includes(field.Schema.UIDataType))
2206
- matchValue = { '$gte': moment_1.default(obj.Value.From).startOf('day').toDate(), '$lte': moment_1.default(obj.Value.To).endOf('day').toDate() };
2207
- // else if (field.Schema.UIDataType == 'time')
2208
- // matchValue = (obj.Value == 'true');
2209
- else if (field.Schema.UIDataType == 'checkbox') {
2210
- if (obj.Value == 'true')
2211
- matchValue = true;
2195
+ else if (["dropdown", "multiselect"].includes(field.Schema.UIDataType)) {
2196
+ if (field.Schema.LookupObject) {
2197
+ matchValue = { '$in': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2198
+ }
2199
+ else {
2200
+ matchValue = { '$in': obj.Value };
2201
+ }
2202
+ }
2203
+ else if (["date", "datetime"].includes(field.Schema.UIDataType))
2204
+ matchValue = { '$gte': moment_1.default(obj.Value.From).startOf('day').toDate(), '$lte': moment_1.default(obj.Value.To).endOf('day').toDate() };
2205
+ // else if (field.Schema.UIDataType == 'time')
2206
+ // matchValue = (obj.Value == 'true');
2207
+ else if (field.Schema.UIDataType == 'checkbox') {
2208
+ if (obj.Value == 'true')
2209
+ matchValue = true;
2210
+ else
2211
+ matchValue = { $ne: true };
2212
+ }
2213
+ else if (field.Schema.UIDataType == 'int')
2214
+ matchValue = { '$eq': parseInt(obj.Value) };
2215
+ else if (["decimal", "percent"].includes(field.Schema.UIDataType))
2216
+ matchValue = { '$eq': mongodb_1.Decimal128.fromString(obj.Value) };
2217
+ else if (field.Schema.UIDataType == 'objectid')
2218
+ matchValue = { '$eq': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2219
+ else if (field.Schema.IsEqualAndCaseInsensitiveSearch === true)
2220
+ matchValue = new RegExp('^' + obj.Value + '$', 'i');
2221
+ else if (field.Schema.IsEqualSearch === true)
2222
+ matchValue = { '$eq': obj.Value };
2212
2223
  else
2213
- matchValue = { $ne: true };
2224
+ matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
2225
+ var fieldMatch = {};
2226
+ fieldMatch[fldName] = matchValue;
2227
+ sets.push(fieldMatch);
2214
2228
  }
2215
- else if (field.Schema.UIDataType == 'int')
2216
- matchValue = { '$eq': parseInt(obj.Value) };
2217
- else if (["decimal", "percent"].includes(field.Schema.UIDataType))
2218
- matchValue = { '$eq': mongodb_1.Decimal128.fromString(obj.Value) };
2219
- else if (field.Schema.UIDataType == 'objectid')
2220
- matchValue = { '$eq': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2221
- else if (field.Schema.IsEqualAndCaseInsensitiveSearch === true)
2222
- matchValue = new RegExp('^' + obj.Value + '$', 'i');
2223
- else if (field.Schema.IsEqualSearch === true)
2224
- matchValue = { '$eq': obj.Value };
2225
- else
2226
- matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
2227
- var fieldMatch = {};
2228
- fieldMatch[fldName] = matchValue;
2229
- sets.push(fieldMatch);
2229
+ };
2230
+ for (var i = 0; i < filters.length; i++) {
2231
+ _loop_14(i);
2230
2232
  }
2231
- };
2232
- for (var i = 0; i < filters.length; i++) {
2233
- _loop_14(i);
2233
+ return { '$and': sets };
2234
+ }
2235
+ catch (error) {
2236
+ console.error("Internal Error in GirdHeaderFilters : " + error);
2234
2237
  }
2235
- return { '$and': sets };
2236
2238
  }
2237
2239
  exports.GirdHeaderFilters = GirdHeaderFilters;
2238
2240
  function FieldsGridHeaderFilters(filters, fields) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.268",
3
+ "version": "1.0.271",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {