@optimiser/common 1.0.269 → 1.0.272
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/helper.js +35 -0
- package/dist/lib/utility.js +120 -104
- package/package.json +1 -1
package/dist/lib/helper.js
CHANGED
|
@@ -431,118 +431,147 @@ var GetDateRangeFromOperatorValue = function (operator, fiscalMonth, fiscalFrom)
|
|
|
431
431
|
}
|
|
432
432
|
switch (operator) {
|
|
433
433
|
case "Yesterday":
|
|
434
|
+
case "yesterday":
|
|
434
435
|
startDate = momentObj.clone().subtract(1, "days").format(requiredDateFormat);
|
|
435
436
|
endDate = momentObj.clone().subtract(1, "days").format(requiredDateFormat);
|
|
436
437
|
break;
|
|
437
438
|
case "Today":
|
|
439
|
+
case "today":
|
|
438
440
|
startDate = momentObj.clone().format(requiredDateFormat);
|
|
439
441
|
endDate = momentObj.clone().format(requiredDateFormat);
|
|
440
442
|
break;
|
|
441
443
|
case "Tomorrow":
|
|
444
|
+
case "tomorrow":
|
|
442
445
|
startDate = momentObj.clone().add(1, "days").format(requiredDateFormat);
|
|
443
446
|
endDate = momentObj.clone().add(1, "days").format(requiredDateFormat);
|
|
444
447
|
break;
|
|
445
448
|
case "Last 7 Days":
|
|
449
|
+
case "last-7-days":
|
|
446
450
|
startDate = momentObj.clone().subtract(6, "days").format(requiredDateFormat);
|
|
447
451
|
endDate = momentObj.clone().format(requiredDateFormat);
|
|
448
452
|
break;
|
|
449
453
|
case "Last 30 Days":
|
|
454
|
+
case "last-30-days":
|
|
450
455
|
startDate = momentObj.clone().subtract(29, "days").format(requiredDateFormat);
|
|
451
456
|
endDate = momentObj.clone().format(requiredDateFormat);
|
|
452
457
|
break;
|
|
453
458
|
case "Last 60 Days":
|
|
459
|
+
case "last-60-days":
|
|
454
460
|
startDate = momentObj.clone().subtract(59, "days").format(requiredDateFormat);
|
|
455
461
|
endDate = momentObj.clone().format(requiredDateFormat);
|
|
456
462
|
break;
|
|
457
463
|
case "Last 90 Days":
|
|
464
|
+
case "last-90-days":
|
|
458
465
|
startDate = momentObj.clone().subtract(89, "days").format(requiredDateFormat);
|
|
459
466
|
endDate = momentObj.clone().format(requiredDateFormat);
|
|
460
467
|
break;
|
|
461
468
|
case "Last 120 Days":
|
|
469
|
+
case "last-120-days":
|
|
462
470
|
startDate = momentObj.clone().subtract(119, "days").format(requiredDateFormat);
|
|
463
471
|
endDate = momentObj.clone().format(requiredDateFormat);
|
|
464
472
|
break;
|
|
465
473
|
case "Next 7 Days":
|
|
474
|
+
case "next-7-days":
|
|
466
475
|
startDate = momentObj.clone().format(requiredDateFormat);
|
|
467
476
|
endDate = momentObj.clone().add(6, "days").format(requiredDateFormat);
|
|
468
477
|
break;
|
|
469
478
|
case "Next 30 Days":
|
|
479
|
+
case "next-30-days":
|
|
470
480
|
startDate = momentObj.clone().format(requiredDateFormat);
|
|
471
481
|
endDate = momentObj.clone().add(29, "days").format(requiredDateFormat);
|
|
472
482
|
break;
|
|
473
483
|
case "Next 60 Days":
|
|
484
|
+
case "next-60-days":
|
|
474
485
|
startDate = momentObj.clone().format(requiredDateFormat);
|
|
475
486
|
endDate = momentObj.clone().add(59, "days").format(requiredDateFormat);
|
|
476
487
|
break;
|
|
477
488
|
case "Next 90 Days":
|
|
489
|
+
case "next-90-days":
|
|
478
490
|
startDate = momentObj.clone().format(requiredDateFormat);
|
|
479
491
|
endDate = momentObj.clone().add(89, "days").format(requiredDateFormat);
|
|
480
492
|
break;
|
|
481
493
|
case "Next 120 Days":
|
|
494
|
+
case "next-120-days":
|
|
482
495
|
startDate = momentObj.clone().format(requiredDateFormat);
|
|
483
496
|
endDate = momentObj.clone().add(119, "days").format(requiredDateFormat);
|
|
484
497
|
break;
|
|
485
498
|
case "Last Week":
|
|
499
|
+
case "last-week":
|
|
486
500
|
startDate = momentObj.clone().subtract(1, "weeks").startOf('isoWeek').format(requiredDateFormat);
|
|
487
501
|
endDate = momentObj.clone().subtract(1, "weeks").endOf('isoWeek').format(requiredDateFormat);
|
|
488
502
|
break;
|
|
489
503
|
case "This Week":
|
|
504
|
+
case "this-week":
|
|
490
505
|
startDate = momentObj.clone().startOf('isoWeek').format(requiredDateFormat);
|
|
491
506
|
endDate = momentObj.clone().endOf('isoWeek').format(requiredDateFormat);
|
|
492
507
|
break;
|
|
493
508
|
case "Next Week":
|
|
509
|
+
case "next-week":
|
|
494
510
|
startDate = momentObj.clone().add(1, "weeks").startOf('isoWeek').format(requiredDateFormat);
|
|
495
511
|
endDate = momentObj.clone().add(1, "weeks").endOf('isoWeek').format(requiredDateFormat);
|
|
496
512
|
break;
|
|
497
513
|
case "Last Month":
|
|
514
|
+
case "last-month":
|
|
498
515
|
startDate = momentObj.clone().subtract(1, "months").startOf('month').format(requiredDateFormat);
|
|
499
516
|
endDate = momentObj.clone().subtract(1, "months").endOf('month').format(requiredDateFormat);
|
|
500
517
|
break;
|
|
501
518
|
case "This Month":
|
|
519
|
+
case "this-month":
|
|
502
520
|
startDate = momentObj.clone().startOf('month').format(requiredDateFormat);
|
|
503
521
|
endDate = momentObj.clone().endOf('month').format(requiredDateFormat);
|
|
504
522
|
break;
|
|
505
523
|
case "Next Month":
|
|
524
|
+
case "next-month":
|
|
506
525
|
startDate = momentObj.clone().add(1, "months").startOf('month').format(requiredDateFormat);
|
|
507
526
|
endDate = momentObj.clone().add(1, "months").endOf('month').format(requiredDateFormat);
|
|
508
527
|
break;
|
|
509
528
|
case "Last Quarter":
|
|
529
|
+
case "last-quarter":
|
|
510
530
|
startDate = momentObj.clone().subtract(1, "quarters").startOf('quarter').format(requiredDateFormat);
|
|
511
531
|
endDate = momentObj.clone().subtract(1, "quarters").endOf('quarter').format(requiredDateFormat);
|
|
512
532
|
break;
|
|
513
533
|
case "This Quarter":
|
|
534
|
+
case "this-quarter":
|
|
514
535
|
startDate = momentObj.clone().startOf('quarter').format(requiredDateFormat);
|
|
515
536
|
endDate = momentObj.clone().endOf('quarter').format(requiredDateFormat);
|
|
516
537
|
break;
|
|
517
538
|
case "Next Quarter":
|
|
539
|
+
case "next-quarter":
|
|
518
540
|
startDate = momentObj.clone().add(1, "quarters").startOf('quarter').format(requiredDateFormat);
|
|
519
541
|
endDate = momentObj.clone().add(1, "quarters").endOf('quarter').format(requiredDateFormat);
|
|
520
542
|
break;
|
|
521
543
|
case "Last Fiscal Quarter":
|
|
544
|
+
case "last-fiscal-quarter":
|
|
522
545
|
startDate = moment_1.default(startDate, currentDateFormat).clone().subtract(3, "months").startOf('month').format(requiredDateFormat);
|
|
523
546
|
endDate = moment_1.default(startDate, currentDateFormat).clone().add(2, "months").endOf('month').format(requiredDateFormat);
|
|
524
547
|
break;
|
|
525
548
|
case "This Fiscal Quarter":
|
|
549
|
+
case "this-fiscal-quarter":
|
|
526
550
|
startDate = startDate;
|
|
527
551
|
endDate = endDate;
|
|
528
552
|
break;
|
|
529
553
|
case "Next Fiscal Quarter":
|
|
554
|
+
case "next-fiscal-quarter":
|
|
530
555
|
startDate = moment_1.default(startDate, currentDateFormat).clone().add(3, "months").startOf('month').format(requiredDateFormat);
|
|
531
556
|
endDate = moment_1.default(startDate, currentDateFormat).clone().add(2, "months").endOf('month').format(requiredDateFormat);
|
|
532
557
|
break;
|
|
533
558
|
case "Last Year":
|
|
559
|
+
case "last-year":
|
|
534
560
|
startDate = momentObj.clone().subtract(1, "years").startOf('year').format(requiredDateFormat);
|
|
535
561
|
endDate = momentObj.clone().subtract(1, "years").endOf('year').format(requiredDateFormat);
|
|
536
562
|
break;
|
|
537
563
|
case "This Year":
|
|
564
|
+
case "this-year":
|
|
538
565
|
startDate = momentObj.clone().startOf('year').format(requiredDateFormat);
|
|
539
566
|
endDate = momentObj.clone().endOf('year').format(requiredDateFormat);
|
|
540
567
|
break;
|
|
541
568
|
case "Next Year":
|
|
569
|
+
case "next-year":
|
|
542
570
|
startDate = momentObj.clone().add(1, "years").startOf('year').format(requiredDateFormat);
|
|
543
571
|
endDate = momentObj.clone().add(1, "years").endOf('year').format(requiredDateFormat);
|
|
544
572
|
break;
|
|
545
573
|
case "Last Fiscal Year":
|
|
574
|
+
case "last-fiscal-year":
|
|
546
575
|
if (fiscalFrom === "Start") {
|
|
547
576
|
if (getFiscalMonthIndex == 0 || getFiscalMonthIndex && getFiscalMonthIndex <= momentObj.clone().month()) {
|
|
548
577
|
startDate = moment_1.default(startDate, currentDateFormat).clone().month(fiscalMonth).subtract(12, "months").startOf('month').format(requiredDateFormat);
|
|
@@ -565,6 +594,7 @@ var GetDateRangeFromOperatorValue = function (operator, fiscalMonth, fiscalFrom)
|
|
|
565
594
|
}
|
|
566
595
|
break;
|
|
567
596
|
case "This Fiscal Year":
|
|
597
|
+
case "this-fiscal-quarter":
|
|
568
598
|
if (fiscalFrom === "Start") {
|
|
569
599
|
if (getFiscalMonthIndex == 0 || getFiscalMonthIndex && getFiscalMonthIndex <= momentObj.clone().month()) {
|
|
570
600
|
startDate = moment_1.default(startDate, currentDateFormat).clone().month(fiscalMonth).startOf('month').format(requiredDateFormat);
|
|
@@ -587,6 +617,7 @@ var GetDateRangeFromOperatorValue = function (operator, fiscalMonth, fiscalFrom)
|
|
|
587
617
|
}
|
|
588
618
|
break;
|
|
589
619
|
case "Next Fiscal Year":
|
|
620
|
+
case "next-fiscal-quarter":
|
|
590
621
|
if (fiscalFrom === "Start") {
|
|
591
622
|
if (getFiscalMonthIndex == 0 || getFiscalMonthIndex && getFiscalMonthIndex <= momentObj.clone().month()) {
|
|
592
623
|
startDate = moment_1.default(startDate, currentDateFormat).clone().month(fiscalMonth).add(1, "years").startOf('month').format(requiredDateFormat);
|
|
@@ -609,18 +640,22 @@ var GetDateRangeFromOperatorValue = function (operator, fiscalMonth, fiscalFrom)
|
|
|
609
640
|
}
|
|
610
641
|
break;
|
|
611
642
|
case "Current Calendar Year":
|
|
643
|
+
case "current-calendar-year":
|
|
612
644
|
startDate = momentObj.clone().startOf('year').format(requiredDateFormat);
|
|
613
645
|
endDate = momentObj.clone().endOf('year').format(requiredDateFormat);
|
|
614
646
|
break;
|
|
615
647
|
case "Previous Calendar Year":
|
|
648
|
+
case "previous-calendar-year":
|
|
616
649
|
startDate = momentObj.clone().subtract(1, "years").startOf('year').format(requiredDateFormat);
|
|
617
650
|
endDate = momentObj.clone().subtract(1, "years").endOf('year').format(requiredDateFormat);
|
|
618
651
|
break;
|
|
619
652
|
case "Next Calendar Year":
|
|
653
|
+
case "next-calendar-year":
|
|
620
654
|
startDate = momentObj.clone().add(1, "years").startOf('year').format(requiredDateFormat);
|
|
621
655
|
endDate = momentObj.clone().add(1, "years").endOf('year').format(requiredDateFormat);
|
|
622
656
|
break;
|
|
623
657
|
case "Year to Date":
|
|
658
|
+
case "year-to-date":
|
|
624
659
|
endDate = momentObj.clone().format(requiredDateFormat);
|
|
625
660
|
if (parseInt(momentObj.format('M')) > 3) {
|
|
626
661
|
startDate = momentObj.clone().startOf('month').month("Apr").format(requiredDateFormat);
|
package/dist/lib/utility.js
CHANGED
|
@@ -96,6 +96,7 @@ var errorHandlerForServices_1 = __importDefault(require("../utility/errorHandler
|
|
|
96
96
|
var cryptoService = __importStar(require("../utility/crypto"));
|
|
97
97
|
var countrycode_1 = require("./countrycode");
|
|
98
98
|
require("moment-timezone");
|
|
99
|
+
var helper_1 = require("./helper");
|
|
99
100
|
var sanitize = require('mongo-sanitize');
|
|
100
101
|
function GetObjectByKeyValueFromList(list, key, val) {
|
|
101
102
|
if (list && list.length > 0) {
|
|
@@ -564,9 +565,7 @@ function SyncChildObjectData(pageData, objectID, db) {
|
|
|
564
565
|
_a.sent();
|
|
565
566
|
SyncFieldInSameCollectionByObjectID(group.ChildObject, childID, db);
|
|
566
567
|
_a.label = 5;
|
|
567
|
-
case 5:
|
|
568
|
-
SyncFieldInOtherCollection(syncFields, db);
|
|
569
|
-
return [3 /*break*/, 14];
|
|
568
|
+
case 5: return [3 /*break*/, 14];
|
|
570
569
|
case 6:
|
|
571
570
|
childFieldsObj = {};
|
|
572
571
|
_loop_6 = function (i_4) {
|
|
@@ -662,15 +661,15 @@ function SyncParentObjectData(pageData, objectID, db) {
|
|
|
662
661
|
switch (_a.label) {
|
|
663
662
|
case 0:
|
|
664
663
|
objectName = pageData.ObjectName;
|
|
665
|
-
if (!pageData.ParentObject) return [3 /*break*/,
|
|
664
|
+
if (!pageData.ParentObject) return [3 /*break*/, 4];
|
|
666
665
|
parent_1 = pageData.ParentObject;
|
|
667
666
|
return [4 /*yield*/, db.collection(objectName).findOne({ '_id': objectID })];
|
|
668
667
|
case 1:
|
|
669
668
|
data = _a.sent();
|
|
670
|
-
if (!(data && data._id)) return [3 /*break*/,
|
|
671
|
-
if (!(parent_1 && data.IsDefaultRecord)) return [3 /*break*/,
|
|
669
|
+
if (!(data && data._id)) return [3 /*break*/, 4];
|
|
670
|
+
if (!(parent_1 && data.IsDefaultRecord)) return [3 /*break*/, 4];
|
|
672
671
|
parentID = data[parent_1.ObjectField];
|
|
673
|
-
if (!parentID) return [3 /*break*/,
|
|
672
|
+
if (!parentID) return [3 /*break*/, 4];
|
|
674
673
|
return [4 /*yield*/, db.collection(parent_1.ObjectName).findOne({ '_id': parentID })];
|
|
675
674
|
case 2:
|
|
676
675
|
parentData = _a.sent();
|
|
@@ -705,10 +704,7 @@ function SyncParentObjectData(pageData, objectID, db) {
|
|
|
705
704
|
case 3:
|
|
706
705
|
_a.sent();
|
|
707
706
|
_a.label = 4;
|
|
708
|
-
case 4:
|
|
709
|
-
SyncFieldInOtherCollection(syncFields, db);
|
|
710
|
-
_a.label = 5;
|
|
711
|
-
case 5: return [2 /*return*/];
|
|
707
|
+
case 4: return [2 /*return*/];
|
|
712
708
|
}
|
|
713
709
|
});
|
|
714
710
|
});
|
|
@@ -1806,7 +1802,9 @@ function BuildGridFieldProjection(project, field, group) {
|
|
|
1806
1802
|
project[alias] = 1;
|
|
1807
1803
|
if (field.Schema.LookupObject) {
|
|
1808
1804
|
for (var i = 0; i < field.Schema.LookupFields.length; i++) {
|
|
1809
|
-
searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], ""] });
|
|
1805
|
+
//searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], ""] });
|
|
1806
|
+
// added by Mohan, make int to string and concat
|
|
1807
|
+
searchConcatArry.push({ "$ifNull": [{ $toString: '$' + alias + '.' + field.Schema.LookupFields[i] }, ""] });
|
|
1810
1808
|
if (i < field.Schema.LookupFields.length - 1) {
|
|
1811
1809
|
searchConcatArry.push(" ");
|
|
1812
1810
|
}
|
|
@@ -2014,6 +2012,7 @@ function BuildLookupFieldProjection(field, group, project, aggregateArry) {
|
|
|
2014
2012
|
}
|
|
2015
2013
|
exports.BuildLookupFieldProjection = BuildLookupFieldProjection;
|
|
2016
2014
|
function FilterConditions(condition, match, fields) {
|
|
2015
|
+
var _a, _b;
|
|
2017
2016
|
if (condition != undefined && condition.Filters.length > 0) {
|
|
2018
2017
|
var sets = void 0;
|
|
2019
2018
|
if (condition.Condition == 'AND') {
|
|
@@ -2066,105 +2065,122 @@ function FilterConditions(condition, match, fields) {
|
|
|
2066
2065
|
break;
|
|
2067
2066
|
}
|
|
2068
2067
|
}
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
matchValue = { '$eq': obj.Value };
|
|
2093
|
-
}
|
|
2094
|
-
else if (["date", "datetime"].includes(field.Schema.UIDataType)) {
|
|
2095
|
-
matchValue = { '$gte': moment_1.default(obj.Value).startOf('day').toDate(), '$lte': moment_1.default(obj.Value).endOf('day').toDate() };
|
|
2096
|
-
}
|
|
2097
|
-
else if (["int", "decimal", "percent"].includes(field.Schema.UIDataType)) {
|
|
2098
|
-
matchValue = { '$eq': obj.Value };
|
|
2099
|
-
}
|
|
2100
|
-
else if (field.Schema.UIDataType == 'checkbox') {
|
|
2101
|
-
if (obj.Value == 'true' || obj.Value === true)
|
|
2102
|
-
matchValue = true;
|
|
2068
|
+
// Below If condition added by Nidhi - QPC-5338
|
|
2069
|
+
if (field.Schema.UIDataType === 'date' || field.Schema.UIDataType === 'datetime') {
|
|
2070
|
+
var operator = obj.Operator;
|
|
2071
|
+
var startCompareDate = void 0, endCompareDate = void 0;
|
|
2072
|
+
if (operator === "custom") {
|
|
2073
|
+
startCompareDate = moment_1.default((_a = obj.Value) === null || _a === void 0 ? void 0 : _a.From, "DD-MMM-YYYY").startOf('day');
|
|
2074
|
+
endCompareDate = moment_1.default((_b = obj.Value) === null || _b === void 0 ? void 0 : _b.To, "DD-MMM-YYYY").endOf('day');
|
|
2075
|
+
}
|
|
2076
|
+
else {
|
|
2077
|
+
var _a = helper_1.GetDateRangeFromOperatorValue(operator, obj.FiscalMonth, obj.FiscalFrom), startDate = _a.startDate, endDate = _a.endDate;
|
|
2078
|
+
startCompareDate = moment_1.default(startDate, "DD-MMM-YYYY").startOf('day');
|
|
2079
|
+
endCompareDate = moment_1.default(endDate, "DD-MMM-YYYY").endOf('day');
|
|
2080
|
+
}
|
|
2081
|
+
matchValue = { '$gte': new Date(moment_1.default(startCompareDate).toISOString()), '$lte': new Date(moment_1.default(endCompareDate).toISOString()) };
|
|
2082
|
+
}
|
|
2083
|
+
else {
|
|
2084
|
+
switch (obj.Operator) {
|
|
2085
|
+
case "CONTAINS":
|
|
2086
|
+
if (obj.Value === '')
|
|
2087
|
+
matchValue = { '$in': [null, ''] };
|
|
2088
|
+
else if (["dropdown", "multiselect"].includes(field.Schema.UIDataType)) {
|
|
2089
|
+
matchValue = { '$in': obj.Value };
|
|
2090
|
+
}
|
|
2103
2091
|
else
|
|
2104
|
-
matchValue = { $
|
|
2105
|
-
|
|
2106
|
-
|
|
2092
|
+
matchValue = { '$regex': obj.Value, '$options': 'i' };
|
|
2093
|
+
break;
|
|
2094
|
+
case "NOT_CONTAINS":
|
|
2095
|
+
if (obj.Value === '')
|
|
2096
|
+
matchValue = { '$nin': [null, ''] };
|
|
2097
|
+
else if (["dropdown", "multiselect"].includes(field.Schema.UIDataType)) {
|
|
2098
|
+
matchValue = { '$nin': obj.Value };
|
|
2099
|
+
}
|
|
2100
|
+
else
|
|
2101
|
+
matchValue = { '$regex': '^((?!' + obj.Value + ').)*$', '$options': 'i' };
|
|
2102
|
+
break;
|
|
2103
|
+
case "EQUAL":
|
|
2104
|
+
if (obj.Value === '')
|
|
2105
|
+
matchValue = { '$in': [null, ''] };
|
|
2106
|
+
else if (field.Schema.SearchType == 'dropdown') {
|
|
2107
|
+
matchValue = { '$eq': obj.Value };
|
|
2108
|
+
}
|
|
2109
|
+
else if (["date", "datetime"].includes(field.Schema.UIDataType)) {
|
|
2110
|
+
matchValue = { '$gte': moment_1.default(obj.Value).startOf('day').toDate(), '$lte': moment_1.default(obj.Value).endOf('day').toDate() };
|
|
2111
|
+
}
|
|
2112
|
+
else if (["int", "decimal", "percent"].includes(field.Schema.UIDataType)) {
|
|
2113
|
+
matchValue = { '$eq': obj.Value };
|
|
2114
|
+
}
|
|
2115
|
+
else if (field.Schema.UIDataType == 'checkbox') {
|
|
2116
|
+
if (obj.Value == 'true' || obj.Value === true)
|
|
2117
|
+
matchValue = true;
|
|
2118
|
+
else
|
|
2119
|
+
matchValue = { $ne: true };
|
|
2120
|
+
}
|
|
2121
|
+
else if (["lookup", "multilookup"].includes(field.Schema.UIDataType) && obj.ValueType == 'ObjectID') {
|
|
2122
|
+
if (obj.Value) {
|
|
2123
|
+
if (field.Schema.UIDataType == "lookup")
|
|
2124
|
+
matchValue = obj.Value;
|
|
2125
|
+
else {
|
|
2126
|
+
matchValue = {
|
|
2127
|
+
'$in': [obj.Value]
|
|
2128
|
+
};
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
else
|
|
2133
|
+
matchValue = { '$regex': '^' + obj.Value + '$', '$options': 'i' };
|
|
2134
|
+
break;
|
|
2135
|
+
case "NOT_EQUAL":
|
|
2136
|
+
if (obj.Value === '')
|
|
2137
|
+
matchValue = { '$nin': [null, ''] };
|
|
2138
|
+
else if (field.Schema.SearchType == 'dropdown') {
|
|
2139
|
+
matchValue = { '$ne': obj.Value };
|
|
2140
|
+
}
|
|
2141
|
+
else if (["int", "decimal", "percent", "time"].includes(field.Schema.UIDataType)) {
|
|
2142
|
+
matchValue = { '$ne': obj.Value };
|
|
2143
|
+
}
|
|
2144
|
+
else
|
|
2145
|
+
matchValue = { '$regex': '^(?!' + obj.Value + '$)', '$options': 'i' };
|
|
2146
|
+
break;
|
|
2147
|
+
case "GREATER_THAN":
|
|
2107
2148
|
if (obj.Value) {
|
|
2108
|
-
if (field.Schema.UIDataType
|
|
2109
|
-
matchValue = obj.Value;
|
|
2110
|
-
else {
|
|
2111
|
-
matchValue = {
|
|
2112
|
-
'$in': [obj.Value]
|
|
2113
|
-
};
|
|
2149
|
+
if (["date", "datetime"].includes(field.Schema.UIDataType)) {
|
|
2150
|
+
matchValue = { '$gt': moment_1.default(obj.Value).endOf('day').toDate() };
|
|
2114
2151
|
}
|
|
2152
|
+
else
|
|
2153
|
+
matchValue = { '$gt': obj.Value };
|
|
2115
2154
|
}
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
matchValue = { '$regex': '^' + obj.Value + '$', '$options': 'i' };
|
|
2119
|
-
break;
|
|
2120
|
-
case "NOT_EQUAL":
|
|
2121
|
-
if (obj.Value === '')
|
|
2122
|
-
matchValue = { '$nin': [null, ''] };
|
|
2123
|
-
else if (field.Schema.SearchType == 'dropdown') {
|
|
2124
|
-
matchValue = { '$ne': obj.Value };
|
|
2125
|
-
}
|
|
2126
|
-
else if (["int", "decimal", "percent", "time"].includes(field.Schema.UIDataType)) {
|
|
2127
|
-
matchValue = { '$ne': obj.Value };
|
|
2128
|
-
}
|
|
2129
|
-
else
|
|
2130
|
-
matchValue = { '$regex': '^(?!' + obj.Value + '$)', '$options': 'i' };
|
|
2131
|
-
break;
|
|
2132
|
-
case "GREATER_THAN":
|
|
2133
|
-
if (obj.Value) {
|
|
2155
|
+
break;
|
|
2156
|
+
case "LESS_THAN":
|
|
2134
2157
|
if (["date", "datetime"].includes(field.Schema.UIDataType)) {
|
|
2135
|
-
matchValue = { '$
|
|
2158
|
+
matchValue = { '$lt': moment_1.default(obj.Value).startOf('day').toDate() };
|
|
2136
2159
|
}
|
|
2137
2160
|
else
|
|
2138
|
-
matchValue = { '$
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
break;
|
|
2162
|
-
case "STARTS_WITH":
|
|
2163
|
-
matchValue = { '$regex': '^' + obj.Value, '$options': 'i' };
|
|
2164
|
-
break;
|
|
2165
|
-
case "END_WITH":
|
|
2166
|
-
matchValue = { '$regex': obj.Value + '$', '$options': 'i' };
|
|
2167
|
-
break;
|
|
2161
|
+
matchValue = { '$lt': obj.Value };
|
|
2162
|
+
break;
|
|
2163
|
+
case "GREATER_OR_EQUAL":
|
|
2164
|
+
if (["date", "datetime"].includes(field.Schema.UIDataType)) {
|
|
2165
|
+
matchValue = { '$gte': moment_1.default(obj.Value).startOf('day').toDate() };
|
|
2166
|
+
}
|
|
2167
|
+
else
|
|
2168
|
+
matchValue = { '$gte': obj.Value };
|
|
2169
|
+
break;
|
|
2170
|
+
case "LESS_OR_EQUAL":
|
|
2171
|
+
if (["date", "datetime"].includes(field.Schema.UIDataType)) {
|
|
2172
|
+
matchValue = { '$lte': moment_1.default(obj.Value).endOf('day').toDate() };
|
|
2173
|
+
}
|
|
2174
|
+
else
|
|
2175
|
+
matchValue = { '$lte': obj.Value };
|
|
2176
|
+
break;
|
|
2177
|
+
case "STARTS_WITH":
|
|
2178
|
+
matchValue = { '$regex': '^' + obj.Value, '$options': 'i' };
|
|
2179
|
+
break;
|
|
2180
|
+
case "END_WITH":
|
|
2181
|
+
matchValue = { '$regex': obj.Value + '$', '$options': 'i' };
|
|
2182
|
+
break;
|
|
2183
|
+
}
|
|
2168
2184
|
}
|
|
2169
2185
|
var fieldMatch = {};
|
|
2170
2186
|
fieldMatch[fldName] = matchValue;
|