@izara_frontend/shared-complex-filter 1.0.1

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.
@@ -0,0 +1,1341 @@
1
+ import React, { useState, useEffect, useCallback, useMemo } from "react";
2
+ import { useImmer } from "use-immer";
3
+ import {
4
+ IzaraDivStyle,
5
+ IzaraButtonStyle,
6
+ createStyleDefualtTags,
7
+ createStyleTags,
8
+ } from "@izaraFrontends/styles";
9
+ import { useDispatch, useSelector } from "react-redux";
10
+ // import { DataFieldsSharedLib } from "@izara_project/izara-shared-search-and-sort";
11
+ import { DataFieldsSharedLib } from "@izara_project/izara-shared-search-and-sort";
12
+ import { ModalLinkStepsComponent } from "../linkSteps/modalLinkStepsComponent.jsx";
13
+ import { ModalComplexFilterComponent } from "./modalComplexFilterComponent.jsx";
14
+ import { utils as sharedSchemaUtils } from "@izara_project/izara-shared-service-schemas";
15
+
16
+ var hash = require("object-hash");
17
+
18
+ function createObjTypeConcat(objType) {
19
+ console.log("objType:dfcvcbcxb ", objType);
20
+
21
+ return `${objType.serviceTag}_${objType.objectType}`;
22
+ }
23
+ function createRelTypeConcat(relType) {
24
+ console.log("objType:sdsadwsd ", relType);
25
+ return `${relType?.serviceTag}_${relType?.relationshipTag}`;
26
+ }
27
+ function objTypeFromObjTypeConcat(objTypeConcat) {
28
+ console.log("objTypeConcat:aeaeaeww ", objTypeConcat);
29
+ let result = objTypeConcat.split("_");
30
+
31
+ if (result.length !== 2) {
32
+ throw Error("objTypeConcat invalid");
33
+ }
34
+
35
+ return {
36
+ serviceTag: result[0],
37
+ objectType: result[1],
38
+ };
39
+ }
40
+
41
+ export const MainCaseUseConditionAndMultipleIdentifersComponent = ({
42
+ titleModal,
43
+ statusModalFunc,
44
+ objConfigUseCase,
45
+ objTypeMain,
46
+ nameReducer,
47
+ parentOutputId,
48
+ valueUserTags,
49
+ // valueUserTags, not sure
50
+ successFunc,
51
+ collectObjectLinksWithRequestProperties,
52
+ collectObjectSchemaWithHierarchy,
53
+ //useCase--------------------------------
54
+ nameObjectLinkStepEdit,
55
+ keyElement,
56
+ LastStepsComponentUseCase,
57
+ }) => {
58
+ //-----------------------state---------------------------------------
59
+ // const [nameObjectLinkStep, setNameObjectLinkStep] = useState(
60
+ // nameObjectLinkStepEdit,
61
+ // );
62
+
63
+ //--------------------------------------------------------------
64
+
65
+ //-----------------------Shared function-----------------------------------
66
+
67
+ //-----------------------End Shared function-----------------------------------
68
+ const dispatch = useDispatch();
69
+
70
+ console.log("objTypeMain:xczczxvv ", objTypeMain);
71
+ function submitLinkSteps() {}
72
+
73
+ function validateRequestProperties() {
74
+ if (linkSteps[linkStepsOutput.active]?.requestProperties) {
75
+ for (const key in linkSteps[linkStepsOutput.active].requestProperties) {
76
+ if (!linkSteps[linkStepsOutput.active].requestProperties[key]) {
77
+ alert("please select " + key + " requestProperties");
78
+ return false;
79
+ }
80
+ }
81
+ }
82
+ return true;
83
+ }
84
+
85
+ //----------------------func prop---------------------------------
86
+
87
+ // function handleInputNameLinkStep(e) {
88
+ // setNameObjectLinkStep(e.target.value);
89
+ // }
90
+
91
+ //----------------------func prop---------------------------------
92
+
93
+ console.log("nameReducer:sdxcvzxvcxv ", nameReducer);
94
+ console.log("component ssswxvcxz");
95
+ return (
96
+ <>
97
+ <ModalLinkStepsComponent
98
+ titleModal={titleModal}
99
+ statusModalFunc={statusModalFunc}
100
+ objConfigUseCase={objConfigUseCase}
101
+ objTypeMain={objTypeMain}
102
+ nameReducer={nameReducer}
103
+ parentOutputId={parentOutputId}
104
+ successFunc={successFunc}
105
+ collectObjectLinksWithRequestProperties={
106
+ collectObjectLinksWithRequestProperties
107
+ }
108
+ collectObjectSchemaWithHierarchy={collectObjectSchemaWithHierarchy}
109
+ //---------------use case----------------------------
110
+ keyElement={keyElement}
111
+ // nameObjectLinkStep={nameObjectLinkStep}
112
+ //------------------------------------------
113
+ // funcUseCase={{ handleInputNameLinkStep, validateRequestProperties }}
114
+ ComponentUseCase={ConditionLinkStepAndMultipleIdentifersComponent}
115
+ LastStepsComponentUseCase={LastStepsComponentUseCase}
116
+ valueUserTags={valueUserTags}
117
+ nameObjectLinkStepEdit={nameObjectLinkStepEdit}
118
+ // keyObjectUseCase
119
+ />
120
+ </>
121
+ );
122
+ };
123
+
124
+ export const ConditionLinkStepAndMultipleIdentifersComponent = ({
125
+ allObjTypesLinkConfigs,
126
+ resultFieldName,
127
+ linkSteps,
128
+ nameReducer,
129
+ parentOutputId,
130
+ setLinkSteps,
131
+ linkStepsOutput,
132
+ objTypeMain,
133
+ valueUserTags,
134
+ objConfigUseCase,
135
+ collectObjectLinksWithRequestProperties,
136
+ collectObjectSchemaWithHierarchy,
137
+ LastStepsComponentUseCase,
138
+ }) => {
139
+ const { checkConditionsLinkStep, checkMultipleIdentifers } =
140
+ DataFieldsSharedLib;
141
+ const [modalSortField, setModalSortField] = useState(false);
142
+ const [modalComplexFilter, setModalComplexFilter] = useState(false);
143
+ const [modalUseCase, setModalUseCase] = useState(false);
144
+ const [newUserTags, setNewUserTags] = useImmer({}); //not sure
145
+
146
+ function statusModalSortField(status) {
147
+ setModalSortField(status);
148
+ }
149
+
150
+ function statusModalComplexFilter(status) {
151
+ setModalComplexFilter(status);
152
+ }
153
+
154
+ function checkObjTypeLinkStep(activeIndex) {
155
+ let objTypeConcat; // objTypeConcat
156
+ objTypeConcat = createObjTypeConcat(objTypeMain);
157
+ if (activeIndex !== 0) {
158
+ objTypeConcat = createObjTypeConcat(
159
+ linkSteps[activeIndex - 1].pathLinkType.objType,
160
+ );
161
+ }
162
+ return objTypeConcat;
163
+ }
164
+
165
+ function conditionsObject(indexLinkStep) {
166
+ let conditions = {};
167
+
168
+ if (linkSteps[indexLinkStep - 1].hasOwnProperty("aggregate")) {
169
+ conditions.aggregate = true;
170
+ }
171
+ if (linkSteps[indexLinkStep - 1].hasOwnProperty("comparison")) {
172
+ conditions.comparison = true;
173
+ }
174
+ if (linkSteps[indexLinkStep - 1].hasOwnProperty("combine")) {
175
+ conditions.combine = linkSteps[indexLinkStep - 1].combine;
176
+ }
177
+
178
+ if (linkSteps[indexLinkStep - 1].hasOwnProperty("requestProperties")) {
179
+ for (const keyRequestProperties in linkSteps[indexLinkStep - 1]
180
+ .requestProperties)
181
+ if (
182
+ valueUserTags[
183
+ linkSteps[indexLinkStep - 1].requestProperties[keyRequestProperties]
184
+ ].hasOwnProperty("complexFilterCombinationId")
185
+ ) {
186
+ (console.log("dhawdshffaf"), linkSteps);
187
+ conditions.applyCombinations = true;
188
+ }
189
+ }
190
+
191
+ return conditions;
192
+ }
193
+
194
+ function checkMultipleIdentifersResult() {
195
+ let resultCheckMultipleIdentifers = false;
196
+ let linkConfig = null;
197
+
198
+ for (
199
+ let indexLinkStep = 0;
200
+ indexLinkStep < linkSteps.length;
201
+ indexLinkStep++
202
+ ) {
203
+ if (indexLinkStep !== 0) {
204
+ let conditions = conditionsObject(indexLinkStep);
205
+
206
+ let linkTypeId = sharedSchemaUtils.createPathLinkTypeId(
207
+ linkSteps[indexLinkStep - 1]?.pathLinkType,
208
+ );
209
+
210
+ if (
211
+ allObjTypesLinkConfigs[
212
+ createObjTypeConcat(
213
+ indexLinkStep === 1
214
+ ? objTypeMain
215
+ : linkSteps[indexLinkStep - 2]?.pathLinkType.objType,
216
+ )
217
+ ]
218
+ ) {
219
+ linkConfig =
220
+ allObjTypesLinkConfigs[
221
+ createObjTypeConcat(
222
+ indexLinkStep === 1
223
+ ? objTypeMain
224
+ : linkSteps[indexLinkStep - 2]?.pathLinkType.objType,
225
+ )
226
+ ][
227
+ allObjTypesLinkConfigs[
228
+ createObjTypeConcat(
229
+ indexLinkStep === 1
230
+ ? objTypeMain
231
+ : linkSteps[indexLinkStep - 2]?.pathLinkType.objType,
232
+ ) + "_pathLinkTypeIdIndex"
233
+ ][linkTypeId?.result]
234
+ ];
235
+ }
236
+
237
+ resultCheckMultipleIdentifers = checkMultipleIdentifers(
238
+ linkConfig, //link ก่่อนหน้า active -1
239
+ conditions,
240
+ resultCheckMultipleIdentifers,
241
+ );
242
+
243
+ if (linkStepsOutput.active === indexLinkStep) {
244
+ return resultCheckMultipleIdentifers;
245
+ }
246
+ }
247
+ }
248
+ }
249
+
250
+ function outputResultCheckConditionsLinkStep(index) {
251
+ let objTypeConcat = checkObjTypeLinkStep(linkStepsOutput.active);
252
+
253
+ let combine = false;
254
+
255
+ if (linkSteps[linkStepsOutput.active - 1]?.combine) {
256
+ combine = true;
257
+ }
258
+
259
+ let resultCheckConditionsLinkStep = checkConditionsLinkStep(
260
+ checkMultipleIdentifersResult(),
261
+ allObjTypesLinkConfigs[objTypeConcat][index],
262
+ combine,
263
+ );
264
+
265
+ return resultCheckConditionsLinkStep;
266
+ }
267
+
268
+ function handleConditionLinkSteps(type, value) {
269
+ // let value = e.target.value;
270
+
271
+ setLinkSteps((linkSteps) => {
272
+ if (value === "none") {
273
+ delete linkSteps[linkStepsOutput.active][type];
274
+ if (type === "aggregate") {
275
+ delete linkSteps[linkStepsOutput.active].sortFields;
276
+ }
277
+ } else {
278
+ if (type === "comparisonSortField") {
279
+ let dataType;
280
+ console.log(
281
+ "sadawdsd",
282
+ resultFieldName[
283
+ createObjTypeConcat(
284
+ linkSteps[linkStepsOutput.active].pathLinkType.objType,
285
+ )
286
+ ].fieldNames[value],
287
+ );
288
+ switch (
289
+ resultFieldName[
290
+ createObjTypeConcat(
291
+ linkSteps[linkStepsOutput.active].pathLinkType.objType,
292
+ )
293
+ ].fieldNames[value].type
294
+ ) {
295
+ case "integer":
296
+ case "number":
297
+ case "currencyValue":
298
+ dataType = "number";
299
+ break;
300
+
301
+ case "currency":
302
+ case "string":
303
+ dataType = "string";
304
+ break;
305
+
306
+ // default:
307
+ // dataType = "string";
308
+ }
309
+
310
+ linkSteps[linkStepsOutput.active].comparisonDataType = dataType;
311
+ }
312
+ linkSteps[linkStepsOutput.active][type] = value;
313
+ if (type === "aggregate") {
314
+ if (!linkSteps[linkStepsOutput.active]?.sortFields) {
315
+ linkSteps[linkStepsOutput.active].sortFields = [];
316
+ }
317
+ }
318
+ }
319
+
320
+ if (linkStepsOutput.active + 1 !== linkSteps.length) {
321
+ linkSteps = linkSteps.splice(
322
+ linkStepsOutput.active - linkSteps.length + 1,
323
+ );
324
+ }
325
+ });
326
+ }
327
+
328
+ function handleSelectSortOrder(e, idSortField) {
329
+ let value = e.target.value;
330
+ setLinkSteps((linkSteps) => {
331
+ linkSteps[linkStepsOutput.active].sortFields[idSortField].sortOrder =
332
+ value;
333
+ });
334
+ }
335
+ function handleNewOrEditFilter() {
336
+ statusModalUseCase("filterElements");
337
+ }
338
+
339
+ const COMPARISON = [
340
+ "equals",
341
+ "greaterThan",
342
+ "greaterThanEquals",
343
+ "lessThan",
344
+ "lessThanEquals",
345
+ "highLow",
346
+ "high",
347
+ "low",
348
+ "izaraSyntax",
349
+ ];
350
+
351
+ // valueUserTags not sure if need to be here
352
+ function handleValueSelect(e, key) {
353
+ let value = e.target.value;
354
+
355
+ if (value === "createUserTag") {
356
+ setLinkSteps((linkSteps) => {
357
+ linkSteps[linkStepsOutput.active].requestProperties[key] = null;
358
+ });
359
+ setNewUserTags((newUserTags) => {
360
+ newUserTags[key] = { name: "", obj: { defaultValue: "" } };
361
+ });
362
+ } else {
363
+ setLinkSteps((linkSteps) => {
364
+ linkSteps[linkStepsOutput.active].requestProperties[key] = value;
365
+ });
366
+
367
+ setNewUserTags((newUserTags) => {
368
+ delete newUserTags[key];
369
+ });
370
+ }
371
+ // setNewUserTags({});
372
+ }
373
+
374
+ function handleRequestPropertiesSelect(e, key) {
375
+ let type = e.target.value;
376
+ let objUserTag = {};
377
+
378
+ if (type === "defaultValue") {
379
+ objUserTag = {
380
+ defaultValue: "",
381
+ };
382
+ }
383
+
384
+ if (type === "complexFilterCombination") {
385
+ objUserTag = {
386
+ valueSource: "complexFilterCombination",
387
+ };
388
+ }
389
+ if (type === "perParentCombination") {
390
+ objUserTag = {
391
+ valueSource: "perParentCombination",
392
+ };
393
+ }
394
+
395
+ setNewUserTags((newUserTags) => {
396
+ newUserTags[key].name = "";
397
+ newUserTags[key].obj = objUserTag;
398
+ });
399
+ }
400
+
401
+ function handleChangeNameUserTag(e, key) {
402
+ let value = e.target.value;
403
+ setNewUserTags((newUserTags) => {
404
+ newUserTags[key].name = value;
405
+ });
406
+ }
407
+
408
+ function handleCreateuserTagTypeValue(e, key) {
409
+ if (
410
+ newUserTags[key].name === "" ||
411
+ newUserTags[key].obj.defaultValue === ""
412
+ ) {
413
+ alert("please fill in name and defaultValue");
414
+ } else {
415
+ setLinkSteps((linkSteps) => {
416
+ linkSteps[linkStepsOutput.active].requestProperties[key] =
417
+ newUserTags[key].name;
418
+ });
419
+
420
+ // setValueDataUserTags((valueDataUserTags) => {
421
+ // valueDataUserTags[newUserTags[key].name] = {
422
+ // defaultValue: newUserTags[key].obj.defaultValue,
423
+ // };
424
+ // });
425
+
426
+ setNewUserTags((newUserTags) => {
427
+ delete newUserTags[key];
428
+ });
429
+ }
430
+ }
431
+
432
+ function createFilterElement(
433
+ objType,
434
+ initialLogicalElementId,
435
+ logicalElementObj,
436
+ ) {
437
+ setLinkSteps((linkSteps) => {
438
+ linkSteps[linkStepsOutput.active].filterElements = {
439
+ objType: objType,
440
+ initialLogicalElementId: initialLogicalElementId,
441
+ logicalElements: logicalElementObj,
442
+ };
443
+ });
444
+ }
445
+
446
+ function handleCreateUserTagComplexOrPerParent(key, type) {
447
+ if (newUserTags[key].name === "") {
448
+ alert("please fill in name");
449
+ } else {
450
+ statusModalUseCase(type);
451
+ }
452
+ }
453
+
454
+ function statusModalUseCase(type) {
455
+ if (
456
+ type === "complexFilterCombination" ||
457
+ type === "perParentCombination"
458
+ ) {
459
+ setModalUseCase(type);
460
+ } else {
461
+ setModalUseCase(type);
462
+ }
463
+ }
464
+
465
+ function createComplexFilterCombinations(
466
+ objTypeConcat,
467
+ initialLogicalElementId,
468
+ filterElement,
469
+ valueDataUserTagsNew,
470
+ keyUseCase,
471
+ ) {
472
+ console.log("newUserTags:dfgxvxvx ", newUserTags, keyUseCase);
473
+ let objComplexFilterCombination = {};
474
+
475
+ objComplexFilterCombination = {
476
+ objType: objTypeFromObjTypeConcat(objTypeConcat),
477
+ initialLogicalElementId: initialLogicalElementId,
478
+ logicalElements: filterElement,
479
+ };
480
+
481
+ let hashComplexFilterCombination = hash(objComplexFilterCombination);
482
+
483
+ console.log(
484
+ "objComplexFilterCombination: fdfcgrtgd",
485
+ objComplexFilterCombination,
486
+ );
487
+
488
+ // setComplexFilterCombinations((complexFilterCombinations) => {
489
+ // delete complexFilterCombinations[
490
+ // valueDataUserTags[
491
+ // requiredDataLinkStep[requiredDataOutput.active].requestProperties[
492
+ // keyUseCase
493
+ // ]
494
+ // ]?.complexFilterCombinationId
495
+ // ];
496
+ // complexFilterCombinations[hashComplexFilterCombination] =
497
+ // objComplexFilterCombination;
498
+ // });
499
+
500
+ // setRequiredDataLinkStep((requiredDataLinkStep) => {
501
+ // requiredDataLinkStep[requiredDataOutput.active].requestProperties[
502
+ // keyUseCase
503
+ // ] = newUserTags[keyUseCase].name;
504
+ // });
505
+ }
506
+
507
+ let testAA = [];
508
+ let testBB = [];
509
+
510
+ testAA;
511
+
512
+ function successFuncCreateSortField(
513
+ parentOutputId,
514
+ sortLinkSteps,
515
+ objTypeMain,
516
+ nameLinkSteps,
517
+ dataType,
518
+ ) {
519
+ console.log("sortObj:sdccvxxcv ", sortLinkSteps);
520
+ let linkStepsArr = [];
521
+ for (const index in sortLinkSteps) {
522
+ let linkStepObj = sortLinkSteps[index];
523
+
524
+ let hashRequiredData = hash(linkStepObj);
525
+
526
+ linkStepsArr.push(hashRequiredData);
527
+ }
528
+
529
+ setLinkSteps((linkSteps) => {
530
+ linkSteps[linkStepsOutput.active].sortFields.push({
531
+ requiredDataLinkStepObjectId: nameLinkSteps,
532
+ dataType: dataType,
533
+ });
534
+ });
535
+ }
536
+
537
+ console.log(modalSortField, "modalSortField:widixcaeews");
538
+ return (
539
+ <>
540
+ {allObjTypesLinkConfigs[
541
+ linkStepsOutput.active === 0
542
+ ? createObjTypeConcat(objTypeMain)
543
+ : createObjTypeConcat(
544
+ linkSteps[linkStepsOutput.active - 1].pathLinkType.objType,
545
+ )
546
+ ].map((data, indexLink) => (
547
+ <div>
548
+ {_.isEqual(
549
+ data.relType,
550
+ linkSteps[linkStepsOutput.active]?.pathLinkType.relType,
551
+ ) && (
552
+ <>
553
+ {Object.entries(
554
+ outputResultCheckConditionsLinkStep(indexLink),
555
+ ).map(([key, value]) => (
556
+ <>
557
+ {key === "canAggregateCompare" && value && (
558
+ <div>
559
+ <fieldset>
560
+ <legend>aggregate</legend>
561
+ <select
562
+ onChange={(e) =>
563
+ handleConditionLinkSteps(
564
+ "aggregate",
565
+ e.target.value,
566
+ )
567
+ }
568
+ value={linkSteps[linkStepsOutput.active]?.aggregate}
569
+ >
570
+ <option value={null}>none</option>
571
+ <option value={"max"}>max</option>
572
+ <option value={"min"}>min</option>
573
+ <option value={"average"}>average</option>
574
+ </select>
575
+ </fieldset>
576
+ {linkSteps[linkStepsOutput.active]?.aggregate && (
577
+ <>
578
+ <IzaraButtonStyle
579
+ styletags={createStyleDefualtTags(
580
+ "modal",
581
+ "",
582
+ "button",
583
+ )}
584
+ onClick={(e) => statusModalSortField(true)}
585
+ >
586
+ create sortField
587
+ </IzaraButtonStyle>
588
+ {linkSteps[linkStepsOutput.active]?.sortFields && (
589
+ <>
590
+ {linkSteps[
591
+ linkStepsOutput.active
592
+ ]?.sortFields.map((data, idSortField) => (
593
+ <li>
594
+ {data.linkStepsObjectId}
595
+ <p>data Type</p>
596
+ <select
597
+ onChange={(e) =>
598
+ handleSelectDataType(e, idSortField)
599
+ }
600
+ value={
601
+ linkSteps[linkStepsOutput.active]
602
+ .sortFields[idSortField].dataType
603
+ }
604
+ // value={currentStep.lastFieldname}
605
+ >
606
+ <option value="string">string</option>
607
+ <option value="number">number</option>
608
+ <option value="array">array</option>
609
+ </select>
610
+ {linkSteps[linkStepsOutput.active].sortFields[
611
+ idSortField
612
+ ].dataType === "array" && (
613
+ <>
614
+ {linkSteps[
615
+ linkStepsOutput.active
616
+ ].sortFields[
617
+ idSortField
618
+ ].sortByValueUserTags.map(
619
+ (value, index) => (
620
+ <>
621
+ <li>
622
+ {value}
623
+ <button>X</button>
624
+ </li>
625
+ </>
626
+ ),
627
+ )}
628
+
629
+ <select
630
+ onChange={(e) => handleDataTypeArray(e)}
631
+ value={dataTypeArray}
632
+ >
633
+ <option value="">-- choose --</option>
634
+ {Object.entries(valueUserTags).map(
635
+ ([key, valueUserTag]) => (
636
+ <div>
637
+ {valueUserTag.hasOwnProperty(
638
+ "defaultValue",
639
+ ) && (
640
+ <option value={key}>
641
+ {key}
642
+ </option>
643
+ )}
644
+ </div>
645
+ ),
646
+ )}
647
+ </select>
648
+
649
+ <button
650
+ onClick={() =>
651
+ handleAddDataTypeArray(idSortField)
652
+ }
653
+ >
654
+ add
655
+ </button>
656
+ </>
657
+ )}
658
+ <button
659
+ onClick={(e) =>
660
+ statusModalSortField(
661
+ data.linkStepsObjectId,
662
+ )
663
+ }
664
+ >
665
+ edit
666
+ </button>
667
+ <button>x</button>
668
+
669
+ <fieldset>
670
+ <legend>sortOrder</legend>
671
+ <select
672
+ onChange={(e) => {
673
+ handleSelectSortOrder(e, idSortField);
674
+ }}
675
+ >
676
+ <option value={""}>choose</option>
677
+ <option value="ascending">
678
+ ascending
679
+ </option>
680
+ <option value="descending">
681
+ descending
682
+ </option>
683
+ </select>
684
+ </fieldset>
685
+ </li>
686
+ ))}
687
+ </>
688
+ )}
689
+ </>
690
+ )}
691
+ <hr></hr>
692
+ <fieldset>
693
+ <legend>comparison</legend>
694
+ <select
695
+ onChange={(e) =>
696
+ handleConditionLinkSteps(
697
+ "comparison",
698
+ e.target.value,
699
+ )
700
+ }
701
+ value={linkSteps[linkStepsOutput.active].comparison}
702
+ >
703
+ <option value={null}>none</option>
704
+ {COMPARISON.map((key) => (
705
+ <option key={key} value={key}>
706
+ {key}
707
+ </option>
708
+ ))}
709
+ </select>
710
+ </fieldset>
711
+ {linkSteps[linkStepsOutput.active]?.comparison && (
712
+ <>
713
+ <fieldset>
714
+ <legend>comparisonValue</legend>
715
+ <select
716
+ onChange={(e) =>
717
+ handleConditionLinkSteps(
718
+ "comparisonValue",
719
+ e.target.value,
720
+ )
721
+ }
722
+ value={
723
+ linkSteps[linkStepsOutput.active]
724
+ .comparisonValue
725
+ }
726
+ >
727
+ <option value={null}>none</option>
728
+ <option value="createUserTag">
729
+ create new userTag
730
+ </option>
731
+ {Object.entries(valueUserTags)
732
+ .filter(([key, val]) => "defaultValue" in val)
733
+ .map(([key, val]) => (
734
+ <option key={key} value={key}>
735
+ {val.defaultValue ? key : ""}
736
+ </option>
737
+ ))}
738
+ </select>
739
+ </fieldset>
740
+
741
+ <fieldset>
742
+ <legend>comparisonSortField</legend>
743
+ <select
744
+ onChange={(e) =>
745
+ handleConditionLinkSteps(
746
+ "comparisonSortField",
747
+ e.target.value,
748
+ )
749
+ }
750
+ value={
751
+ linkSteps[linkStepsOutput.active]
752
+ .comparisonSortField
753
+ }
754
+ >
755
+ <option value={null}>none</option>
756
+ {Object.keys(
757
+ resultFieldName[
758
+ createObjTypeConcat(
759
+ linkSteps[linkStepsOutput.active]
760
+ .pathLinkType.objType,
761
+ )
762
+ ].fieldNames,
763
+ ).map((key) => (
764
+ <option key={key} value={key}>
765
+ {key}
766
+ </option>
767
+ ))}
768
+ </select>
769
+ </fieldset>
770
+ <fieldset>
771
+ <legend>comparisonDataType</legend>
772
+ <select
773
+ onChange={(e) =>
774
+ handleConditionLinkSteps(
775
+ "comparisonDataType",
776
+ e.target.value,
777
+ )
778
+ }
779
+ value={
780
+ linkSteps[linkStepsOutput.active]
781
+ .comparisonDataType
782
+ }
783
+ >
784
+ <option value={null}>none</option>
785
+ <option value="string">string</option>
786
+ <option value="number">number</option>
787
+ <option value="array">array</option>
788
+ </select>
789
+ </fieldset>
790
+ </>
791
+ )}
792
+
793
+ <hr></hr>
794
+ </div>
795
+ )}
796
+ {key === "canCombine" && value && (
797
+ <div>
798
+ <p>Combine</p>
799
+ <input
800
+ type="checkbox"
801
+ checked={linkSteps[linkStepsOutput.active]?.combine}
802
+ value={linkSteps[linkStepsOutput.active]?.combine}
803
+ onChange={(e) =>
804
+ handleConditionLinkSteps("combine", e.target.checked)
805
+ }
806
+ ></input>
807
+ <hr></hr>
808
+ </div>
809
+ )}
810
+ {key === "canFilters" && value && (
811
+ <fieldset>
812
+ <p>addFilterMain</p>
813
+
814
+ <input
815
+ type="checkbox"
816
+ checked={
817
+ linkSteps[linkStepsOutput.active]?.addFilterMain
818
+ }
819
+ value={linkSteps[linkStepsOutput.active]?.addFilterMain}
820
+ onChange={(e) =>
821
+ handleConditionLinkSteps(
822
+ "addFilterMain",
823
+ e.target.checked,
824
+ )
825
+ }
826
+ ></input>
827
+ {linkSteps[linkStepsOutput.active]?.filterElements ? (
828
+ <>
829
+ <li>
830
+ <p>haveFilter</p>
831
+
832
+ {/* <button onClick={}>X</button> */}
833
+ </li>
834
+ <button
835
+ onClick={(e) => statusModalComplexFilter(true)}
836
+ >
837
+ edit filterElements
838
+ </button>
839
+ </>
840
+ ) : (
841
+ <button onClick={(e) => statusModalComplexFilter(true)}>
842
+ create filterElements
843
+ </button>
844
+ )}
845
+ </fieldset>
846
+ )}
847
+ {key === "canPerParent" && (
848
+ <fieldset>
849
+ {data?.requestProperties && (
850
+ <>
851
+ <p>requestProperties</p>
852
+ {Object.entries(data.requestProperties).map(
853
+ ([keyRequestProperties, objRequestProperties]) => (
854
+ <IzaraDivStyle
855
+ styletags={createStyleDefualtTags(
856
+ "background",
857
+ "scroll",
858
+ "div",
859
+ )}
860
+ key={keyRequestProperties}
861
+ >
862
+ <p>{keyRequestProperties}</p>
863
+ <select
864
+ onChange={(e) =>
865
+ handleValueSelect(e, keyRequestProperties)
866
+ }
867
+ value={
868
+ linkSteps[linkStepsOutput.active]
869
+ .requestProperties[keyRequestProperties]
870
+ }
871
+ >
872
+ <option
873
+ value=""
874
+ disabled={
875
+ linkSteps[linkStepsOutput.active]
876
+ .requestProperties[
877
+ keyRequestProperties
878
+ ] !== ""
879
+ }
880
+ >
881
+ -- choose --
882
+ </option>
883
+ <option value="createUserTag">
884
+ create new userTag
885
+ </option>
886
+
887
+ {Object.entries(valueUserTags).map(
888
+ ([key, valueUserTag]) => (
889
+ <div>
890
+ {valueUserTag.hasOwnProperty(
891
+ "defaultValue",
892
+ ) && <option value={key}>{key}</option>}
893
+
894
+ {valueUserTag?.valueSource ===
895
+ "complexFilterCombination" && (
896
+ <>
897
+ {_.isEqual(
898
+ complexFilterCombinations[
899
+ valueUserTag
900
+ .complexFilterCombinationId
901
+ ].objType,
902
+ objRequestProperties.objType,
903
+ ) && (
904
+ <option value={key}>{key}</option>
905
+ )}
906
+ </>
907
+ )}
908
+
909
+ {value && (
910
+ <>
911
+ {valueUserTag?.valueSource ===
912
+ "perParentCombination" && (
913
+ <>
914
+ {_.isEqual(
915
+ perParentCombinations[
916
+ valueUserTag
917
+ .perParentCombinationId
918
+ ].objType,
919
+ objRequestProperties.objType,
920
+ ) && (
921
+ <option value={key}>
922
+ {key}
923
+ </option>
924
+ )}
925
+ </>
926
+ )}
927
+ </>
928
+ )}
929
+ </div>
930
+ ),
931
+ )}
932
+ </select>
933
+ {linkSteps[linkStepsOutput.active]
934
+ .requestProperties[keyRequestProperties] && (
935
+ <button
936
+ onClick={(e) =>
937
+ handleEditUserTag(
938
+ e,
939
+ keyRequestProperties,
940
+ linkSteps[linkStepsOutput.active]
941
+ .requestProperties[
942
+ keyRequestProperties
943
+ ],
944
+ )
945
+ }
946
+ disabled={newUserTags[keyRequestProperties]}
947
+ >
948
+ edit
949
+ </button>
950
+ )}
951
+ {linkSteps[linkStepsOutput.active]
952
+ .requestProperties[keyRequestProperties] ===
953
+ null && (
954
+ <>
955
+ <select
956
+ onChange={(e) =>
957
+ handleRequestPropertiesSelect(
958
+ e,
959
+ keyRequestProperties,
960
+ )
961
+ }
962
+ value={
963
+ newUserTags[
964
+ keyRequestProperties
965
+ ].obj.hasOwnProperty("defaultValue")
966
+ ? "defaultValue"
967
+ : newUserTags[keyRequestProperties]
968
+ .obj.valueSource
969
+ }
970
+ >
971
+ <option value="defaultValue">
972
+ defaultValue
973
+ </option>
974
+ <option value="complexFilterCombination">
975
+ complexFilterCombination
976
+ </option>
977
+ {value && (
978
+ <option value="perParentCombination">
979
+ perParentCombination
980
+ </option>
981
+ )}
982
+ </select>
983
+ </>
984
+ )}
985
+
986
+ <>
987
+ {newUserTags[
988
+ keyRequestProperties
989
+ ]?.hasOwnProperty("name") && (
990
+ <>
991
+ {!linkSteps[linkStepsOutput.active]
992
+ .requestProperties[
993
+ keyRequestProperties
994
+ ] && (
995
+ <fieldset>
996
+ <legend>userTagName</legend>
997
+ <input
998
+ onChange={(e) => {
999
+ handleChangeNameUserTag(
1000
+ e,
1001
+ keyRequestProperties,
1002
+ );
1003
+ }}
1004
+ value={
1005
+ newUserTags[keyRequestProperties]
1006
+ .name
1007
+ }
1008
+ ></input>
1009
+ </fieldset>
1010
+ )}
1011
+ {newUserTags[
1012
+ keyRequestProperties
1013
+ ].obj.hasOwnProperty("defaultValue") && (
1014
+ <>
1015
+ <fieldset>
1016
+ <legend>defaultValue</legend>
1017
+ <input
1018
+ onChange={(e) =>
1019
+ handleChangeUserTag(
1020
+ e,
1021
+ "defaultValue",
1022
+ keyRequestProperties,
1023
+ )
1024
+ }
1025
+ value={
1026
+ newUserTags[
1027
+ keyRequestProperties
1028
+ ].obj.defaultValue
1029
+ }
1030
+ ></input>
1031
+ </fieldset>
1032
+ <button
1033
+ onClick={(e) =>
1034
+ handleCreateuserTagTypeValue(
1035
+ e,
1036
+ keyRequestProperties,
1037
+ )
1038
+ }
1039
+ >
1040
+ {linkSteps[linkStepsOutput.active]
1041
+ .requestProperties[
1042
+ keyRequestProperties
1043
+ ] ? (
1044
+ <>update</>
1045
+ ) : (
1046
+ <>create</>
1047
+ )}
1048
+ </button>
1049
+ </>
1050
+ )}
1051
+ {newUserTags[
1052
+ keyRequestProperties
1053
+ ].obj.hasOwnProperty("valueSource") && (
1054
+ <>
1055
+ {newUserTags[keyRequestProperties].obj
1056
+ .valueSource ===
1057
+ "perParentCombination" && (
1058
+ <>
1059
+ <button
1060
+ onClick={() =>
1061
+ handleCreateUserTagComplexOrPerParent(
1062
+ keyRequestProperties,
1063
+ "perParentCombination",
1064
+ )
1065
+ }
1066
+ >
1067
+ create
1068
+ </button>
1069
+ </>
1070
+ )}
1071
+
1072
+ {newUserTags[keyRequestProperties].obj
1073
+ .valueSource ===
1074
+ "complexFilterCombination" && (
1075
+ <>
1076
+ <button
1077
+ onClick={() =>
1078
+ handleCreateUserTagComplexOrPerParent(
1079
+ keyRequestProperties,
1080
+ "complexFilterCombination",
1081
+ )
1082
+ }
1083
+ >
1084
+ create
1085
+ </button>
1086
+ </>
1087
+ )}
1088
+ </>
1089
+ )}
1090
+
1091
+ {modalUseCase ===
1092
+ "complexFilterCombination" && (
1093
+ <>
1094
+ <ModalComplexFilterComponent
1095
+ statusModal={statusModalUseCase}
1096
+ titleModel={
1097
+ "complexFilterCombination"
1098
+ }
1099
+ objTypeMain={
1100
+ data.requestProperties[
1101
+ keyRequestProperties
1102
+ ].objType
1103
+ }
1104
+ createFilterElement={
1105
+ createComplexFilterCombinations
1106
+ }
1107
+ nameReducer={nameReducer}
1108
+ parentOutputId={parentOutputId}
1109
+ keyUseCase={keyRequestProperties}
1110
+ valueUserTag={Object.fromEntries(
1111
+ Object.entries(
1112
+ valueUserTags,
1113
+ ).filter(
1114
+ ([_, val]) =>
1115
+ "defaultValue" in val,
1116
+ ),
1117
+ )}
1118
+ // objConfigUseCase={
1119
+ // complexFilterCombinations[
1120
+ // valueUserTags[
1121
+ // linkSteps[
1122
+ // linkStepsOutput.active
1123
+ // ].requestProperties[
1124
+ // keyRequestProperties
1125
+ // ]
1126
+ // ]?.complexFilterCombinationId
1127
+ // ]
1128
+ // }
1129
+ collectObjectLinksWithRequestProperties={
1130
+ collectObjectLinksWithRequestProperties
1131
+ }
1132
+ collectObjectSchemaWithHierarchy={
1133
+ collectObjectSchemaWithHierarchy
1134
+ }
1135
+ // editLogicalElementObj={
1136
+ // complexFilterCombinations[
1137
+ // valueUserTags[
1138
+ // linkSteps[
1139
+ // linkStepsOutput
1140
+ // .active
1141
+ // ]
1142
+ // .requestProperties[
1143
+ // keyRequestProperties
1144
+ // ]
1145
+ // ]
1146
+ // ?.complexFilterCombinationId
1147
+ // ]
1148
+ // }
1149
+ />
1150
+ </>
1151
+ )}
1152
+ {modalUseCase ===
1153
+ "perParentCombination" && (
1154
+ <>
1155
+ <ModalComplexFilterComponent
1156
+ statusModal={statusModalUseCase}
1157
+ titleModel={"perParentCombination"}
1158
+ objTypeMain={
1159
+ data.requestProperties[
1160
+ keyRequestProperties
1161
+ ].objType
1162
+ }
1163
+ createFilterElement={
1164
+ createPerParentCombinations
1165
+ }
1166
+ nameReducer={nameReducer}
1167
+ parentOutputId={parentOutputId}
1168
+ keyUseCase={keyRequestProperties}
1169
+ valueUserTag={Object.fromEntries(
1170
+ Object.entries(
1171
+ valueUserTags,
1172
+ ).filter(
1173
+ ([_, val]) =>
1174
+ "defaultValue" in val ||
1175
+ "perParentIdentifierFieldname" in
1176
+ val,
1177
+ ),
1178
+ )}
1179
+ objConfigUseCase={
1180
+ perParentCombinations[
1181
+ valueUserTags[
1182
+ linkSteps[
1183
+ linkStepsOutput.active
1184
+ ].requestProperties[
1185
+ keyRequestProperties
1186
+ ]
1187
+ ]?.perParentCombinationId
1188
+ ]
1189
+ }
1190
+ perParentIdentifierFieldname={
1191
+ resultFieldName[
1192
+ linkStepsOutput.active === 0
1193
+ ? createObjTypeConcat(
1194
+ objTypeMain,
1195
+ )
1196
+ : createObjTypeConcat(
1197
+ linkSteps[
1198
+ linkStepsOutput.active -
1199
+ 1
1200
+ ].pathLinkType.objType,
1201
+ )
1202
+ ].identifiers
1203
+ }
1204
+ collectObjectLinksWithRequestProperties={
1205
+ collectObjectLinksWithRequestProperties
1206
+ }
1207
+ collectObjectSchemaWithHierarchy={
1208
+ collectObjectSchemaWithHierarchy
1209
+ }
1210
+ // editLogicalElementObj={
1211
+ // perParentCombinations[
1212
+ // valueUserTags[
1213
+ // linkSteps[
1214
+ // linkStepsOutput
1215
+ // .active
1216
+ // ]
1217
+ // .requestProperties[
1218
+ // keyRequestProperties
1219
+ // ]
1220
+ // ]
1221
+ // ?.perParentCombinationId
1222
+ // ]
1223
+ // }
1224
+ />
1225
+ </>
1226
+ )}
1227
+ </>
1228
+ )}
1229
+ </>
1230
+ </IzaraDivStyle>
1231
+ ),
1232
+ )}
1233
+ </>
1234
+ )}
1235
+ </fieldset>
1236
+ )}
1237
+ </>
1238
+ ))}
1239
+ {/* ------------------------------------------------------------------ */}
1240
+ {modalComplexFilter && (
1241
+ <ModalComplexFilterComponent
1242
+ titleModel={"complexFilter"}
1243
+ statusModal={statusModalComplexFilter}
1244
+ // objTypeMain={{
1245
+ // serviceTag: "SellOfferPlan",
1246
+ // objectType: "sellOfferPlan",
1247
+ // }}
1248
+ objTypeMain={
1249
+ linkSteps[linkStepsOutput.active].pathLinkType.objType
1250
+ }
1251
+ nameReducer={nameReducer}
1252
+ parentOutputId={parentOutputId}
1253
+ // objConfigUseCase={objConfigUseCase}
1254
+ createFilterElement={createFilterElement}
1255
+ collectObjectLinksWithRequestProperties={
1256
+ collectObjectLinksWithRequestProperties
1257
+ }
1258
+ collectObjectSchemaWithHierarchy={
1259
+ collectObjectSchemaWithHierarchy
1260
+ }
1261
+ valueUserTags={valueUserTags}
1262
+ // successTraversal={successTraversal}
1263
+ />
1264
+ )}
1265
+ {/* {modalSortField && (
1266
+ <ModalLinkStepsComponent
1267
+ titleModal={"sortField"}
1268
+ statusModalFunc={statusModalSortField}
1269
+ objTypeMain={
1270
+ linkSteps[linkStepsOutput.active].pathLinkType.objType
1271
+ }
1272
+ objConfigUseCase={objConfigUseCase}
1273
+ nameReducer={nameReducer}
1274
+ parentOutputId={parentOutputId}
1275
+ successFunc={successSortField}
1276
+ collectObjectLinksWithRequestProperties={
1277
+ collectObjectLinksWithRequestProperties
1278
+ }
1279
+ collectObjectSchemaWithHierarchy={
1280
+ collectObjectSchemaWithHierarchy
1281
+ }
1282
+ nameObjectLinkStepEdit={
1283
+ modalSortField === true ? "" : modalSortField
1284
+ }
1285
+ //----------------------------------
1286
+ LastStepsComponentUseCase={LastStepsComponentUseCase}
1287
+ valueUserTags={valueUserTags}
1288
+
1289
+ //useLink
1290
+ // nameFiledNameLastLinkStep={"fieldName"}
1291
+
1292
+ // sortFieldStatus={true}
1293
+
1294
+ // complexFilterCombinationsObj={
1295
+ // objConfig.pageOutputMainConfigUseCase.complexFilterCombinations
1296
+ // }
1297
+ // perParentCombinationsObj={
1298
+ // objConfig.pageOutputMainConfigUseCase.perParentCombinations
1299
+ // }
1300
+ // createSortFieldFunc={""}
1301
+ // keyElement={keyElement}
1302
+ />
1303
+ )} */}
1304
+ {modalSortField && (
1305
+ <ModalLinkStepsComponent
1306
+ titleModal={"srortField"}
1307
+ statusModalFunc={statusModalSortField}
1308
+ objConfigUseCase={objConfigUseCase}
1309
+ objTypeMain={objTypeMain}
1310
+ nameReducer={nameReducer}
1311
+ parentOutputId={parentOutputId}
1312
+ // successFunc={successFuncCreateSortField}
1313
+ successFuncUseCase={successFuncCreateSortField}
1314
+ collectObjectLinksWithRequestProperties={
1315
+ collectObjectLinksWithRequestProperties
1316
+ }
1317
+ collectObjectSchemaWithHierarchy={
1318
+ collectObjectSchemaWithHierarchy
1319
+ }
1320
+ //---------------use case----------------------------
1321
+ // keyElement={keyElement}
1322
+ // nameObjectLinkStep={nameObjectLinkStep}
1323
+ //------------------------------------------
1324
+ // funcUseCase={{ handleInputNameLinkStep, validateRequestProperties }}
1325
+ ComponentUseCase={
1326
+ ConditionLinkStepAndMultipleIdentifersComponent
1327
+ }
1328
+ LastStepsComponentUseCase={LastStepsComponentUseCase}
1329
+ valueUserTags={valueUserTags}
1330
+ nameObjectLinkStepEdit={""}
1331
+ // keyObjectUseCase
1332
+ />
1333
+ )}
1334
+ </>
1335
+ )}
1336
+ </div>
1337
+ ))}
1338
+ </>
1339
+ );
1340
+ };
1341
+ //----------------------------- use Lib -----------------------------------------------