@optimiser/common 1.0.268 → 1.0.269

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: {
@@ -2179,60 +2179,65 @@ function FilterConditions(condition, match, fields) {
2179
2179
  }
2180
2180
  exports.FilterConditions = FilterConditions;
2181
2181
  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)) };
2182
+ try {
2183
+ var sets = [];
2184
+ var _loop_14 = function (i) {
2185
+ var obj = filters[i];
2186
+ var field = fields.find(function (x) { return x.UniqueID == obj.Name; });
2187
+ if (field) {
2188
+ var matchValue = null;
2189
+ var fldName = field.UniqueID;
2190
+ //added by nirbhay on 25.04.22 to add dropdown in any type of fields for filter
2191
+ if (field.Schema.SearchType == 'dropdown') {
2192
+ matchValue = { '$eq': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2200
2193
  }
2201
- else {
2202
- matchValue = { '$in': obj.Value };
2194
+ else if (["lookup", "multilookup"].includes(field.Schema.UIDataType)) {
2195
+ fldName += '_SearchValue';
2196
+ matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
2203
2197
  }
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;
2198
+ else if (["dropdown", "multiselect"].includes(field.Schema.UIDataType)) {
2199
+ if (field.Schema.LookupObject) {
2200
+ matchValue = { '$in': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2201
+ }
2202
+ else {
2203
+ matchValue = { '$in': obj.Value };
2204
+ }
2205
+ }
2206
+ else if (["date", "datetime"].includes(field.Schema.UIDataType))
2207
+ matchValue = { '$gte': moment_1.default(obj.Value.From).startOf('day').toDate(), '$lte': moment_1.default(obj.Value.To).endOf('day').toDate() };
2208
+ // else if (field.Schema.UIDataType == 'time')
2209
+ // matchValue = (obj.Value == 'true');
2210
+ else if (field.Schema.UIDataType == 'checkbox') {
2211
+ if (obj.Value == 'true')
2212
+ matchValue = true;
2213
+ else
2214
+ matchValue = { $ne: true };
2215
+ }
2216
+ else if (field.Schema.UIDataType == 'int')
2217
+ matchValue = { '$eq': parseInt(obj.Value) };
2218
+ else if (["decimal", "percent"].includes(field.Schema.UIDataType))
2219
+ matchValue = { '$eq': mongodb_1.Decimal128.fromString(obj.Value) };
2220
+ else if (field.Schema.UIDataType == 'objectid')
2221
+ matchValue = { '$eq': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
2222
+ else if (field.Schema.IsEqualAndCaseInsensitiveSearch === true)
2223
+ matchValue = new RegExp('^' + obj.Value + '$', 'i');
2224
+ else if (field.Schema.IsEqualSearch === true)
2225
+ matchValue = { '$eq': obj.Value };
2212
2226
  else
2213
- matchValue = { $ne: true };
2227
+ matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
2228
+ var fieldMatch = {};
2229
+ fieldMatch[fldName] = matchValue;
2230
+ sets.push(fieldMatch);
2214
2231
  }
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);
2232
+ };
2233
+ for (var i = 0; i < filters.length; i++) {
2234
+ _loop_14(i);
2230
2235
  }
2231
- };
2232
- for (var i = 0; i < filters.length; i++) {
2233
- _loop_14(i);
2236
+ return { '$and': sets };
2237
+ }
2238
+ catch (error) {
2239
+ console.error("Internal Error in GirdHeaderFilters : " + error);
2234
2240
  }
2235
- return { '$and': sets };
2236
2241
  }
2237
2242
  exports.GirdHeaderFilters = GirdHeaderFilters;
2238
2243
  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.269",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {