@optimiser/common 1.0.267 → 1.0.270

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: {
@@ -391,14 +391,15 @@ function GetPageFieldData(pageName, db, mdb, msp_d, next, callback) {
391
391
  Width: 100
392
392
  };
393
393
  pageData.Fields.splice(0, 0, idObject);
394
+ //Code added by Brijesh on 25Apr2022, condition added for objectschema =PromoCodeTransaction and grouped then not condition
394
395
  //By Kashish : To handle System Info Fields in Grid
395
- if (!pageData.Fields.find(function (x) { return x.Name == 'CreatedBy'; }) && !['CompanySessionLogList', 'CompanyTransactionLogsList'].includes(pageData.PageName) && pageData.ObjectName != 'Task' && pageData.ObjectName != 'Session')
396
+ if (!pageData.Fields.find(function (x) { return x.Name == 'CreatedBy'; }) && !['CompanySessionLogList', 'CompanyTransactionLogsList'].includes(pageData.PageName) && ["Session", "PromoCodeTransaction", "Task"].includes(pageData.ObjectName) == false)
396
397
  pageData.Fields.push(createdByObj);
397
- if (!pageData.Fields.find(function (x) { return x.Name == 'CreatedDate'; }) && !['CompanySessionLogList', 'CompanyTransactionLogsList'].includes(pageData.PageName) && pageData.ObjectName != 'Session')
398
+ if (!pageData.Fields.find(function (x) { return x.Name == 'CreatedDate'; }) && !['CompanySessionLogList', 'CompanyTransactionLogsList'].includes(pageData.PageName) && ["Session", "PromoCodeTransaction"].includes(pageData.ObjectName) == false)
398
399
  pageData.Fields.push(createdDateObj);
399
- if (!pageData.Fields.find(function (x) { return x.Name == 'ModifiedBy'; }) && !['CompanySessionLogList', 'CompanyTransactionLogsList'].includes(pageData.PageName) && pageData.ObjectName != 'Session')
400
+ if (!pageData.Fields.find(function (x) { return x.Name == 'ModifiedBy'; }) && !['CompanySessionLogList', 'CompanyTransactionLogsList'].includes(pageData.PageName) && ["Session", "PromoCodeTransaction"].includes(pageData.ObjectName) == false)
400
401
  pageData.Fields.push(modByObj);
401
- if (!pageData.Fields.find(function (x) { return x.Name == 'ModifiedDate'; }) && !['CompanySessionLogList', 'CompanyTransactionLogsList'].includes(pageData.PageName) && pageData.ObjectName != 'Session')
402
+ if (!pageData.Fields.find(function (x) { return x.Name == 'ModifiedDate'; }) && !['CompanySessionLogList', 'CompanyTransactionLogsList'].includes(pageData.PageName) && ["Session", "PromoCodeTransaction"].includes(pageData.ObjectName) == false)
402
403
  pageData.Fields.push(modDateObj);
403
404
  }
404
405
  if (pageData.Fields && pageData.Type == "ObjectDetail") {
@@ -563,9 +564,7 @@ function SyncChildObjectData(pageData, objectID, db) {
563
564
  _a.sent();
564
565
  SyncFieldInSameCollectionByObjectID(group.ChildObject, childID, db);
565
566
  _a.label = 5;
566
- case 5:
567
- SyncFieldInOtherCollection(syncFields, db);
568
- return [3 /*break*/, 14];
567
+ case 5: return [3 /*break*/, 14];
569
568
  case 6:
570
569
  childFieldsObj = {};
571
570
  _loop_6 = function (i_4) {
@@ -661,15 +660,15 @@ function SyncParentObjectData(pageData, objectID, db) {
661
660
  switch (_a.label) {
662
661
  case 0:
663
662
  objectName = pageData.ObjectName;
664
- if (!pageData.ParentObject) return [3 /*break*/, 5];
663
+ if (!pageData.ParentObject) return [3 /*break*/, 4];
665
664
  parent_1 = pageData.ParentObject;
666
665
  return [4 /*yield*/, db.collection(objectName).findOne({ '_id': objectID })];
667
666
  case 1:
668
667
  data = _a.sent();
669
- if (!(data && data._id)) return [3 /*break*/, 5];
670
- 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];
671
670
  parentID = data[parent_1.ObjectField];
672
- if (!parentID) return [3 /*break*/, 5];
671
+ if (!parentID) return [3 /*break*/, 4];
673
672
  return [4 /*yield*/, db.collection(parent_1.ObjectName).findOne({ '_id': parentID })];
674
673
  case 2:
675
674
  parentData = _a.sent();
@@ -704,10 +703,7 @@ function SyncParentObjectData(pageData, objectID, db) {
704
703
  case 3:
705
704
  _a.sent();
706
705
  _a.label = 4;
707
- case 4:
708
- SyncFieldInOtherCollection(syncFields, db);
709
- _a.label = 5;
710
- case 5: return [2 /*return*/];
706
+ case 4: return [2 /*return*/];
711
707
  }
712
708
  });
713
709
  });
@@ -2039,6 +2035,15 @@ function FilterConditions(condition, match, fields) {
2039
2035
  if (["lookup", "multilookup"].includes(field.Schema.UIDataType)) {
2040
2036
  fldName += '_SearchValue';
2041
2037
  }
2038
+ //added by nirbhay on 25.04.22 to add dropdown in any type of fields for filter
2039
+ if (field.Schema.SearchType) {
2040
+ fldName = field.UniqueID;
2041
+ if (field.Schema.SearchType == 'dropdown') {
2042
+ if (field.Schema.LookupObject && obj.Value && (field.Schema.SelectKeyType == undefined || field.Schema.SelectKeyType == 'objectid')) {
2043
+ obj.Value = new mongodb_1.ObjectId(obj.Value);
2044
+ }
2045
+ }
2046
+ }
2042
2047
  switch (field.Schema.UIDataType) {
2043
2048
  case "int":
2044
2049
  obj.Value = parseInt(obj.Value);
@@ -2078,6 +2083,9 @@ function FilterConditions(condition, match, fields) {
2078
2083
  case "EQUAL":
2079
2084
  if (obj.Value === '')
2080
2085
  matchValue = { '$in': [null, ''] };
2086
+ else if (field.Schema.SearchType == 'dropdown') {
2087
+ matchValue = { '$eq': obj.Value };
2088
+ }
2081
2089
  else if (["date", "datetime"].includes(field.Schema.UIDataType)) {
2082
2090
  matchValue = { '$gte': moment_1.default(obj.Value).startOf('day').toDate(), '$lte': moment_1.default(obj.Value).endOf('day').toDate() };
2083
2091
  }
@@ -2107,6 +2115,9 @@ function FilterConditions(condition, match, fields) {
2107
2115
  case "NOT_EQUAL":
2108
2116
  if (obj.Value === '')
2109
2117
  matchValue = { '$nin': [null, ''] };
2118
+ else if (field.Schema.SearchType == 'dropdown') {
2119
+ matchValue = { '$ne': obj.Value };
2120
+ }
2110
2121
  else if (["int", "decimal", "percent", "time"].includes(field.Schema.UIDataType)) {
2111
2122
  matchValue = { '$ne': obj.Value };
2112
2123
  }
@@ -2163,65 +2174,65 @@ function FilterConditions(condition, match, fields) {
2163
2174
  }
2164
2175
  exports.FilterConditions = FilterConditions;
2165
2176
  function GirdHeaderFilters(filters, fields) {
2166
- var sets = [];
2167
- var _loop_14 = function (i) {
2168
- var obj = filters[i];
2169
- var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
2170
- if (field) {
2171
- var matchValue = null;
2172
- var fldName = field.UniqueID;
2173
- if (["lookup", "multilookup"].includes(field.Schema.UIDataType)) {
2174
- //added by nirbhay on 12 apr 2022, added dropdown and multiselect for lookup and multilookup field
2177
+ try {
2178
+ var sets = [];
2179
+ var _loop_14 = function (i) {
2180
+ var obj = filters[i];
2181
+ var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
2182
+ if (field) {
2183
+ var matchValue = null;
2184
+ var fldName = field.UniqueID;
2185
+ //added by nirbhay on 25.04.22 to add dropdown in any type of fields for filter
2175
2186
  if (field.Schema.SearchType == 'dropdown') {
2176
2187
  matchValue = { '$eq': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2177
2188
  }
2178
- else if (field.Schema.SearchType == 'multiselect') {
2179
- matchValue = { '$in': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2180
- }
2181
- else {
2189
+ else if (["lookup", "multilookup"].includes(field.Schema.UIDataType)) {
2182
2190
  fldName += '_SearchValue';
2183
2191
  matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
2184
2192
  }
2185
- }
2186
- else if (["dropdown", "multiselect"].includes(field.Schema.UIDataType)) {
2187
- if (field.Schema.LookupObject) {
2188
- matchValue = { '$in': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2193
+ else if (["dropdown", "multiselect"].includes(field.Schema.UIDataType)) {
2194
+ if (field.Schema.LookupObject) {
2195
+ matchValue = { '$in': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2196
+ }
2197
+ else {
2198
+ matchValue = { '$in': obj.Value };
2199
+ }
2189
2200
  }
2190
- else {
2191
- matchValue = { '$in': obj.Value };
2201
+ else if (["date", "datetime"].includes(field.Schema.UIDataType))
2202
+ matchValue = { '$gte': moment_1.default(obj.Value.From).startOf('day').toDate(), '$lte': moment_1.default(obj.Value.To).endOf('day').toDate() };
2203
+ // else if (field.Schema.UIDataType == 'time')
2204
+ // matchValue = (obj.Value == 'true');
2205
+ else if (field.Schema.UIDataType == 'checkbox') {
2206
+ if (obj.Value == 'true')
2207
+ matchValue = true;
2208
+ else
2209
+ matchValue = { $ne: true };
2192
2210
  }
2193
- }
2194
- else if (["date", "datetime"].includes(field.Schema.UIDataType))
2195
- matchValue = { '$gte': moment_1.default(obj.Value.From).startOf('day').toDate(), '$lte': moment_1.default(obj.Value.To).endOf('day').toDate() };
2196
- // else if (field.Schema.UIDataType == 'time')
2197
- // matchValue = (obj.Value == 'true');
2198
- else if (field.Schema.UIDataType == 'checkbox') {
2199
- if (obj.Value == 'true')
2200
- matchValue = true;
2211
+ else if (field.Schema.UIDataType == 'int')
2212
+ matchValue = { '$eq': parseInt(obj.Value) };
2213
+ else if (["decimal", "percent"].includes(field.Schema.UIDataType))
2214
+ matchValue = { '$eq': mongodb_1.Decimal128.fromString(obj.Value) };
2215
+ else if (field.Schema.UIDataType == 'objectid')
2216
+ matchValue = { '$eq': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2217
+ else if (field.Schema.IsEqualAndCaseInsensitiveSearch === true)
2218
+ matchValue = new RegExp('^' + obj.Value + '$', 'i');
2219
+ else if (field.Schema.IsEqualSearch === true)
2220
+ matchValue = { '$eq': obj.Value };
2201
2221
  else
2202
- matchValue = { $ne: true };
2222
+ matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
2223
+ var fieldMatch = {};
2224
+ fieldMatch[fldName] = matchValue;
2225
+ sets.push(fieldMatch);
2203
2226
  }
2204
- else if (field.Schema.UIDataType == 'int')
2205
- matchValue = { '$eq': parseInt(obj.Value) };
2206
- else if (["decimal", "percent"].includes(field.Schema.UIDataType))
2207
- matchValue = { '$eq': mongodb_1.Decimal128.fromString(obj.Value) };
2208
- else if (field.Schema.UIDataType == 'objectid')
2209
- matchValue = { '$eq': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2210
- else if (field.Schema.IsEqualAndCaseInsensitiveSearch === true)
2211
- matchValue = new RegExp('^' + obj.Value + '$', 'i');
2212
- else if (field.Schema.IsEqualSearch === true)
2213
- matchValue = { '$eq': obj.Value };
2214
- else
2215
- matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
2216
- var fieldMatch = {};
2217
- fieldMatch[fldName] = matchValue;
2218
- sets.push(fieldMatch);
2227
+ };
2228
+ for (var i = 0; i < filters.length; i++) {
2229
+ _loop_14(i);
2219
2230
  }
2220
- };
2221
- for (var i = 0; i < filters.length; i++) {
2222
- _loop_14(i);
2231
+ return { '$and': sets };
2232
+ }
2233
+ catch (error) {
2234
+ console.error("Internal Error in GirdHeaderFilters : " + error);
2223
2235
  }
2224
- return { '$and': sets };
2225
2236
  }
2226
2237
  exports.GirdHeaderFilters = GirdHeaderFilters;
2227
2238
  function FieldsGridHeaderFilters(filters, fields) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.267",
3
+ "version": "1.0.270",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {