@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.
- package/dist/lib/utility.d.ts +1 -1
- package/dist/lib/utility.js +53 -48
- package/package.json +1 -1
package/dist/lib/utility.d.ts
CHANGED
|
@@ -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: {
|
package/dist/lib/utility.js
CHANGED
|
@@ -2179,60 +2179,65 @@ function FilterConditions(condition, match, fields) {
|
|
|
2179
2179
|
}
|
|
2180
2180
|
exports.FilterConditions = FilterConditions;
|
|
2181
2181
|
function GirdHeaderFilters(filters, fields) {
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
var
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
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 = { $
|
|
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
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
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
|
-
|
|
2233
|
-
|
|
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) {
|