@izara_project/izara-shared-search-and-sort 1.0.9 → 1.0.11
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/package.json +1 -1
- package/src/DataFieldsSharedLib.js +236 -142
- package/src/FiltersSharedLib.js +380 -616
- package/src/LogicalStructureSharedLib.js +159 -476
- package/src/SearchSortSharedLib.js +65 -37
|
@@ -26,7 +26,7 @@ import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
|
26
26
|
import lodash from 'lodash';
|
|
27
27
|
const { isEmpty } = lodash;
|
|
28
28
|
import filtersSharedLib from './FiltersSharedLib.js';
|
|
29
|
-
import LogicalStructureSharedLib from './LogicalStructureSharedLib'
|
|
29
|
+
import LogicalStructureSharedLib from './LogicalStructureSharedLib.js'
|
|
30
30
|
|
|
31
31
|
async function createRequiredData(
|
|
32
32
|
objType,
|
|
@@ -37,7 +37,7 @@ async function createRequiredData(
|
|
|
37
37
|
perParentCombinations,
|
|
38
38
|
requiredDataLinkStepObjects,
|
|
39
39
|
requiredDataLinkSteps,
|
|
40
|
-
|
|
40
|
+
valueUserTags,
|
|
41
41
|
) {
|
|
42
42
|
console.log('createRequiredData: ', {
|
|
43
43
|
objType,
|
|
@@ -48,7 +48,7 @@ async function createRequiredData(
|
|
|
48
48
|
perParentCombinations,
|
|
49
49
|
requiredDataLinkStepObjects,
|
|
50
50
|
requiredDataLinkSteps,
|
|
51
|
-
|
|
51
|
+
valueUserTags,
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
let errorsObject = {};
|
|
@@ -73,12 +73,19 @@ async function createRequiredData(
|
|
|
73
73
|
console.log('initial data: ', { linkSteps });
|
|
74
74
|
|
|
75
75
|
let [fieldName, returnValue, linkPathErrorObject, linkPathErrorsFound] = await createLinkPath(
|
|
76
|
+
objType,
|
|
76
77
|
linkSteps,
|
|
77
78
|
requiredDataLinkStepObjects,
|
|
78
79
|
requiredDataLinkSteps,
|
|
79
80
|
perParentCombinations,
|
|
80
81
|
complexFilterCombinations,
|
|
81
|
-
|
|
82
|
+
valueUserTags,
|
|
83
|
+
{
|
|
84
|
+
objType: objType,
|
|
85
|
+
initialLogicalElementId: initialLogicalElementId,
|
|
86
|
+
logicalElements: logicalElements
|
|
87
|
+
},
|
|
88
|
+
[],
|
|
82
89
|
errorsObject,
|
|
83
90
|
errorsFound
|
|
84
91
|
);
|
|
@@ -91,7 +98,14 @@ async function createRequiredData(
|
|
|
91
98
|
|
|
92
99
|
if (linkPathErrorsFound.length > 0 || fieldName === null) {
|
|
93
100
|
Object.assign(errorsObject, linkPathErrorObject);
|
|
94
|
-
|
|
101
|
+
|
|
102
|
+
for (const linkPathErr of linkPathErrorsFound) {
|
|
103
|
+
if (!errorsFound.includes(linkPathErr)) {
|
|
104
|
+
errorsFound.push(linkPathErr);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// errorsFound = errorsFound.concat(linkPathErrorsFound);
|
|
95
109
|
return {
|
|
96
110
|
requiredDataHash: null,
|
|
97
111
|
requiredDataObject: requiredDataObject,
|
|
@@ -133,17 +147,7 @@ async function createRequiredData(
|
|
|
133
147
|
linkPathObjectId: pathId
|
|
134
148
|
};
|
|
135
149
|
|
|
136
|
-
let requiredFieldNameObject = {
|
|
137
|
-
// fieldName: fieldName,
|
|
138
|
-
fieldName: setObject,
|
|
139
|
-
linkPathObjects: {
|
|
140
|
-
[pathId]: pathObject
|
|
141
|
-
},
|
|
142
|
-
linkPathSteps: returnValue.linkStepObjects
|
|
143
|
-
};
|
|
144
|
-
|
|
145
150
|
if (returnValue.hasOwnProperty('complexFilterCombinations')) {
|
|
146
|
-
// requiredFieldNameObject.complexFilterCombinations = returnValue.complexFilterCombinations;
|
|
147
151
|
Object.assign(setComplexFilterCombinations, returnValue.complexFilterCombinations);
|
|
148
152
|
|
|
149
153
|
setObject.complexFilterCombinationIds = []
|
|
@@ -154,6 +158,15 @@ async function createRequiredData(
|
|
|
154
158
|
};
|
|
155
159
|
};
|
|
156
160
|
|
|
161
|
+
let requiredFieldNameObject = {
|
|
162
|
+
// fieldName: fieldName,
|
|
163
|
+
fieldName: setObject,
|
|
164
|
+
linkPathObjects: {
|
|
165
|
+
[pathId]: pathObject
|
|
166
|
+
},
|
|
167
|
+
linkPathSteps: returnValue.linkStepObjects
|
|
168
|
+
};
|
|
169
|
+
|
|
157
170
|
if (returnValue.hasOwnProperty('perParentCombinations')) {
|
|
158
171
|
// requiredFieldNameObject.perParentCombinations = returnValue.perParentCombinations;
|
|
159
172
|
Object.assign(setPerParentCombinations, returnValue.perParentCombinations);
|
|
@@ -183,7 +196,11 @@ async function createRequiredData(
|
|
|
183
196
|
console.log("------- requiredData has only fieldName ---------");
|
|
184
197
|
|
|
185
198
|
let requiredFieldNameObject = {
|
|
186
|
-
fieldName:
|
|
199
|
+
fieldName: {
|
|
200
|
+
fieldName: fieldName
|
|
201
|
+
},
|
|
202
|
+
linkPathObjects: {},
|
|
203
|
+
linkPathSteps: {}
|
|
187
204
|
};
|
|
188
205
|
console.log("requiredFieldNameObject: ", requiredFieldNameObject);
|
|
189
206
|
|
|
@@ -215,17 +232,17 @@ async function createRequiredData(
|
|
|
215
232
|
};
|
|
216
233
|
};
|
|
217
234
|
|
|
218
|
-
if (!isEmpty(setComplexFilterCombinations)) {
|
|
219
|
-
|
|
220
|
-
};
|
|
235
|
+
// if (!isEmpty(setComplexFilterCombinations)) {
|
|
236
|
+
// requiredObject.complexFilterCombinations = setComplexFilterCombinations;
|
|
237
|
+
// };
|
|
221
238
|
|
|
222
|
-
if (!isEmpty(setPerParentCombinations)) {
|
|
223
|
-
|
|
224
|
-
};
|
|
239
|
+
// if (!isEmpty(setPerParentCombinations)) {
|
|
240
|
+
// requiredObject.perParentCombinations = setPerParentCombinations;
|
|
241
|
+
// };
|
|
225
242
|
|
|
226
|
-
if (!isEmpty(setFilterElementsLink)) {
|
|
227
|
-
|
|
228
|
-
};
|
|
243
|
+
// if (!isEmpty(setFilterElementsLink)) {
|
|
244
|
+
// requiredObject.filterElements = setFilterElementsLink;
|
|
245
|
+
// };
|
|
229
246
|
console.log('requiredObject: ', requiredObject);
|
|
230
247
|
|
|
231
248
|
if (!isEmpty(requiredObject)) {
|
|
@@ -268,19 +285,18 @@ async function createRequiredData(
|
|
|
268
285
|
|
|
269
286
|
|
|
270
287
|
async function createLinkPath(
|
|
288
|
+
objType,
|
|
271
289
|
linkSteps,
|
|
272
290
|
requiredDataLinkStepObjects,
|
|
273
291
|
requiredDataLinkSteps,
|
|
274
292
|
perParentCombinations,
|
|
275
293
|
complexFilterCombinations,
|
|
276
|
-
|
|
294
|
+
valueUserTags,
|
|
277
295
|
filtersStructure,
|
|
278
296
|
path,
|
|
279
297
|
errorsObject,
|
|
280
298
|
errorsFound,
|
|
281
|
-
index = 0
|
|
282
|
-
previousLinkId = null,
|
|
283
|
-
previousLink = null
|
|
299
|
+
index = 0
|
|
284
300
|
) {
|
|
285
301
|
console.log('create LinkPath: ', {
|
|
286
302
|
linkSteps,
|
|
@@ -288,14 +304,12 @@ async function createLinkPath(
|
|
|
288
304
|
requiredDataLinkSteps,
|
|
289
305
|
perParentCombinations,
|
|
290
306
|
complexFilterCombinations,
|
|
291
|
-
|
|
307
|
+
valueUserTags,
|
|
292
308
|
filtersStructure,
|
|
293
309
|
path,
|
|
294
310
|
errorsObject,
|
|
295
311
|
errorsFound,
|
|
296
|
-
index
|
|
297
|
-
previousLinkId,
|
|
298
|
-
previousLink
|
|
312
|
+
index
|
|
299
313
|
});
|
|
300
314
|
let fieldName = null;
|
|
301
315
|
let returnValue = {}; //* must return only linkPath params
|
|
@@ -338,13 +352,14 @@ async function createLinkPath(
|
|
|
338
352
|
// console.log('---------- is next link ----------', hhhh);
|
|
339
353
|
}
|
|
340
354
|
|
|
341
|
-
let conditionsPromise = checkConditionsLink(
|
|
342
|
-
|
|
355
|
+
// let conditionsPromise = checkConditionsLink(
|
|
356
|
+
let [conditions, conditionErrObject, conditionErrFound] = await checkConditionsLink(
|
|
343
357
|
linkStep.pathLinkType.objType,
|
|
344
358
|
linkStep,
|
|
345
359
|
perParentCombinations,
|
|
346
360
|
complexFilterCombinations,
|
|
347
|
-
|
|
361
|
+
valueUserTags,
|
|
362
|
+
filtersStructure,
|
|
348
363
|
linkSteps,
|
|
349
364
|
requiredDataLinkStepObjects,
|
|
350
365
|
requiredDataLinkSteps,
|
|
@@ -352,14 +367,20 @@ async function createLinkPath(
|
|
|
352
367
|
errorsObject,
|
|
353
368
|
errorsFound
|
|
354
369
|
);
|
|
370
|
+
console.log('checkConditionsLink in link', {
|
|
371
|
+
conditions,
|
|
372
|
+
conditionErrObject,
|
|
373
|
+
conditionErrFound
|
|
374
|
+
});
|
|
355
375
|
|
|
356
376
|
[fieldName, returnValue, errorsObject, errorsFound, sortObj] = await createLinkPath(
|
|
377
|
+
linkStep.pathLinkType.objType,
|
|
357
378
|
linkSteps,
|
|
358
379
|
requiredDataLinkStepObjects,
|
|
359
380
|
requiredDataLinkSteps,
|
|
360
381
|
perParentCombinations,
|
|
361
382
|
complexFilterCombinations,
|
|
362
|
-
|
|
383
|
+
valueUserTags,
|
|
363
384
|
filtersStructure,
|
|
364
385
|
path,
|
|
365
386
|
errorsObject,
|
|
@@ -374,21 +395,25 @@ async function createLinkPath(
|
|
|
374
395
|
index
|
|
375
396
|
});
|
|
376
397
|
|
|
377
|
-
if (errorsFound.length > 0) {
|
|
378
|
-
return [null, null, errorsObject, errorsFound]
|
|
379
|
-
}
|
|
380
|
-
|
|
381
398
|
console.log('linkStep', linkStep);
|
|
382
399
|
|
|
383
|
-
let [conditions, conditionErrObject, conditionErrFound] = await conditionsPromise;
|
|
384
|
-
|
|
400
|
+
// let [conditions, conditionErrObject, conditionErrFound] = await conditionsPromise;
|
|
385
401
|
if (conditionErrFound.length > 0) {
|
|
386
402
|
Object.assign(errorsObject, conditionErrObject);
|
|
387
|
-
errorsFound = errorsFound.concat(conditionErrFound);
|
|
388
403
|
|
|
389
|
-
|
|
404
|
+
for (const conditionErr of conditionErrFound) {
|
|
405
|
+
if (!errorsFound.includes(conditionErr)) {
|
|
406
|
+
errorsFound.push(conditionErr);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
// errorsFound = errorsFound.concat(conditionErrFound);
|
|
410
|
+
// return [null, null, errorsObject, errorsFound]
|
|
390
411
|
};
|
|
391
412
|
|
|
413
|
+
if (errorsFound.length > 0) {
|
|
414
|
+
return [null, null, errorsObject, errorsFound];
|
|
415
|
+
}
|
|
416
|
+
|
|
392
417
|
if (!isEmpty(returnValue)) {
|
|
393
418
|
console.log('----------------- has returnValue ---------------------', { index, fieldName, returnValue, conditions })
|
|
394
419
|
|
|
@@ -397,13 +422,13 @@ async function createLinkPath(
|
|
|
397
422
|
}
|
|
398
423
|
|
|
399
424
|
if (conditions.hasOwnProperty('filterElements')) {
|
|
400
|
-
for (const filterElementId of Object.
|
|
425
|
+
for (const [filterElementId, filterElements] of Object.entries(conditions.filterElements)) {
|
|
401
426
|
linkStepObject.filterElementId = filterElementId;
|
|
402
427
|
|
|
403
428
|
if (returnValue.hasOwnProperty('filterElements')) {
|
|
404
|
-
Object.assign(returnValue['filterElements'],
|
|
429
|
+
Object.assign(returnValue['filterElements'], filterElements);
|
|
405
430
|
} else {
|
|
406
|
-
returnValue.filterElements = conditions.filterElements;
|
|
431
|
+
returnValue.filterElements = filterElements;// conditions.filterElements;
|
|
407
432
|
}
|
|
408
433
|
}
|
|
409
434
|
}
|
|
@@ -422,7 +447,7 @@ async function createLinkPath(
|
|
|
422
447
|
if (conditions.hasOwnProperty('linkPathObjects')) {
|
|
423
448
|
if (conditions.hasOwnProperty('linkStepObjects')) {
|
|
424
449
|
|
|
425
|
-
linkStepObject.
|
|
450
|
+
linkStepObject.requiredDataObjects = conditions.requiredDataFields;
|
|
426
451
|
|
|
427
452
|
if (returnValue.hasOwnProperty("sortFieldLinkPathObjects")) {
|
|
428
453
|
Object.assign(returnValue.sortFieldLinkPathObjects["linkPathObjects"], conditions.linkPathObjects);
|
|
@@ -507,6 +532,19 @@ async function createLinkPath(
|
|
|
507
532
|
};
|
|
508
533
|
};
|
|
509
534
|
|
|
535
|
+
if (conditions.hasOwnProperty("comparison")) {
|
|
536
|
+
if (conditions.hasOwnProperty("comparisonSortField")) {
|
|
537
|
+
if (conditions.hasOwnProperty("comparisonValue")) {
|
|
538
|
+
if (conditions.hasOwnProperty('comparisonSortDataType')) {
|
|
539
|
+
linkStepObject.comparison = conditions.comparison;
|
|
540
|
+
linkStepObject.comparisonSortField = conditions.comparisonSortField;
|
|
541
|
+
linkStepObject.comparisonSortDataType = conditions.comparisonSortDataType;
|
|
542
|
+
linkStepObject.comparisonValue = conditions.comparisonValue;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
510
548
|
console.log('linkStepObject', linkStepObject);
|
|
511
549
|
let linkStepId = hash(linkStepObject);
|
|
512
550
|
console.log('linkStepId', linkStepId);
|
|
@@ -525,9 +563,9 @@ async function createLinkPath(
|
|
|
525
563
|
};
|
|
526
564
|
|
|
527
565
|
if (conditions.hasOwnProperty('filterElements')) {
|
|
528
|
-
for (const filterElementId of Object.
|
|
566
|
+
for (const [filterElementId, filterElements] of Object.entries(conditions.filterElements)) {
|
|
529
567
|
linkStepObject.filterElementId = filterElementId;
|
|
530
|
-
returnValue.filterElements =
|
|
568
|
+
returnValue.filterElements = filterElements;
|
|
531
569
|
};
|
|
532
570
|
};
|
|
533
571
|
|
|
@@ -545,7 +583,7 @@ async function createLinkPath(
|
|
|
545
583
|
if (conditions.hasOwnProperty('linkPathObjects')) {
|
|
546
584
|
if (conditions.hasOwnProperty('linkStepObjects')) {
|
|
547
585
|
|
|
548
|
-
linkStepObject.
|
|
586
|
+
linkStepObject.requiredDataObjects = conditions.requiredDataFields;
|
|
549
587
|
|
|
550
588
|
if (returnValue.hasOwnProperty("sortFieldLinkPathObjects")) {
|
|
551
589
|
Object.assign(returnValue.sortFieldLinkPathObjects["linkPathObjects"], conditions.linkPathObjects);
|
|
@@ -570,15 +608,32 @@ async function createLinkPath(
|
|
|
570
608
|
if (conditions.hasOwnProperty("setFilterCombinations") && !isEmpty(conditions.setFilterCombinations)) {
|
|
571
609
|
|
|
572
610
|
if (conditions.setFilterCombinations.hasOwnProperty('filterElements')) {
|
|
573
|
-
|
|
611
|
+
if (returnValue.hasOwnProperty("filterElements")) {
|
|
612
|
+
Object.assign(returnValue["filterElements"], conditions.setFilterCombinations.filterElements);
|
|
613
|
+
} else {
|
|
614
|
+
returnValue.filterElements = {}
|
|
615
|
+
Object.assign(returnValue["filterElements"], conditions.setFilterCombinations.filterElements);
|
|
616
|
+
}
|
|
574
617
|
}
|
|
575
618
|
|
|
576
619
|
if (conditions.setFilterCombinations.hasOwnProperty('perParentCombinations')) {
|
|
577
|
-
Object.assign(returnValue["perParentCombinations"], conditions.perParentCombinations);
|
|
620
|
+
// Object.assign(returnValue["perParentCombinations"], conditions.perParentCombinations);
|
|
621
|
+
if (returnValue.hasOwnProperty("perParentCombinations")) {
|
|
622
|
+
Object.assign(returnValue["perParentCombinations"], conditions.setFilterCombinations.perParentCombinations);
|
|
623
|
+
} else {
|
|
624
|
+
returnValue.perParentCombinations = {}
|
|
625
|
+
Object.assign(returnValue["perParentCombinations"], conditions.setFilterCombinations.perParentCombinations);
|
|
626
|
+
}
|
|
578
627
|
};
|
|
579
628
|
|
|
580
629
|
if (conditions.setFilterCombinations.hasOwnProperty('complexFilterCombinations')) {
|
|
581
|
-
Object.assign(returnValue['complexFilterCombinations'], conditions.complexFilterCombinations);
|
|
630
|
+
// Object.assign(returnValue['complexFilterCombinations'], conditions.complexFilterCombinations);
|
|
631
|
+
if (returnValue.hasOwnProperty("complexFilterCombinations")) {
|
|
632
|
+
Object.assign(returnValue["complexFilterCombinations"], conditions.setFilterCombinations.complexFilterCombinations);
|
|
633
|
+
} else {
|
|
634
|
+
returnValue.complexFilterCombinations = {}
|
|
635
|
+
Object.assign(returnValue["complexFilterCombinations"], conditions.setFilterCombinations.complexFilterCombinations);
|
|
636
|
+
}
|
|
582
637
|
};
|
|
583
638
|
}
|
|
584
639
|
|
|
@@ -608,12 +663,16 @@ async function createLinkPath(
|
|
|
608
663
|
};
|
|
609
664
|
};
|
|
610
665
|
|
|
666
|
+
|
|
611
667
|
if (conditions.hasOwnProperty("comparison")) {
|
|
612
668
|
if (conditions.hasOwnProperty("comparisonSortField")) {
|
|
613
669
|
if (conditions.hasOwnProperty("comparisonValue")) {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
670
|
+
if (conditions.hasOwnProperty('comparisonSortDataType')) {
|
|
671
|
+
linkStepObject.comparison = conditions.comparison;
|
|
672
|
+
linkStepObject.comparisonSortField = conditions.comparisonSortField;
|
|
673
|
+
linkStepObject.comparisonSortDataType = conditions.comparisonSortDataType;
|
|
674
|
+
linkStepObject.comparisonValue = conditions.comparisonValue;
|
|
675
|
+
}
|
|
617
676
|
}
|
|
618
677
|
}
|
|
619
678
|
}
|
|
@@ -629,7 +688,7 @@ async function createLinkPath(
|
|
|
629
688
|
console.log('returnValue', returnValue);
|
|
630
689
|
}
|
|
631
690
|
}
|
|
632
|
-
return [fieldName, returnValue, errorsObject, errorsFound]
|
|
691
|
+
return [fieldName, returnValue, errorsObject, errorsFound, sortObj]
|
|
633
692
|
}
|
|
634
693
|
|
|
635
694
|
|
|
@@ -638,7 +697,7 @@ async function checkConditionsLink(
|
|
|
638
697
|
linkStepObject,
|
|
639
698
|
perParentCombinations,
|
|
640
699
|
complexFilterCombinations,
|
|
641
|
-
|
|
700
|
+
valueUserTags,
|
|
642
701
|
filtersStructure,
|
|
643
702
|
linkSteps,
|
|
644
703
|
requiredDataLinkStepObjects,
|
|
@@ -652,7 +711,7 @@ async function checkConditionsLink(
|
|
|
652
711
|
linkStepObject,
|
|
653
712
|
perParentCombinations,
|
|
654
713
|
complexFilterCombinations,
|
|
655
|
-
|
|
714
|
+
valueUserTags,
|
|
656
715
|
filtersStructure,
|
|
657
716
|
linkSteps,
|
|
658
717
|
requiredDataLinkStepObjects,
|
|
@@ -664,7 +723,8 @@ async function checkConditionsLink(
|
|
|
664
723
|
|
|
665
724
|
|
|
666
725
|
let conditionLinkObject = {};
|
|
667
|
-
let
|
|
726
|
+
let addFilterMainRequest = null;
|
|
727
|
+
let filterElements = null;
|
|
668
728
|
|
|
669
729
|
if (linkStepObject.hasOwnProperty("addFilterMain") && linkStepObject.addFilterMain === true) {
|
|
670
730
|
|
|
@@ -687,7 +747,25 @@ async function checkConditionsLink(
|
|
|
687
747
|
Object.assign(errorsObject, filterErrorObject);
|
|
688
748
|
errorsFound = errorsFound.concat('filterErrorFound');
|
|
689
749
|
} else {
|
|
690
|
-
|
|
750
|
+
|
|
751
|
+
let [complexFilterRequest, status, filterErrorsObject, filterErrorsFound] = filtersSharedLib.createFiltersRequest(
|
|
752
|
+
filterStructureCurrent.objType,
|
|
753
|
+
filterStructureCurrent.initialLogicalElementId,
|
|
754
|
+
filterStructureCurrent.logicalElements,
|
|
755
|
+
valueUserTags
|
|
756
|
+
);
|
|
757
|
+
console.log('return complexFilter for filterElements: ', {
|
|
758
|
+
complexFilterRequest,
|
|
759
|
+
status,
|
|
760
|
+
filterErrorsObject,
|
|
761
|
+
filterErrorsFound
|
|
762
|
+
});
|
|
763
|
+
|
|
764
|
+
if (filterErrorsFound.length > 0) {
|
|
765
|
+
Object.assign(errorsObject, filterErrorsObject)
|
|
766
|
+
errorsFound = errorsFound.concat(filterErrorsFound)
|
|
767
|
+
};
|
|
768
|
+
addFilterMainRequest = complexFilterRequest;
|
|
691
769
|
}
|
|
692
770
|
|
|
693
771
|
}
|
|
@@ -695,35 +773,19 @@ async function checkConditionsLink(
|
|
|
695
773
|
if (linkStepObject.hasOwnProperty('filterElements')) {
|
|
696
774
|
console.log('------------ has filterElements ------------');
|
|
697
775
|
|
|
698
|
-
let filters = {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
errorsObject[linkStepObject.filterElements.objType.objectType] = 'this linkStep has error when combine filterMain in link';
|
|
703
|
-
errorsFound.push(`${linkStepObject.filterElements.objType.objectType}: this linkStep has error when combine filterMain in link`);
|
|
704
|
-
return [null, errorsObject, errorsFound];
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
filters = filtersSharedLib.combineLogicalElements(
|
|
708
|
-
filterMainRequest,
|
|
709
|
-
linkStepObject.filterElements
|
|
710
|
-
);
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
} else {
|
|
714
|
-
filters = {
|
|
715
|
-
objType: linkStepObject.filterElements.objType,
|
|
716
|
-
initialLogicalElementId: linkStepObject.filterElements.initialLogicalElementId,
|
|
717
|
-
logicalElements: linkStepObject.filterElements.logicalElements,
|
|
718
|
-
}
|
|
776
|
+
let filters = {
|
|
777
|
+
objType: linkStepObject.filterElements.objType,
|
|
778
|
+
initialLogicalElementId: linkStepObject.filterElements.initialLogicalElementId,
|
|
779
|
+
logicalElements: linkStepObject.filterElements.logicalElements,
|
|
719
780
|
}
|
|
781
|
+
|
|
720
782
|
console.log('filters: ', filters);
|
|
721
783
|
|
|
722
784
|
let [complexFilterRequest, status, filterErrorsObject, filterErrorsFound] = filtersSharedLib.createFiltersRequest(
|
|
723
785
|
filters.objType,
|
|
724
786
|
filters.initialLogicalElementId,
|
|
725
787
|
filters.logicalElements,
|
|
726
|
-
|
|
788
|
+
valueUserTags
|
|
727
789
|
);
|
|
728
790
|
console.log('return complexFilter for filterElements: ', {
|
|
729
791
|
complexFilterRequest,
|
|
@@ -737,36 +799,55 @@ async function checkConditionsLink(
|
|
|
737
799
|
errorsFound = errorsFound.concat(filterErrorsFound)
|
|
738
800
|
};
|
|
739
801
|
|
|
740
|
-
|
|
741
|
-
|
|
802
|
+
filterElements = complexFilterRequest;
|
|
803
|
+
}
|
|
742
804
|
|
|
805
|
+
if (!conditionLinkObject.hasOwnProperty("filterElements")) {
|
|
806
|
+
conditionLinkObject.filterElements = {};
|
|
743
807
|
}
|
|
744
808
|
|
|
809
|
+
if (addFilterMainRequest !== null) {
|
|
810
|
+
if (filterElements !== null) {
|
|
745
811
|
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
812
|
+
let combineLogicalElements = Object.assign(addFilterMainRequest.filterElements, filterElements.filterElements);
|
|
813
|
+
console.log('combineLogicalElements: ', combineLogicalElements);
|
|
814
|
+
|
|
815
|
+
// create new operation FilterObject
|
|
816
|
+
let operationFilterObject = {
|
|
817
|
+
objType: objType,
|
|
818
|
+
filterElement: {
|
|
819
|
+
filterType: "operation",
|
|
820
|
+
filterElements: combineLogicalElements,
|
|
821
|
+
filterElementLeft: addFilterMainRequest.filterMainId,
|
|
822
|
+
filterElementRight: filterElements.filterMainId,
|
|
823
|
+
operator: "AND"
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
console.log("operationFilterObject", operationFilterObject);
|
|
827
|
+
|
|
828
|
+
let operationFilterMainId = hash(operationFilterObject);
|
|
829
|
+
console.log("==== validate operationFilterMainId After Hash =====", operationFilterMainId);
|
|
830
|
+
|
|
831
|
+
delete operationFilterObject.filterElement.filterElements;
|
|
832
|
+
|
|
833
|
+
combineLogicalElements = Object.assign(combineLogicalElements, { [operationFilterMainId]: operationFilterObject });
|
|
834
|
+
|
|
835
|
+
conditionLinkObject.filterElements = {
|
|
836
|
+
[operationFilterMainId]: combineLogicalElements
|
|
837
|
+
};
|
|
838
|
+
|
|
839
|
+
} else {
|
|
840
|
+
conditionLinkObject.filterElements = {
|
|
841
|
+
[addFilterMainRequest.filterMainId]: addFilterMainRequest.filterElements
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
} else {
|
|
845
|
+
if (filterElements !== null) {
|
|
846
|
+
conditionLinkObject.filterElements = {
|
|
847
|
+
[filterElements.filterMainId]: filterElements.filterElements
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
}
|
|
770
851
|
|
|
771
852
|
if (linkStepObject.hasOwnProperty('aggregate')) {
|
|
772
853
|
console.log('------------ has aggregate ------------');
|
|
@@ -798,19 +879,23 @@ async function checkConditionsLink(
|
|
|
798
879
|
for (const sortField of linkStepObject.sortFields) {
|
|
799
880
|
console.log('sortField: ', sortField);
|
|
800
881
|
console.log('requiredDataLinkSteps: ', requiredDataLinkSteps);
|
|
882
|
+
console.log('requiredDataLinkStepObjects: ', requiredDataLinkStepObjects);
|
|
801
883
|
let requiredDataLinkStepSortField = requiredDataLinkStepObjects[sortField.requiredDataLinkStepObjectId];
|
|
802
884
|
console.log('requiredDataLinkStepSortField: ', requiredDataLinkStepSortField);
|
|
803
|
-
|
|
804
|
-
|
|
885
|
+
console.log(' requiredDataLinkStepSortField.linkSteps: ', {
|
|
886
|
+
linkSteps: requiredDataLinkStepSortField.linkSteps,
|
|
887
|
+
requiredDataLinkStepSortField: requiredDataLinkStepSortField
|
|
888
|
+
});
|
|
805
889
|
|
|
806
890
|
//* make all linkPath in here and send out to combine allLinkPath
|
|
807
|
-
let [fieldName, childLinkStep, linkErrorsObject, linkErrorsFound] = await createLinkPath(
|
|
891
|
+
let [fieldName, childLinkStep, linkErrorsObject, linkErrorsFound, sortObj] = await createLinkPath(
|
|
892
|
+
linkStepObject.pathLinkType.objType,
|
|
808
893
|
requiredDataLinkStepSortField.linkSteps,
|
|
809
894
|
requiredDataLinkStepObjects,
|
|
810
895
|
requiredDataLinkSteps,
|
|
811
896
|
perParentCombinations,
|
|
812
897
|
complexFilterCombinations,
|
|
813
|
-
|
|
898
|
+
valueUserTags,
|
|
814
899
|
filtersStructure,
|
|
815
900
|
[],
|
|
816
901
|
errorsObject,
|
|
@@ -820,7 +905,8 @@ async function checkConditionsLink(
|
|
|
820
905
|
fieldName,
|
|
821
906
|
childLinkStep,
|
|
822
907
|
linkErrorsObject,
|
|
823
|
-
linkErrorsFound
|
|
908
|
+
linkErrorsFound,
|
|
909
|
+
sortObj
|
|
824
910
|
});
|
|
825
911
|
|
|
826
912
|
if (linkErrorsFound > 0) {
|
|
@@ -874,7 +960,6 @@ async function checkConditionsLink(
|
|
|
874
960
|
requiredDataFields.push({
|
|
875
961
|
fieldName: fieldName,
|
|
876
962
|
linkPathObjectId: pathId,
|
|
877
|
-
// dataType: sortField.dataType
|
|
878
963
|
});
|
|
879
964
|
|
|
880
965
|
} else {
|
|
@@ -883,15 +968,33 @@ async function checkConditionsLink(
|
|
|
883
968
|
});
|
|
884
969
|
};
|
|
885
970
|
|
|
971
|
+
if (!sortField.hasOwnProperty("dataType")) {
|
|
972
|
+
errorsFound.push(`${objType.objectType}: this sortField of linkStep is not set dataType`);
|
|
973
|
+
errorsObject = {
|
|
974
|
+
[objType.objectType]: 'this sortField of linkStep is not set dataType'
|
|
975
|
+
};
|
|
976
|
+
return [null, errorsObject, errorsFound]
|
|
977
|
+
}
|
|
978
|
+
|
|
886
979
|
let sortObject = {
|
|
887
980
|
fieldName: fieldName,
|
|
888
|
-
|
|
981
|
+
dataType: sortField.dataType
|
|
889
982
|
}
|
|
890
983
|
|
|
891
|
-
if (
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
984
|
+
if (sortField.dataType === "array") {
|
|
985
|
+
|
|
986
|
+
if (isEmpty(sortField.sortByValueUserTags)) {
|
|
987
|
+
errorsFound.push(`${objType.objectType}: sortField has sortByValueUserTags is empty`);
|
|
988
|
+
errorsObject = {
|
|
989
|
+
[objType.objectType]: 'sortField has sortByValueUserTags is empty'
|
|
990
|
+
}
|
|
991
|
+
return [null, errorsObject, errorsFound]
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
sortObject.values = [];
|
|
995
|
+
let sortArrays = sortField.sortByValueUserTags;
|
|
996
|
+
for (let sort of sortArrays) {
|
|
997
|
+
sortObject.values.push(valueUserTags[sort].value);
|
|
895
998
|
}
|
|
896
999
|
}
|
|
897
1000
|
|
|
@@ -939,7 +1042,7 @@ async function checkConditionsLink(
|
|
|
939
1042
|
|
|
940
1043
|
for (const [tag, requestPropertyId] of Object.entries(linkStepObject.requestProperties)) {
|
|
941
1044
|
console.log('extract requestProperties', { tag, requestPropertyId });
|
|
942
|
-
let requestPropertyObject =
|
|
1045
|
+
let requestPropertyObject = valueUserTags[requestPropertyId];
|
|
943
1046
|
console.log('extract requestProperties', requestPropertyObject);
|
|
944
1047
|
|
|
945
1048
|
|
|
@@ -955,7 +1058,7 @@ async function checkConditionsLink(
|
|
|
955
1058
|
perParentCombinationObject.objType,
|
|
956
1059
|
perParentCombinationObject.initialLogicalElementId,
|
|
957
1060
|
perParentCombinationObject.logicalElements,
|
|
958
|
-
|
|
1061
|
+
valueUserTags,
|
|
959
1062
|
);
|
|
960
1063
|
console.log('return complexFilter for perParentCombinations: ', {
|
|
961
1064
|
complexFilterRequest,
|
|
@@ -996,7 +1099,7 @@ async function checkConditionsLink(
|
|
|
996
1099
|
complexFilterCombinationObject.objType,
|
|
997
1100
|
complexFilterCombinationObject.initialLogicalElementId,
|
|
998
1101
|
complexFilterCombinationObject.logicalElements,
|
|
999
|
-
|
|
1102
|
+
valueUserTags
|
|
1000
1103
|
);
|
|
1001
1104
|
console.log('return complexFilter for complexFilterCombinations: ', {
|
|
1002
1105
|
complexFilterRequest,
|
|
@@ -1016,7 +1119,6 @@ async function checkConditionsLink(
|
|
|
1016
1119
|
applyCombinations.push({
|
|
1017
1120
|
tag: tag,
|
|
1018
1121
|
filterMainId: complexFilterRequest.filterMainId,
|
|
1019
|
-
// identifiersFieldName: requestPropertyObject.identifierFieldName
|
|
1020
1122
|
});
|
|
1021
1123
|
console.log('applyCombinations: ', applyCombinations);
|
|
1022
1124
|
|
|
@@ -1027,7 +1129,6 @@ async function checkConditionsLink(
|
|
|
1027
1129
|
filterElements: complexFilterRequest.filterElements
|
|
1028
1130
|
}
|
|
1029
1131
|
});
|
|
1030
|
-
// Object.assign(perParentCombinationObjects, complexFilterRequest.filterElements);
|
|
1031
1132
|
};
|
|
1032
1133
|
|
|
1033
1134
|
} else {
|
|
@@ -1035,15 +1136,15 @@ async function checkConditionsLink(
|
|
|
1035
1136
|
if (isEmpty(conditionLinkObject)) {
|
|
1036
1137
|
conditionLinkObject = {
|
|
1037
1138
|
requestProperties: {
|
|
1038
|
-
[tag]:
|
|
1139
|
+
[tag]: valueUserTags[requestPropertyId].value
|
|
1039
1140
|
}
|
|
1040
1141
|
};
|
|
1041
1142
|
} else {
|
|
1042
1143
|
if (conditionLinkObject.hasOwnProperty('requestProperties')) {
|
|
1043
|
-
conditionLinkObject.requestProperties[tag] =
|
|
1144
|
+
conditionLinkObject.requestProperties[tag] = valueUserTags[requestPropertyId].value;
|
|
1044
1145
|
} else {
|
|
1045
1146
|
conditionLinkObject['requestProperties'] = {
|
|
1046
|
-
[tag]:
|
|
1147
|
+
[tag]: valueUserTags[requestPropertyId].value
|
|
1047
1148
|
};
|
|
1048
1149
|
};
|
|
1049
1150
|
};
|
|
@@ -1075,15 +1176,16 @@ async function checkConditionsLink(
|
|
|
1075
1176
|
if (linkStepObject.hasOwnProperty("comparison")) {
|
|
1076
1177
|
console.log('------------ link has comparison ------------');
|
|
1077
1178
|
|
|
1078
|
-
if (!linkStepObject.hasOwnProperty(
|
|
1079
|
-
errorsObject[objType.objectType] = 'no comparisonSortField | comparisonValue';
|
|
1080
|
-
errorsFound.push(`${objType.objectType}: no comparisonSortField | comparisonValue`);
|
|
1179
|
+
if (!linkStepObject.hasOwnProperty('comparisonSortField') || !linkStepObject.hasOwnProperty('comparisonValue') || !linkStepObject.hasOwnProperty('comparisonSortDataType')) {
|
|
1180
|
+
errorsObject[objType.objectType] = 'no comparisonSortField | comparisonValue | comparisonSortDataType';
|
|
1181
|
+
errorsFound.push(`${objType.objectType}: no comparisonSortField | comparisonValue | comparisonSortDataType`);
|
|
1081
1182
|
return [null, errorsObject, errorsFound]
|
|
1082
1183
|
}
|
|
1083
1184
|
|
|
1084
1185
|
conditionLinkObject.comparison = linkStepObject.comparison;
|
|
1085
1186
|
conditionLinkObject.comparisonSortField = linkStepObject.comparisonSortField;
|
|
1086
|
-
conditionLinkObject.
|
|
1187
|
+
conditionLinkObject.comparisonSortDataType = linkStepObject.comparisonSortDataType;
|
|
1188
|
+
conditionLinkObject.comparisonValue = valueUserTags[linkStepObject.comparisonValue].value;
|
|
1087
1189
|
|
|
1088
1190
|
}
|
|
1089
1191
|
|
|
@@ -1166,15 +1268,7 @@ function checkMultipleIdentifers(
|
|
|
1166
1268
|
linkConfig = {},
|
|
1167
1269
|
conditions = {},
|
|
1168
1270
|
multipleIdentifiers = false,
|
|
1169
|
-
//
|
|
1170
1271
|
) {
|
|
1171
|
-
// conditions: {
|
|
1172
|
-
// aggregate ,
|
|
1173
|
-
// comparison,
|
|
1174
|
-
// combine ,
|
|
1175
|
-
// applyCombinations ,
|
|
1176
|
-
// multipleIdentifiers,
|
|
1177
|
-
// }
|
|
1178
1272
|
|
|
1179
1273
|
let manyIdentifiers = null;
|
|
1180
1274
|
|