@optimiser/common 1.0.271 → 1.0.274
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 +116 -91
- 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) {
|
|
@@ -2011,6 +2012,7 @@ function BuildLookupFieldProjection(field, group, project, aggregateArry) {
|
|
|
2011
2012
|
}
|
|
2012
2013
|
exports.BuildLookupFieldProjection = BuildLookupFieldProjection;
|
|
2013
2014
|
function FilterConditions(condition, match, fields) {
|
|
2015
|
+
var _a, _b;
|
|
2014
2016
|
if (condition != undefined && condition.Filters.length > 0) {
|
|
2015
2017
|
var sets = void 0;
|
|
2016
2018
|
if (condition.Condition == 'AND') {
|
|
@@ -2037,7 +2039,7 @@ function FilterConditions(condition, match, fields) {
|
|
|
2037
2039
|
if (["lookup", "multilookup"].includes(field.Schema.UIDataType)) {
|
|
2038
2040
|
fldName += '_SearchValue';
|
|
2039
2041
|
}
|
|
2040
|
-
//added by nirbhay on 25.04.22 to add dropdown in any type of fields for filter
|
|
2042
|
+
//added by nirbhay on 25.04.22 to add dropdown and multiselect in any type of fields for filter
|
|
2041
2043
|
if (field.Schema.SearchType) {
|
|
2042
2044
|
fldName = field.UniqueID;
|
|
2043
2045
|
if (field.Schema.SearchType == 'dropdown') {
|
|
@@ -2045,6 +2047,13 @@ function FilterConditions(condition, match, fields) {
|
|
|
2045
2047
|
obj.Value = new mongodb_1.ObjectId(obj.Value);
|
|
2046
2048
|
}
|
|
2047
2049
|
}
|
|
2050
|
+
else if (field.Schema.SearchType == 'multiselect') {
|
|
2051
|
+
if (field.Schema.LookupObject && obj.Value && obj.Value.length && (field.Schema.SelectKeyType == undefined || field.Schema.SelectKeyType == 'objectid')) {
|
|
2052
|
+
for (var j = 0; j < obj.Value.length; j++) {
|
|
2053
|
+
obj.Value[j] = new mongodb_1.ObjectId(obj.Value[j]);
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2048
2057
|
}
|
|
2049
2058
|
switch (field.Schema.UIDataType) {
|
|
2050
2059
|
case "int":
|
|
@@ -2063,105 +2072,118 @@ function FilterConditions(condition, match, fields) {
|
|
|
2063
2072
|
break;
|
|
2064
2073
|
}
|
|
2065
2074
|
}
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
matchValue = { '$eq': obj.Value };
|
|
2090
|
-
}
|
|
2091
|
-
else if (["date", "datetime"].includes(field.Schema.UIDataType)) {
|
|
2092
|
-
matchValue = { '$gte': moment_1.default(obj.Value).startOf('day').toDate(), '$lte': moment_1.default(obj.Value).endOf('day').toDate() };
|
|
2093
|
-
}
|
|
2094
|
-
else if (["int", "decimal", "percent"].includes(field.Schema.UIDataType)) {
|
|
2095
|
-
matchValue = { '$eq': obj.Value };
|
|
2096
|
-
}
|
|
2097
|
-
else if (field.Schema.UIDataType == 'checkbox') {
|
|
2098
|
-
if (obj.Value == 'true' || obj.Value === true)
|
|
2099
|
-
matchValue = true;
|
|
2075
|
+
// Below If condition added by Nidhi - QPC-5338
|
|
2076
|
+
if (field.Schema.UIDataType === 'date' || field.Schema.UIDataType === 'datetime') {
|
|
2077
|
+
var operator = obj.Operator;
|
|
2078
|
+
var startCompareDate = void 0, endCompareDate = void 0;
|
|
2079
|
+
if (operator === "custom") {
|
|
2080
|
+
startCompareDate = moment_1.default((_a = obj.Value) === null || _a === void 0 ? void 0 : _a.From, "DD-MMM-YYYY").startOf('day');
|
|
2081
|
+
endCompareDate = moment_1.default((_b = obj.Value) === null || _b === void 0 ? void 0 : _b.To, "DD-MMM-YYYY").endOf('day');
|
|
2082
|
+
}
|
|
2083
|
+
else {
|
|
2084
|
+
var _a = helper_1.GetDateRangeFromOperatorValue(operator, obj.FiscalMonth, obj.FiscalFrom), startDate = _a.startDate, endDate = _a.endDate;
|
|
2085
|
+
startCompareDate = moment_1.default(startDate, "DD-MMM-YYYY").startOf('day');
|
|
2086
|
+
endCompareDate = moment_1.default(endDate, "DD-MMM-YYYY").endOf('day');
|
|
2087
|
+
}
|
|
2088
|
+
matchValue = { '$gte': new Date(moment_1.default(startCompareDate).toISOString()), '$lte': new Date(moment_1.default(endCompareDate).toISOString()) };
|
|
2089
|
+
}
|
|
2090
|
+
else {
|
|
2091
|
+
switch (obj.Operator) {
|
|
2092
|
+
case "CONTAINS":
|
|
2093
|
+
if (obj.Value === '')
|
|
2094
|
+
matchValue = { '$in': [null, ''] };
|
|
2095
|
+
else if (["dropdown", "multiselect"].includes(field.Schema.UIDataType) || field.Schema.SearchType == 'multiselect') {
|
|
2096
|
+
matchValue = { '$in': obj.Value };
|
|
2097
|
+
}
|
|
2100
2098
|
else
|
|
2101
|
-
matchValue = { $
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
if (obj.Value)
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2099
|
+
matchValue = { '$regex': obj.Value, '$options': 'i' };
|
|
2100
|
+
break;
|
|
2101
|
+
case "NOT_CONTAINS":
|
|
2102
|
+
if (obj.Value === '')
|
|
2103
|
+
matchValue = { '$nin': [null, ''] };
|
|
2104
|
+
else if (["dropdown", "multiselect"].includes(field.Schema.UIDataType) || field.Schema.SearchType == 'multiselect') {
|
|
2105
|
+
matchValue = { '$nin': obj.Value };
|
|
2106
|
+
}
|
|
2107
|
+
else
|
|
2108
|
+
matchValue = { '$regex': '^((?!' + obj.Value + ').)*$', '$options': 'i' };
|
|
2109
|
+
break;
|
|
2110
|
+
case "EQUAL":
|
|
2111
|
+
if (obj.Value === '')
|
|
2112
|
+
matchValue = { '$in': [null, ''] };
|
|
2113
|
+
else if (field.Schema.SearchType == 'dropdown') {
|
|
2114
|
+
matchValue = { '$eq': obj.Value };
|
|
2115
|
+
}
|
|
2116
|
+
// else if (["date", "datetime"].includes(field.Schema.UIDataType)) {
|
|
2117
|
+
// matchValue = { '$gte': moment(obj.Value).startOf('day').toDate(), '$lte': moment(obj.Value).endOf('day').toDate() };
|
|
2118
|
+
// }
|
|
2119
|
+
else if (["int", "decimal", "percent"].includes(field.Schema.UIDataType)) {
|
|
2120
|
+
matchValue = { '$eq': obj.Value };
|
|
2121
|
+
}
|
|
2122
|
+
else if (field.Schema.UIDataType == 'checkbox') {
|
|
2123
|
+
if (obj.Value == 'true' || obj.Value === true)
|
|
2124
|
+
matchValue = true;
|
|
2125
|
+
else
|
|
2126
|
+
matchValue = { $ne: true };
|
|
2127
|
+
}
|
|
2128
|
+
else if (["lookup", "multilookup"].includes(field.Schema.UIDataType) && obj.ValueType == 'ObjectID') {
|
|
2129
|
+
if (obj.Value) {
|
|
2130
|
+
if (field.Schema.UIDataType == "lookup")
|
|
2131
|
+
matchValue = obj.Value;
|
|
2132
|
+
else {
|
|
2133
|
+
matchValue = {
|
|
2134
|
+
'$in': [obj.Value]
|
|
2135
|
+
};
|
|
2136
|
+
}
|
|
2111
2137
|
}
|
|
2112
2138
|
}
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
matchValue = { '$ne': obj.Value };
|
|
2125
|
-
}
|
|
2126
|
-
else
|
|
2127
|
-
matchValue = { '$regex': '^(?!' + obj.Value + '$)', '$options': 'i' };
|
|
2128
|
-
break;
|
|
2129
|
-
case "GREATER_THAN":
|
|
2130
|
-
if (obj.Value) {
|
|
2131
|
-
if (["date", "datetime"].includes(field.Schema.UIDataType)) {
|
|
2132
|
-
matchValue = { '$gt': moment_1.default(obj.Value).endOf('day').toDate() };
|
|
2139
|
+
else
|
|
2140
|
+
matchValue = { '$regex': '^' + obj.Value + '$', '$options': 'i' };
|
|
2141
|
+
break;
|
|
2142
|
+
case "NOT_EQUAL":
|
|
2143
|
+
if (obj.Value === '')
|
|
2144
|
+
matchValue = { '$nin': [null, ''] };
|
|
2145
|
+
else if (field.Schema.SearchType == 'dropdown') {
|
|
2146
|
+
matchValue = { '$ne': obj.Value };
|
|
2147
|
+
}
|
|
2148
|
+
else if (["int", "decimal", "percent", "time"].includes(field.Schema.UIDataType)) {
|
|
2149
|
+
matchValue = { '$ne': obj.Value };
|
|
2133
2150
|
}
|
|
2134
2151
|
else
|
|
2152
|
+
matchValue = { '$regex': '^(?!' + obj.Value + '$)', '$options': 'i' };
|
|
2153
|
+
break;
|
|
2154
|
+
case "GREATER_THAN":
|
|
2155
|
+
if (obj.Value) {
|
|
2156
|
+
// if (["date", "datetime"].includes(field.Schema.UIDataType)) {
|
|
2157
|
+
// matchValue = { '$gt': moment(obj.Value).endOf('day').toDate() };
|
|
2158
|
+
// } else
|
|
2135
2159
|
matchValue = { '$gt': obj.Value };
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
matchValue = { '$lt':
|
|
2141
|
-
|
|
2142
|
-
else
|
|
2160
|
+
}
|
|
2161
|
+
break;
|
|
2162
|
+
case "LESS_THAN":
|
|
2163
|
+
// if (["date", "datetime"].includes(field.Schema.UIDataType)) {
|
|
2164
|
+
// matchValue = { '$lt': moment(obj.Value).startOf('day').toDate() }
|
|
2165
|
+
// } else
|
|
2143
2166
|
matchValue = { '$lt': obj.Value };
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
matchValue = { '$gte':
|
|
2148
|
-
|
|
2149
|
-
else
|
|
2167
|
+
break;
|
|
2168
|
+
case "GREATER_OR_EQUAL":
|
|
2169
|
+
// if (["date", "datetime"].includes(field.Schema.UIDataType)) {
|
|
2170
|
+
// matchValue = { '$gte': moment(obj.Value).startOf('day').toDate() }
|
|
2171
|
+
// } else
|
|
2150
2172
|
matchValue = { '$gte': obj.Value };
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
matchValue = { '$lte':
|
|
2155
|
-
|
|
2156
|
-
else
|
|
2173
|
+
break;
|
|
2174
|
+
case "LESS_OR_EQUAL":
|
|
2175
|
+
// if (["date", "datetime"].includes(field.Schema.UIDataType)) {
|
|
2176
|
+
// matchValue = { '$lte': moment(obj.Value).endOf('day').toDate() }
|
|
2177
|
+
// } else
|
|
2157
2178
|
matchValue = { '$lte': obj.Value };
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2179
|
+
break;
|
|
2180
|
+
case "STARTS_WITH":
|
|
2181
|
+
matchValue = { '$regex': '^' + obj.Value, '$options': 'i' };
|
|
2182
|
+
break;
|
|
2183
|
+
case "END_WITH":
|
|
2184
|
+
matchValue = { '$regex': obj.Value + '$', '$options': 'i' };
|
|
2185
|
+
break;
|
|
2186
|
+
}
|
|
2165
2187
|
}
|
|
2166
2188
|
var fieldMatch = {};
|
|
2167
2189
|
fieldMatch[fldName] = matchValue;
|
|
@@ -2188,6 +2210,9 @@ function GirdHeaderFilters(filters, fields) {
|
|
|
2188
2210
|
if (field.Schema.SearchType == 'dropdown') {
|
|
2189
2211
|
matchValue = { '$eq': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
|
|
2190
2212
|
}
|
|
2213
|
+
else if (field.Schema.SearchType == 'multiselect') {
|
|
2214
|
+
matchValue = { '$in': bson_1.EJSON.parse(JSON.stringify(obj.Value)) };
|
|
2215
|
+
}
|
|
2191
2216
|
else if (["lookup", "multilookup"].includes(field.Schema.UIDataType)) {
|
|
2192
2217
|
fldName += '_SearchValue';
|
|
2193
2218
|
matchValue = { '$regex': obj.Value.trim().replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, "\\$&"), '$options': 'i' };
|