@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,2572 @@
1
+ import React, {
2
+ useContext,
3
+ useState,
4
+ useEffect,
5
+ useRef,
6
+ useCallback,
7
+ } from "react";
8
+ import {
9
+ IzaraDivStyle,
10
+ IzaraButtonStyle,
11
+ createStyleDefualtTags,
12
+ createStyleTags,
13
+ } from "@izaraFrontends/styles";
14
+ import { useImmer } from "use-immer";
15
+
16
+ // import {
17
+ // getObjectSchema,
18
+ // reformatObjectSchema,
19
+ // } from "@izara_project/izara-shared-service-schemas";
20
+
21
+ // import { get_objectLinksSchema } from "../../../../izara-frontend-lib-core-page-output-config_rut/configPageOutputSection/getSchemaNewLibrary/getObjectSchemaQuery";
22
+ // import {
23
+ // collectObjectLinksWithRequestProperties,
24
+ // collectObjectSchemaWithHierarchy,
25
+ // } from "@izara_frontend/service-schemas";
26
+
27
+ import { useDispatch, useSelector } from "react-redux";
28
+ import { nanoid } from "nanoid";
29
+ import { ModalLinkStepsComponent } from "../linkSteps/modalLinkStepsComponent.jsx";
30
+ import { UserTagsSelectAndCreateComponent } from "../valueUserTags/valueUserTagsComponent.jsx";
31
+ import { successTraversalConfig } from "../function/createActionLibCreateLinkStepAndComplexFilter";
32
+
33
+ // import { ModalRequiredData } from "./modalRequiredData";
34
+ // import _, { flatMap, last } from "lodash";
35
+ var hash = require("object-hash");
36
+
37
+ function createObjTypeConcat(objType) {
38
+ console.log("objType:sdsadwsd ", objType);
39
+ return `${objType?.serviceTag}_${objType?.objectType}`;
40
+ }
41
+ function createRelTypeConcat(relType) {
42
+ console.log("objType:sdsadwsd ", relType);
43
+ return `${relType?.serviceTag}_${relType?.relationshipTag}`;
44
+ }
45
+ function objTypeFromObjTypeConcat(objTypeConcat) {
46
+ console.log("objTypeConcat:aeaeaeww ", objTypeConcat);
47
+ let result = objTypeConcat.split("_");
48
+
49
+ if (result.length !== 2) {
50
+ throw Error("objTypeConcat invalid");
51
+ }
52
+
53
+ return {
54
+ serviceTag: result[0],
55
+ objectType: result[1],
56
+ };
57
+ }
58
+
59
+ export function findLogicalRoot(activeId, logicalElementObj) {
60
+ const prevId = logicalElementObj[activeId]?.previousLogicalElementId;
61
+ console.log("prevId:sdasdaszc ", prevId);
62
+ console.log("activeId:sdasdaszc ", activeId);
63
+
64
+ if (prevId) {
65
+ if (
66
+ logicalElementObj[prevId]?.logicalElementType === "childComplexFilter"
67
+ ) {
68
+ if (activeId === logicalElementObj[prevId].childLogicalElementId) {
69
+ return activeId;
70
+ } else {
71
+ return findLogicalRoot(prevId, logicalElementObj);
72
+ }
73
+ } else {
74
+ return findLogicalRoot(prevId, logicalElementObj);
75
+ }
76
+ }
77
+ return activeId;
78
+ }
79
+
80
+ export const OutputListLogicalElement = ({
81
+ logicalElementObj,
82
+ setLogicalElementObj,
83
+ logicalElementId,
84
+ logicalElementOutput,
85
+ setLogicalElementOutput,
86
+ handleAddLogicalElement,
87
+ hadleActiveLogicalElement,
88
+ }) => {
89
+ function handelRemoveLogical(startKey) {
90
+ const toDelete = new Set();
91
+
92
+ function loopLogical(key) {
93
+ if (!logicalElementObj[key]) return;
94
+
95
+ const current = logicalElementObj[key];
96
+
97
+ if (current.nextLogicalElementId) {
98
+ loopLogical(current.nextLogicalElementId);
99
+ }
100
+
101
+ if (current.childLogicalElementId) {
102
+ loopLogical(current.childLogicalElementId);
103
+ }
104
+
105
+ toDelete.add(key);
106
+ }
107
+
108
+ loopLogical(startKey);
109
+ setLogicalElementOutput((logicalElementOutput) => {
110
+ logicalElementOutput.active =
111
+ logicalElementObj[startKey].previousLogicalElementId;
112
+ });
113
+
114
+ setLogicalElementObj((logicalElementObj) => {
115
+ for (const keyDelete of toDelete) {
116
+ logicalElementObj[
117
+ logicalElementObj[keyDelete].previousLogicalElementId
118
+ ].nextLogicalElementId = null;
119
+
120
+ delete logicalElementObj[keyDelete];
121
+ }
122
+ });
123
+ }
124
+
125
+ const le = logicalElementObj[logicalElementId];
126
+ const bracketObj = {
127
+ openBracket: "(",
128
+ closeBracket: ")",
129
+ };
130
+
131
+ const display =
132
+ le?.operation ??
133
+ bracketObj[le?.logicalElementType] ??
134
+ le?.logicalElementType;
135
+
136
+ return (
137
+ <>
138
+ {logicalElementId && (
139
+ <>
140
+ <IzaraDivStyle
141
+ styletags={createStyleDefualtTags("gridColumn", "", "311")}
142
+ >
143
+ <button
144
+ disabled={logicalElementId === logicalElementOutput.active}
145
+ onClick={(e) => hadleActiveLogicalElement(logicalElementId)}
146
+ >
147
+ {display}
148
+ </button>
149
+
150
+ <>
151
+ {logicalElementId === logicalElementOutput.active && (
152
+ <button onClick={(e) => handelRemoveLogical(logicalElementId)}>
153
+ x
154
+ </button>
155
+ )}
156
+ </>
157
+ </IzaraDivStyle>
158
+
159
+ {logicalElementObj[logicalElementId]?.nextLogicalElementId && (
160
+ <>
161
+ <OutputListLogicalElement
162
+ logicalElementObj={logicalElementObj}
163
+ setLogicalElementObj={setLogicalElementObj}
164
+ logicalElementId={
165
+ logicalElementObj[logicalElementId].nextLogicalElementId
166
+ }
167
+ logicalElementOutput={logicalElementOutput}
168
+ setLogicalElementOutput={setLogicalElementOutput}
169
+ handleAddLogicalElement={handleAddLogicalElement}
170
+ hadleActiveLogicalElement={hadleActiveLogicalElement}
171
+ />
172
+ </>
173
+ )}
174
+ </>
175
+ )}
176
+ </>
177
+ );
178
+ };
179
+
180
+ export const ModalComplexFilterComponent = ({
181
+ titleModel,
182
+ statusModal,
183
+ objTypeMain,
184
+ createFilterElement,
185
+ parentOutputId,
186
+ nameReducer,
187
+ keyUseCase, //not sure keyRequestProperties
188
+ valueUserTags,
189
+ perParentIdentifierFieldname,
190
+ successFunction,
191
+ collectObjectLinksWithRequestProperties,
192
+ collectObjectSchemaWithHierarchy,
193
+ objConfigUseCase,
194
+ // successTraversal,
195
+ }) => {
196
+ // console.log("keyUseCase:dfecvxvd ", keyUseCase);
197
+ if (!objTypeMain) {
198
+ objTypeMain = objConfigUseCase.objType;
199
+ }
200
+
201
+ console.log("valueUserTags:dfcxvcxvxc ", valueUserTags);
202
+ console.log("successFunction: sdxcxcaAD", successFunction);
203
+ // console.log("objConfigUseCase:adxzvcxbxb ", objConfigUseCase, valueUserTag);
204
+
205
+ // if (!valueUserTag) {
206
+ // if (objConfigUseCase?.valueUserTags) {
207
+ // valueUserTag = objConfigUseCase.valueUserTags;
208
+ // } else {
209
+ // valueUserTag = {};
210
+ // }
211
+ // }
212
+
213
+ // const valueUserTags = Object.fromEntries(
214
+ // Object.entries(objConfigUseCase?.valueUserTags).filter(
215
+ // ([_, val]) =>
216
+ // "defaultValue" in val || "perParentIdentifierFieldname" in val,
217
+ // ),
218
+ // );
219
+
220
+ // console.log("valueUserTag:sxzcvxcb ", valueUserTags);
221
+
222
+ const dispatch = useDispatch();
223
+ const [modalTraversal, setModalTraversal] = useState(false);
224
+
225
+ //----------------------------logical-----------------------------------------
226
+ const [fieldValueUserTag, setFieldValueUserTag] = useImmer({
227
+ // fieldName: "",
228
+ // valueUserTag: "",
229
+ });
230
+
231
+ function selectValueUserTagForPartitionKey(e, key) {
232
+ let value = e.target.value;
233
+
234
+ setLogicalElementObj((logicalElementObj) => {
235
+ logicalElementObj[logicalElementOutput.active].partitionKeyValueUserTags[
236
+ key
237
+ ] = value;
238
+ });
239
+ }
240
+
241
+ function handleSelectFieldNameAndValueUserTag(e, type) {
242
+ let value = e.target.value;
243
+ console.log("type:sdadfdsfd ", type);
244
+ console.log("value:sdadfdsfd ", value);
245
+
246
+ setFieldValueUserTag((fieldValueUserTag) => {
247
+ fieldValueUserTag[type] = value;
248
+ });
249
+ }
250
+
251
+ function handleAddFieldName() {
252
+ setFieldValueUserTag({
253
+ fieldName: "",
254
+ valueUserTag: "",
255
+ });
256
+ }
257
+
258
+ function handleSaveFieldValueUserTag() {
259
+ setLogicalElementObj((logicalElementObj) => {
260
+ if (
261
+ !logicalElementObj[logicalElementOutput.active].conditionalFieldValues
262
+ ) {
263
+ logicalElementObj[logicalElementOutput.active].conditionalFieldValues =
264
+ [];
265
+ }
266
+
267
+ logicalElementObj[
268
+ logicalElementOutput.active
269
+ ].conditionalFieldValues.push({
270
+ fieldname: fieldValueUserTag.fieldName,
271
+ includeValueUserTags: [fieldValueUserTag.valueUserTag],
272
+ // excludeValueUserTags: ["xx","sdd"]
273
+ });
274
+ });
275
+
276
+ setFieldValueUserTag({});
277
+ }
278
+
279
+ function handleSaveChildIdentifiers() {
280
+ setLogicalElementObj((logicalElementObj) => {
281
+ if (!logicalElementObj[logicalElementOutput.active].childIdentifiers) {
282
+ logicalElementObj[logicalElementOutput.active].childIdentifiers = [];
283
+ }
284
+
285
+ logicalElementObj[logicalElementOutput.active].childIdentifiers.push({
286
+ [fieldValueUserTag.fieldName]: fieldValueUserTag.valueUserTag,
287
+ });
288
+ });
289
+
290
+ setFieldValueUserTag({});
291
+ }
292
+
293
+ //----------------------------logical-----------------------------------------
294
+
295
+ const [allObjTypesLinkConfigs, collectRequireLinksFn, collectLinksOpt] =
296
+ collectObjectLinksWithRequestProperties(); // allObjTypesLinkConfigs
297
+
298
+ const [resultFieldName, getObjSchemaHieFn, collectLinksOpt2] =
299
+ collectObjectSchemaWithHierarchy();
300
+
301
+ console.log("objConfigUseCase:dsfevcxvzxc ", objConfigUseCase);
302
+
303
+ console.log(
304
+ "dataRelationship:wsxzx data ",
305
+ allObjTypesLinkConfigs,
306
+ resultFieldName,
307
+ );
308
+ const [initialLogicalElementId, setInitialLogicalElementId] = useState(
309
+ objConfigUseCase ? objConfigUseCase.initialLogicalElementId : "",
310
+ );
311
+ const [logicalElementObj, setLogicalElementObj] = useImmer(
312
+ objConfigUseCase ? objConfigUseCase.logicalElements : {},
313
+ );
314
+
315
+ const [logicalElementOutput, setLogicalElementOutput] = useImmer({
316
+ status: true,
317
+ active: objConfigUseCase ? objConfigUseCase.initialLogicalElementId : "",
318
+ });
319
+
320
+ const [valueDataUserTags, setValueDataUserTags] = useImmer({});
321
+ const [newUserTags, setNewUserTags] = useImmer({});
322
+ const [newUserTagsRequestProperties, setNewUserTagsRequestProperties] =
323
+ useImmer({});
324
+
325
+ console.log(
326
+ "logicalElementOutput: awscxzzvbm",
327
+ initialLogicalElementId,
328
+ logicalElementOutput,
329
+ logicalElementObj,
330
+ );
331
+
332
+ useEffect(() => {
333
+ collectRequireLinksFn(objTypeMain);
334
+ getObjSchemaHieFn(objTypeMain);
335
+ }, []);
336
+
337
+ console.log("objTypeMain:sdwdxzxzxcc ", objTypeMain);
338
+ function createArrObjTypeLogical(activeId, logicalElementObj) {
339
+ const result = {
340
+ arrOutput: [],
341
+ lastObjtype: "",
342
+ };
343
+
344
+ function loopLogical(id) {
345
+ console.log("logicalElementObj:xsadfdfds ", logicalElementObj, id);
346
+ const currentLogical = logicalElementObj[id];
347
+ console.log("currentLogical:createArrObjTypeLogical ", currentLogical);
348
+
349
+ if (!currentLogical) return;
350
+ if (currentLogical.previousLogicalElementId !== null) {
351
+ console.log("IF:createArrObjTypeLogical");
352
+
353
+ loopLogical(currentLogical.previousLogicalElementId);
354
+ }
355
+ console.log(
356
+ "createArrObjTypeLogical",
357
+ id,
358
+ logicalElementObj[currentLogical.previousLogicalElementId]
359
+ ?.childLogicalElementId,
360
+ );
361
+ if (
362
+ id ===
363
+ logicalElementObj[currentLogical.previousLogicalElementId]
364
+ ?.childLogicalElementId
365
+ ) {
366
+ let objTypeOutput;
367
+ if (logicalElementObj[id]?.objType) {
368
+ objTypeOutput = createObjTypeConcat(currentLogical.objType);
369
+ } else {
370
+ objTypeOutput = createObjTypeConcat(
371
+ logicalElementObj[currentLogical.previousLogicalElementId]
372
+ .pathLinkType.objType,
373
+ );
374
+ }
375
+ console.log("objTypeOutput:createArrObjTypeLogical", objTypeOutput);
376
+
377
+ result.lastObjtype = objTypeOutput;
378
+ result.arrOutput.push({ [objTypeOutput]: id });
379
+ }
380
+ }
381
+
382
+ loopLogical(activeId);
383
+
384
+ console.log("result:createArrObjTypeLogical ", result);
385
+ return result;
386
+ }
387
+
388
+ function findObjTypeStep(activeId, logicalElementObj) {
389
+ let result = null;
390
+
391
+ function loop(id) {
392
+ console.log("id:wdsfdfdf ", id);
393
+ const current = logicalElementObj[id];
394
+ console.log("current:sadfdf ", current);
395
+ if (!current) return;
396
+
397
+ if (
398
+ current.logicalElementType === "childComplexFilter" ||
399
+ current.logicalElementType === "logical"
400
+ // !current.previousLogicalElementId
401
+ ) {
402
+ result = current.objType || null;
403
+ return;
404
+ }
405
+
406
+ const prevId = current.previousLogicalElementId;
407
+ console.log("prevId:findObjTypeStep ", prevId);
408
+
409
+ if (!prevId) {
410
+ if (current.objType) {
411
+ result = current.objType;
412
+ }
413
+ return;
414
+ }
415
+
416
+ const prev = logicalElementObj[prevId];
417
+ if (!prev) return;
418
+
419
+ // ถ้า previous มี childLogicalElementId === currentId แสดงว่า current เป็น child ของ prev หยุด (ไม่ข้ามขึ้น)
420
+ if (prev.childLogicalElementId === id) {
421
+ // แต่ถ้ามี objType ของตัวเอง ใช้ตัวเอง
422
+ if (current.objType) {
423
+ result = current.objType;
424
+ }
425
+
426
+ return;
427
+ }
428
+
429
+ // ถ้า previous มี objType ใช้เลย
430
+ if (prev.objType) {
431
+ result = prev.objType;
432
+ return;
433
+ }
434
+
435
+ // ไม่เข้าเงื่อนไขไหน เดินย้อนขึ้นต่อ
436
+ loop(prevId);
437
+ }
438
+
439
+ loop(activeId);
440
+ return result;
441
+ }
442
+
443
+ function findObjTypeStepChild(activeId, logicalElementObj) {
444
+ let result = null;
445
+
446
+ function loop(id) {
447
+ console.log("id:wdsfdfdf ", id);
448
+ const current = logicalElementObj[id];
449
+ // console.log("current:sadfdf ", current);
450
+ // if (!current) {
451
+ // result = null;
452
+ // return;
453
+ // } else {
454
+ // result = current.objType;
455
+ // return;
456
+ // }
457
+
458
+ // if (
459
+ // current.logicalElementType === "childComplexFilter" ||
460
+ // current.logicalElementType === "logical"
461
+ // // !current.previousLogicalElementId
462
+ // ) {
463
+ // result = current.objType || null;
464
+ // return;
465
+ // }
466
+
467
+ const prevId = current.previousLogicalElementId;
468
+ console.log("prevId:findObjTypeStep ", prevId);
469
+
470
+ if (!prevId) {
471
+ if (current.objType) {
472
+ result = current.objType;
473
+ }
474
+ return;
475
+ }
476
+
477
+ const prev = logicalElementObj[prevId];
478
+ if (!prev) return;
479
+
480
+ // ถ้า previous มี childLogicalElementId === currentId แสดงว่า current เป็น child ของ prev หยุด (ไม่ข้ามขึ้น)
481
+ if (prev.childLogicalElementId === id) {
482
+ // แต่ถ้ามี objType ของตัวเอง ใช้ตัวเอง
483
+ if (current.objType) {
484
+ result = current.objType;
485
+ }
486
+
487
+ return;
488
+ }
489
+
490
+ // ถ้า previous มี objType ใช้เลย
491
+ if (prev.objType) {
492
+ result = prev.objType;
493
+ return;
494
+ }
495
+
496
+ // ไม่เข้าเงื่อนไขไหน เดินย้อนขึ้นต่อ
497
+ loop(prevId);
498
+ }
499
+
500
+ loop(activeId);
501
+ return result;
502
+ }
503
+
504
+ async function handleLogicalElementTypeChange(e) {
505
+ let logicalElementType = e.target.value;
506
+ let mainLoigcalObj = objTemplateLogicalElement(
507
+ logicalElementType,
508
+ logicalElementObj[logicalElementOutput.active].previousLogicalElementId,
509
+ logicalElementObj[logicalElementOutput.active].nextLogicalElementId,
510
+ );
511
+ let logicalObj = {};
512
+ console.log("dfofjdf", logicalElementObj[logicalElementOutput.active]);
513
+
514
+ setLogicalElementOutput((logicalElementOutput) => {
515
+ logicalElementOutput.status = false;
516
+ });
517
+
518
+ let objType;
519
+ objType = objTypeMain;
520
+
521
+ if (
522
+ createArrObjTypeLogical(logicalElementOutput.active, logicalElementObj)
523
+ .lastObjtype !== ""
524
+ ) {
525
+ objType = objTypeFromObjTypeConcat(
526
+ createArrObjTypeLogical(logicalElementOutput.active, logicalElementObj)
527
+ .lastObjtype,
528
+ );
529
+ }
530
+
531
+ if (logicalElementType === "childComplexFilter") {
532
+ logicalObj = {
533
+ ...mainLoigcalObj,
534
+ objType: objType,
535
+ pathLinkType: {
536
+ objType: "",
537
+ relType: "",
538
+ direction: "",
539
+ },
540
+ childLogicalElementId: null,
541
+ };
542
+ }
543
+ if (logicalElementType === "translateIds") {
544
+ logicalObj = {
545
+ ...mainLoigcalObj,
546
+ objType: objType,
547
+ pathLinkType: {
548
+ objType: "",
549
+ relType: "",
550
+ direction: "",
551
+ },
552
+ childIdentifiers: [],
553
+ };
554
+ }
555
+
556
+ if (logicalElementType === "logical") {
557
+ console.log(
558
+ "typeLogicalInFunction:ttyyxfchs",
559
+ createObjTypeConcat(
560
+ findObjTypeStep(logicalElementOutput.active, logicalElementObj),
561
+ ),
562
+ resultFieldName[
563
+ logicalElementObj[logicalElementOutput.active]
564
+ .previousLogicalElementId === null
565
+ ? createObjTypeConcat(objTypeMain)
566
+ : createObjTypeConcat(
567
+ findObjTypeStep(logicalElementOutput.active, logicalElementObj),
568
+ )
569
+ ],
570
+ );
571
+
572
+ logicalObj = {
573
+ ...mainLoigcalObj,
574
+ objType: objType,
575
+ partitionKeyValueUserTags: {},
576
+ // fieldName: "",
577
+ // comparison: "",
578
+ // valueUserTag: "",
579
+ };
580
+ }
581
+
582
+ if (
583
+ logicalElementType === "openBracket" ||
584
+ logicalElementType === "closeBracket"
585
+ ) {
586
+ setLogicalElementOutput((logicalElementOutput) => {
587
+ logicalElementOutput.status = true;
588
+ });
589
+ }
590
+
591
+ setLogicalElementObj((logicalElementObj) => {
592
+ logicalElementObj[logicalElementOutput.active] = {
593
+ ...mainLoigcalObj,
594
+ ...logicalObj,
595
+ };
596
+ });
597
+ }
598
+
599
+ // console.log(
600
+ // "typeLogicalOutFunction:ttyyxfchs",
601
+ // createObjTypeConcat(
602
+ // findObjTypeStep(logicalElementOutput.active, logicalElementObj),
603
+ // ),
604
+ // resultFieldName[
605
+ // logicalElementObj[logicalElementOutput.active]
606
+ // ?.previousLogicalElementId === null
607
+ // ? createObjTypeConcat(objTypeMain)
608
+ // : createObjTypeConcat(
609
+ // findObjTypeStep(logicalElementOutput.active, logicalElementObj),
610
+ // )
611
+ // ],
612
+ // );
613
+ function handleOperationChange(e) {
614
+ let operation = e.target.value;
615
+
616
+ setLogicalElementObj((logicalElementObj) => {
617
+ logicalElementObj[logicalElementOutput.active].operation = operation;
618
+ });
619
+
620
+ setLogicalElementOutput((logicalElementOutput) => {
621
+ logicalElementOutput.status = true;
622
+ });
623
+ }
624
+
625
+ function objTemplateLogicalElement(
626
+ logicalElementType,
627
+ previousLogicalElementId,
628
+ nextLogicalElementId,
629
+ ) {
630
+ let objTemplate = {
631
+ logicalElementType: logicalElementType,
632
+ previousLogicalElementId: previousLogicalElementId,
633
+ nextLogicalElementId: nextLogicalElementId,
634
+ };
635
+
636
+ return objTemplate;
637
+ }
638
+
639
+ function handelSelectRelTypeAndDirection(e) {
640
+ let relType = e.target.value;
641
+ let index = e.target.selectedIndex - 1;
642
+ let objTypeConcat = createObjTypeConcat(
643
+ logicalElementObj[logicalElementOutput.active].objType,
644
+ );
645
+
646
+ collectRequireLinksFn(
647
+ allObjTypesLinkConfigs[objTypeConcat][index].other.objType,
648
+ );
649
+ getObjSchemaHieFn(
650
+ allObjTypesLinkConfigs[objTypeConcat][index].other.objType,
651
+ );
652
+
653
+ setLogicalElementObj((logicalElementObj) => {
654
+ logicalElementObj[logicalElementOutput.active].pathLinkType = {
655
+ relType: JSON.parse(relType),
656
+ objType: allObjTypesLinkConfigs[objTypeConcat][index].other.objType,
657
+ direction: allObjTypesLinkConfigs[objTypeConcat][index].base.direction,
658
+ };
659
+
660
+ if (allObjTypesLinkConfigs[objTypeConcat][index]?.requestProperties) {
661
+ let requestProperties = {};
662
+ for (const key in allObjTypesLinkConfigs[objTypeConcat][index]
663
+ ?.requestProperties) {
664
+ requestProperties[key] = "";
665
+ }
666
+ logicalElementObj[logicalElementOutput.active].requestProperties =
667
+ requestProperties;
668
+ } else {
669
+ delete logicalElementObj[logicalElementOutput.active].requestProperties;
670
+ }
671
+ });
672
+
673
+ setLogicalElementOutput((logicalElementOutput) => {
674
+ logicalElementOutput.status = true;
675
+ });
676
+ }
677
+
678
+ function handleAddLogicalElement(action) {
679
+ const uuid = nanoid(10);
680
+
681
+ console.log("action:asfdsgsdg ", action);
682
+ if (action === "addChild") {
683
+ collectRequireLinksFn(
684
+ logicalElementObj[logicalElementOutput.active].pathLinkType.objType,
685
+ );
686
+ getObjSchemaHieFn(
687
+ logicalElementObj[logicalElementOutput.active].pathLinkType.objType,
688
+ );
689
+ }
690
+
691
+ setLogicalElementObj((logicalElementObj) => {
692
+ if (Object.keys(logicalElementObj).length === 0) {
693
+ setInitialLogicalElementId(uuid);
694
+ logicalElementObj[uuid] = objTemplateLogicalElement(
695
+ "newLogicalElement",
696
+ null,
697
+ null,
698
+ );
699
+ } else {
700
+ if (action === "addParent") {
701
+ if (
702
+ logicalElementObj[logicalElementOutput.active]
703
+ .nextLogicalElementId !== null
704
+ ) {
705
+ logicalElementObj[uuid] = objTemplateLogicalElement(
706
+ "newLogicalElement",
707
+ logicalElementOutput.active,
708
+ logicalElementObj[logicalElementOutput.active]
709
+ .nextLogicalElementId,
710
+ );
711
+
712
+ logicalElementObj[
713
+ logicalElementOutput.active
714
+ ].nextLogicalElementId = uuid;
715
+ } else {
716
+ logicalElementObj[
717
+ logicalElementOutput.active
718
+ ].nextLogicalElementId = uuid;
719
+
720
+ logicalElementObj[uuid] = objTemplateLogicalElement(
721
+ "newLogicalElement",
722
+ logicalElementOutput.active,
723
+ null,
724
+ );
725
+ }
726
+ }
727
+
728
+ if (action === "addChild") {
729
+ logicalElementObj[uuid] = objTemplateLogicalElement(
730
+ "newLogicalElement",
731
+ logicalElementOutput.active,
732
+ null,
733
+ );
734
+ logicalElementObj[logicalElementOutput.active].childLogicalElementId =
735
+ uuid;
736
+ }
737
+ }
738
+ });
739
+
740
+ setLogicalElementOutput((logicalElementOutput) => {
741
+ logicalElementOutput.status = false;
742
+ logicalElementOutput.active = uuid;
743
+ });
744
+ }
745
+
746
+ function hadleActiveLogicalElement(key) {
747
+ setLogicalElementOutput((logicalElementOutput) => {
748
+ logicalElementOutput.active = key;
749
+ });
750
+ }
751
+
752
+ function hadelActiveTopParent(objType) {
753
+ console.log("objType:sdsacascz ", objType);
754
+ setLogicalElementOutput((logicalElementOutput) => {
755
+ logicalElementOutput.active = Object.values(objType)[0];
756
+ });
757
+ }
758
+
759
+ console.log(
760
+ "afsofiud",
761
+ createArrObjTypeLogical(logicalElementOutput.active, logicalElementObj),
762
+ );
763
+
764
+ function handleSelectFieldName(e, type) {
765
+ let value = e.target.value;
766
+
767
+ setLogicalElementObj((logicalElementObj) => {
768
+ logicalElementObj[logicalElementOutput.active][type] = value;
769
+ });
770
+
771
+ if (
772
+ type === "partitionKeyValueUserTag" ||
773
+ type === "sortKeyValueUserTags"
774
+ ) {
775
+ if (value === "createUserTag") {
776
+ setNewUserTags((newUserTags) => {
777
+ newUserTags.name = "";
778
+ newUserTags.obj = {
779
+ defaultValue: "",
780
+ };
781
+ });
782
+
783
+ setLogicalElementOutput((logicalElementOutput) => {
784
+ logicalElementOutput.status = "createUserTag";
785
+ });
786
+ } else {
787
+ setLogicalElementOutput((logicalElementOutput) => {
788
+ logicalElementOutput.status = false;
789
+ });
790
+ }
791
+ }
792
+ }
793
+
794
+ function handleUpdateNameNewValue(e) {
795
+ setNewUserTags((newUserTags) => {
796
+ newUserTags.name = e.target.value;
797
+ });
798
+ }
799
+
800
+ function handleUpdateNewValue(e, type) {
801
+ console.log("type: safddfdgcxg", type, newUserTags);
802
+
803
+ setNewUserTags((newUserTags) => {
804
+ newUserTags.obj[type] = e.target.value;
805
+ });
806
+ }
807
+
808
+ function handleUpdateNewValueRequestProperties(
809
+ e,
810
+ type,
811
+ keyRequestProperties,
812
+ ) {
813
+ setNewUserTagsRequestProperties((newUserTagsRequestProperties) => {
814
+ newUserTagsRequestProperties[keyRequestProperties][type] = e.target.value;
815
+ });
816
+ }
817
+
818
+ function handleSelectCreateNewValue(e) {
819
+ let type = e.target.value;
820
+ console.log("type:fgrgdfgfdh ", type);
821
+
822
+ setNewUserTags((newUserTags) => {
823
+ if (type === "valueUserTag") {
824
+ newUserTags.obj = {
825
+ defaultValue: "",
826
+ };
827
+ } else {
828
+ newUserTags.obj = {
829
+ valueSource: "perParentIdentifier",
830
+ perParentIdentifierFieldname: "",
831
+ };
832
+
833
+ if (
834
+ resultFieldName[createObjTypeConcat(objTypeMain)].identifiers
835
+ .length === 1
836
+ ) {
837
+ newUserTags.obj.perParentIdentifierFieldname =
838
+ perParentIdentifierFieldname[0].fieldName;
839
+ }
840
+ }
841
+ });
842
+ // setNewUserTags({});
843
+ }
844
+
845
+ console.log(
846
+ "newUserTags:sadsxczvbbvb ",
847
+ newUserTagsRequestProperties,
848
+ valueDataUserTags,
849
+ );
850
+
851
+ function handleCreateNewValue(e) {
852
+ setLogicalElementObj((logicalElementObj) => {
853
+ logicalElementObj[logicalElementOutput.active].valueUserTag =
854
+ newUserTags.nameUserTag;
855
+ });
856
+
857
+ setValueDataUserTags((valueDataUserTags) => {
858
+ valueDataUserTags[newUserTags.name] = newUserTags.obj;
859
+ });
860
+
861
+ setLogicalElementOutput((logicalElementOutput) => {
862
+ logicalElementOutput.status = true;
863
+ });
864
+ setNewUserTags({});
865
+ }
866
+
867
+ function handleCreateNewValueRequestProperties(e, keyRequestProperties) {
868
+ setLogicalElementObj((logicalElementObj) => {
869
+ logicalElementObj[logicalElementOutput.active].requestProperties[
870
+ keyRequestProperties
871
+ ] = newUserTags.nameUserTag;
872
+ });
873
+
874
+ setValueDataUserTags((valueDataUserTags) => {
875
+ valueDataUserTags[
876
+ newUserTagsRequestProperties[keyRequestProperties].name
877
+ ] = {
878
+ defaultValue:
879
+ newUserTagsRequestProperties[keyRequestProperties].defaultValue,
880
+ };
881
+ });
882
+
883
+ setLogicalElementOutput((logicalElementOutput) => {
884
+ logicalElementOutput.status = true;
885
+ });
886
+
887
+ setNewUserTagsRequestProperties((newUserTagsRequestProperties) => {
888
+ newUserTagsRequestProperties[keyRequestProperties] = {};
889
+ });
890
+ }
891
+
892
+ console.log("newUserTags: ", newUserTags);
893
+ const logicalElementType = [
894
+ "openBracket",
895
+ "closeBracket",
896
+ "childComplexFilter",
897
+ "operation",
898
+ "traversal",
899
+ "translateIds",
900
+ ];
901
+
902
+ const operation = ["AND", "OR"];
903
+ let comparison = [
904
+ "equals",
905
+ "greaterThan",
906
+ "greaterThanEquals",
907
+ "lessThan",
908
+ "lessThanEquals",
909
+ "highLow",
910
+ "high",
911
+ "low",
912
+ "izaraSyntax",
913
+ ];
914
+
915
+ function handelCreateFilterElement() {
916
+ console.log("createFilterElement:dcvnnnbjxdx ", createFilterElement);
917
+ if (createFilterElement) {
918
+ createFilterElement(
919
+ createObjTypeConcat(objTypeMain),
920
+ initialLogicalElementId,
921
+ logicalElementObj,
922
+ valueDataUserTags,
923
+ keyUseCase,
924
+ );
925
+ } else {
926
+ dispatch(
927
+ successFunction({
928
+ parentOutputId: parentOutputId,
929
+ // keyElement,
930
+ initialLogicalElementId: initialLogicalElementId,
931
+ logicalElements: logicalElementObj,
932
+ valueDataUserTags: valueDataUserTags,
933
+ }),
934
+ );
935
+ }
936
+ statusModal(false);
937
+ }
938
+
939
+ function handleValueSelect(e, key) {
940
+ let value = e.target.value;
941
+
942
+ if (value === "createUserTag") {
943
+ setLogicalElementObj((logicalElementObj) => {
944
+ logicalElementObj[logicalElementOutput.active].requestProperties[key] =
945
+ null;
946
+ });
947
+
948
+ setNewUserTagsRequestProperties((newUserTagsRequestProperties) => {
949
+ newUserTagsRequestProperties[key] = {};
950
+ });
951
+ } else {
952
+ setLogicalElementObj((logicalElementObj) => {
953
+ logicalElementObj[logicalElementOutput.active].requestProperties[key] =
954
+ value;
955
+ });
956
+ }
957
+ }
958
+
959
+ function statusModalTraversal(status) {
960
+ setModalTraversal(status);
961
+ }
962
+
963
+ function sussessComplexFilterTypeTraversal(
964
+ parentOutputId,
965
+ arrTraversalSteps,
966
+ ) {
967
+ console.log("arrTraversalSteps:dsfcxvxbx ", arrTraversalSteps);
968
+
969
+ let linkStepsArr = [];
970
+ let linkStepObj = {};
971
+ for (const index in arrTraversalSteps) {
972
+ const linkStep = arrTraversalSteps[index];
973
+ console.log("linkStep:fdvdcxfedfxcv ", linkStep);
974
+ console.log(
975
+ "linkStep?.pathLinkType?.relType:fdvdcxfedfxcv ",
976
+ linkStep?.pathLinkType?.relType,
977
+ );
978
+ if (linkStep?.pathLinkType?.relType) {
979
+ if (Object.keys(linkStep?.pathLinkType?.relType).length === 0) {
980
+ alert("relType in traversal step is empty, please select relType");
981
+ return true;
982
+ }
983
+ }
984
+ if (linkStep?.hopsPassObjType) {
985
+ if (linkStep?.hopsStart && linkStep?.hopsEnd) {
986
+ alert("relType in traversal step is empty, please select relType");
987
+ return true;
988
+ }
989
+ }
990
+
991
+ const hashTraversal = hash(linkStep);
992
+
993
+ linkStepObj[hashTraversal] = linkStep;
994
+
995
+ linkStepsArr.push(hashTraversal);
996
+ }
997
+
998
+ setLogicalElementObj((logicalElementObj) => {
999
+ logicalElementObj[logicalElementOutput.active].traversalSteps =
1000
+ linkStepsArr;
1001
+ });
1002
+
1003
+ dispatch(
1004
+ successTraversalConfig({
1005
+ parentOutputId: parentOutputId,
1006
+ traversalLinkStepsObj: linkStepObj,
1007
+ // keyElement,
1008
+ }),
1009
+ );
1010
+ }
1011
+
1012
+ function handleRemovePartitionKeyValueUserTags(key) {
1013
+ setLogicalElementObj((logicalElementObj) => {
1014
+ delete logicalElementObj[logicalElementOutput.active]
1015
+ .partitionKeyValueUserTags[key];
1016
+ });
1017
+ }
1018
+
1019
+ console.log("createFilterElement:fsdfbcsdfe", createFilterElement);
1020
+ console.log("valueDataUserTags: ", valueDataUserTags);
1021
+
1022
+ console.log("logicalElementObj:dfcxvxzzcs ", logicalElementObj);
1023
+
1024
+ return (
1025
+ <div>
1026
+ <IzaraDivStyle styletags={createStyleDefualtTags("modal", "", "main")}>
1027
+ <IzaraDivStyle styletags={createStyleDefualtTags("modal", "", "box")}>
1028
+ <IzaraDivStyle
1029
+ styletags={createStyleDefualtTags("gridColumn", "", "1")}
1030
+ >
1031
+ <h2>{titleModel}</h2>
1032
+ <hr></hr>
1033
+ <IzaraDivStyle
1034
+ styletags={createStyleDefualtTags("pagination", "", "template")}
1035
+ >
1036
+ {initialLogicalElementId && (
1037
+ <>
1038
+ <a
1039
+ onClick={(e) =>
1040
+ hadelActiveTopParent({
1041
+ [createObjTypeConcat(objTypeMain)]:
1042
+ initialLogicalElementId,
1043
+ })
1044
+ }
1045
+ >
1046
+ {createObjTypeConcat(objTypeMain)}
1047
+ </a>
1048
+ {createArrObjTypeLogical(
1049
+ logicalElementOutput.active,
1050
+ logicalElementObj,
1051
+ ).arrOutput.map((objType, index) => (
1052
+ <>
1053
+ /
1054
+ <a onClick={(e) => hadelActiveTopParent(objType)}>
1055
+ {Object.keys(objType)}
1056
+ </a>
1057
+ </>
1058
+ ))}
1059
+ </>
1060
+ )}
1061
+ </IzaraDivStyle>
1062
+
1063
+ <IzaraDivStyle
1064
+ styletags={createStyleDefualtTags("background", "scroll", "div")}
1065
+ >
1066
+ <fieldset>
1067
+ <legend>logicalElement list</legend>
1068
+
1069
+ <IzaraDivStyle
1070
+ styletags={createStyleDefualtTags(
1071
+ "gridTab",
1072
+ "",
1073
+ "logicalElment",
1074
+ )}
1075
+ >
1076
+ <IzaraDivStyle
1077
+ styletags={createStyleDefualtTags(
1078
+ "pagination",
1079
+ "",
1080
+ "template",
1081
+ )}
1082
+ >
1083
+ {initialLogicalElementId && (
1084
+ <OutputListLogicalElement
1085
+ logicalElementObj={logicalElementObj}
1086
+ setLogicalElementObj={setLogicalElementObj}
1087
+ logicalElementId={findLogicalRoot(
1088
+ logicalElementOutput.active,
1089
+ logicalElementObj,
1090
+ )}
1091
+ logicalElementOutput={logicalElementOutput}
1092
+ setLogicalElementOutput={setLogicalElementOutput}
1093
+ handleAddLogicalElement={handleAddLogicalElement}
1094
+ hadleActiveLogicalElement={hadleActiveLogicalElement}
1095
+ />
1096
+ )}
1097
+ </IzaraDivStyle>
1098
+ <button
1099
+ disabled={!allObjTypesLinkConfigs && !resultFieldName}
1100
+ onClick={(e) => handleAddLogicalElement("addParent")}
1101
+ >
1102
+ add
1103
+ </button>
1104
+ </IzaraDivStyle>
1105
+ </fieldset>
1106
+ </IzaraDivStyle>
1107
+
1108
+ <IzaraDivStyle
1109
+ styletags={createStyleDefualtTags("gridColumn", "", "1")}
1110
+ >
1111
+ <div>
1112
+ {Object.keys(logicalElementObj).length !== 0 ? (
1113
+ <>
1114
+ <IzaraDivStyle
1115
+ styletags={createStyleDefualtTags(
1116
+ "background",
1117
+ "scroll",
1118
+ "div",
1119
+ )}
1120
+ >
1121
+ <>
1122
+ <IzaraDivStyle
1123
+ styletags={createStyleDefualtTags(
1124
+ "gridColumn",
1125
+ "",
1126
+ "11",
1127
+ )}
1128
+ >
1129
+ <fieldset>
1130
+ <legend>logicalElementType</legend>
1131
+ <select
1132
+ onChange={(e) => {
1133
+ handleLogicalElementTypeChange(e);
1134
+ }}
1135
+ value={
1136
+ logicalElementObj[logicalElementOutput.active]
1137
+ .logicalElementType
1138
+ }
1139
+ >
1140
+ <option
1141
+ disabled={
1142
+ logicalElementObj[logicalElementOutput.active]
1143
+ .logicalElementType !== "newLogicalElement"
1144
+ }
1145
+ value={""}
1146
+ >
1147
+ ---choose---
1148
+ </option>
1149
+ {logicalElementType.map((key, id) => (
1150
+ <option key={key} value={key}>
1151
+ {key}
1152
+ </option>
1153
+ ))}
1154
+ {/* {console.log(
1155
+ resultFieldName[
1156
+ logicalElementObj[logicalElementOutput.active]
1157
+ .previousLogicalElementId === null
1158
+ ? createObjTypeConcat(objTypeMain)
1159
+ : createArrObjTypeLogical(
1160
+ logicalElementOutput.active,
1161
+ logicalElementObj,
1162
+ ).lastObjtype
1163
+ ]?.identifiers,
1164
+ createArrObjTypeLogical(
1165
+ logicalElementOutput.active,
1166
+ logicalElementObj,
1167
+ ).lastObjtype,
1168
+ "ssdawdafafff",
1169
+ )} */}
1170
+ {/* {createArrObjTypeLogical(
1171
+ logicalElementOutput.active,
1172
+ logicalElementObj,
1173
+ ).arrOutput.length !== 0 && (
1174
+ <option value="translateIds">
1175
+ translateIds
1176
+ </option>
1177
+ )} */}
1178
+
1179
+ {resultFieldName && (
1180
+ <>
1181
+ {resultFieldName[
1182
+ logicalElementObj[
1183
+ logicalElementOutput.active
1184
+ ].previousLogicalElementId === null
1185
+ ? createObjTypeConcat(objTypeMain)
1186
+ : createArrObjTypeLogical(
1187
+ logicalElementOutput.active,
1188
+ logicalElementObj,
1189
+ ).lastObjtype
1190
+ ]?.identifiers.some(
1191
+ (identifier) =>
1192
+ identifier.type === "partitionKey",
1193
+ ) && <option value="logical">logical</option>}
1194
+ </>
1195
+ )}
1196
+ </select>
1197
+ </fieldset>
1198
+ </IzaraDivStyle>
1199
+ <IzaraDivStyle
1200
+ styletags={createStyleDefualtTags(
1201
+ "gridColumn",
1202
+ "",
1203
+ "1",
1204
+ )}
1205
+ >
1206
+ {logicalElementObj[logicalElementOutput.active]
1207
+ .logicalElementType === "childComplexFilter" && (
1208
+ <IzaraDivStyle
1209
+ styletags={createStyleDefualtTags(
1210
+ "background",
1211
+ "scroll",
1212
+ "div",
1213
+ )}
1214
+ >
1215
+ {console.log(
1216
+ allObjTypesLinkConfigs,
1217
+ "foopesofods",
1218
+ )}
1219
+
1220
+ {!allObjTypesLinkConfigs[
1221
+ logicalElementObj[logicalElementOutput.active]
1222
+ .previousLogicalElementId === null
1223
+ ? createObjTypeConcat(objTypeMain)
1224
+ : createObjTypeConcat(
1225
+ findObjTypeStep(
1226
+ logicalElementOutput.active,
1227
+ logicalElementObj,
1228
+ ),
1229
+ )
1230
+ ] ? (
1231
+ <IzaraDivStyle
1232
+ styletags={createStyleDefualtTags(
1233
+ "loadingCircle",
1234
+ "20px",
1235
+ "template",
1236
+ )}
1237
+ ></IzaraDivStyle>
1238
+ ) : (
1239
+ <>
1240
+ <p> relationship type:</p>
1241
+ <select
1242
+ value={JSON.stringify(
1243
+ logicalElementObj[
1244
+ logicalElementOutput.active
1245
+ ].pathLinkType.relType,
1246
+ )}
1247
+ onChange={(e) =>
1248
+ handelSelectRelTypeAndDirection(e)
1249
+ }
1250
+ >
1251
+ <option
1252
+ disabled={
1253
+ logicalElementObj[
1254
+ logicalElementOutput.active
1255
+ ].pathLinkType.relType !== ""
1256
+ }
1257
+ value=""
1258
+ >
1259
+ -- relType --
1260
+ </option>
1261
+
1262
+ {allObjTypesLinkConfigs[
1263
+ createObjTypeConcat(
1264
+ logicalElementObj[
1265
+ logicalElementOutput.active
1266
+ ].objType,
1267
+ )
1268
+ ].map((data, index) => (
1269
+ <>
1270
+ <option
1271
+ key={index}
1272
+ value={JSON.stringify(data.relType)}
1273
+ >
1274
+ {createRelTypeConcat(data.relType)}
1275
+ </option>
1276
+ </>
1277
+ ))}
1278
+ </select>
1279
+
1280
+ {logicalElementObj[
1281
+ logicalElementOutput.active
1282
+ ]?.pathLinkType.objType && (
1283
+ <>
1284
+ <p> object type:</p>
1285
+ <span>
1286
+ {createObjTypeConcat(
1287
+ logicalElementObj[
1288
+ logicalElementOutput.active
1289
+ ].pathLinkType.objType,
1290
+ )}
1291
+ </span>
1292
+ <p>direction</p>
1293
+ <span>
1294
+ {
1295
+ logicalElementObj[
1296
+ logicalElementOutput.active
1297
+ ].pathLinkType.direction
1298
+ }
1299
+ </span>
1300
+ </>
1301
+ )}
1302
+ </>
1303
+ )}
1304
+
1305
+ {allObjTypesLinkConfigs[
1306
+ createObjTypeConcat(
1307
+ logicalElementObj[logicalElementOutput.active]
1308
+ .objType,
1309
+ )
1310
+ ].map((data, index) => (
1311
+ <>
1312
+ {_.isEqual(
1313
+ data.relType,
1314
+ logicalElementObj[
1315
+ logicalElementOutput.active
1316
+ ]?.pathLinkType.relType,
1317
+ ) && (
1318
+ <>
1319
+ {data.requestProperties && (
1320
+ <>
1321
+ {Object.keys(
1322
+ data.requestProperties,
1323
+ ).map(
1324
+ (keyRequestProperties, index) => (
1325
+ <>
1326
+ <p>{keyRequestProperties}</p>
1327
+ <select
1328
+ onChange={(e) =>
1329
+ handleValueSelect(
1330
+ e,
1331
+ keyRequestProperties,
1332
+ )
1333
+ }
1334
+ value={
1335
+ logicalElementObj[
1336
+ logicalElementOutput
1337
+ .active
1338
+ ].requestProperties[
1339
+ keyRequestProperties
1340
+ ]
1341
+ }
1342
+ >
1343
+ <option value="">
1344
+ -- choose --
1345
+ </option>
1346
+ {Object.entries(valueUserTags)
1347
+ .filter(
1348
+ ([key, val]) =>
1349
+ "defaultValue" in val,
1350
+ )
1351
+ .map(([key, val]) => (
1352
+ <option
1353
+ key={key}
1354
+ value={key}
1355
+ >
1356
+ {val.defaultValue
1357
+ ? key
1358
+ : ""}
1359
+ </option>
1360
+ ))}
1361
+ <option value="createUserTag">
1362
+ create new userTag
1363
+ </option>
1364
+ </select>
1365
+
1366
+ {logicalElementObj[
1367
+ logicalElementOutput.active
1368
+ ].requestProperties[
1369
+ keyRequestProperties
1370
+ ] === null && (
1371
+ <>
1372
+ <p>createUserTag </p>
1373
+ <fieldset>
1374
+ <legend>
1375
+ nameUserTag
1376
+ </legend>
1377
+
1378
+ <input
1379
+ onChange={(e) =>
1380
+ handleUpdateNewValueRequestProperties(
1381
+ e,
1382
+ "name",
1383
+ keyRequestProperties,
1384
+ )
1385
+ }
1386
+ ></input>
1387
+ </fieldset>
1388
+ <fieldset>
1389
+ <legend>
1390
+ defaultValue
1391
+ </legend>
1392
+
1393
+ <input
1394
+ onChange={(e) =>
1395
+ handleUpdateNewValueRequestProperties(
1396
+ e,
1397
+ "defaultValue",
1398
+ keyRequestProperties,
1399
+ )
1400
+ }
1401
+ ></input>
1402
+ </fieldset>
1403
+ <IzaraDivStyle
1404
+ styletags={createStyleDefualtTags(
1405
+ "gridColumn",
1406
+ "",
1407
+ "11",
1408
+ )}
1409
+ >
1410
+ <button
1411
+ onClick={(e) =>
1412
+ handleCreateNewValueRequestProperties(
1413
+ e,
1414
+ keyRequestProperties,
1415
+ )
1416
+ }
1417
+ >
1418
+ create
1419
+ </button>
1420
+ </IzaraDivStyle>
1421
+ </>
1422
+ )}
1423
+ </>
1424
+ ),
1425
+ )}
1426
+ </>
1427
+ )}
1428
+ </>
1429
+ )}
1430
+ <></>
1431
+ </>
1432
+ ))}
1433
+ <br></br>
1434
+ {logicalElementObj[logicalElementOutput.active]
1435
+ .childLogicalElementId === null ? (
1436
+ <button
1437
+ onClick={(e) =>
1438
+ handleAddLogicalElement("addChild")
1439
+ }
1440
+ >
1441
+ create Child
1442
+ </button>
1443
+ ) : (
1444
+ <button
1445
+ onClick={(e) =>
1446
+ hadleActiveLogicalElement(
1447
+ logicalElementObj[
1448
+ logicalElementOutput.active
1449
+ ].childLogicalElementId,
1450
+ )
1451
+ }
1452
+ >
1453
+ view Child
1454
+ </button>
1455
+ )}
1456
+ </IzaraDivStyle>
1457
+ )}
1458
+ {logicalElementObj[logicalElementOutput.active]
1459
+ .logicalElementType === "translateIds" && (
1460
+ <IzaraDivStyle
1461
+ styletags={createStyleDefualtTags(
1462
+ "background",
1463
+ "scroll",
1464
+ "div",
1465
+ )}
1466
+ >
1467
+ {!allObjTypesLinkConfigs[
1468
+ logicalElementObj[logicalElementOutput.active]
1469
+ .previousLogicalElementId === null
1470
+ ? createObjTypeConcat(objTypeMain)
1471
+ : createObjTypeConcat(
1472
+ findObjTypeStep(
1473
+ logicalElementOutput.active,
1474
+ logicalElementObj,
1475
+ ),
1476
+ )
1477
+ ] ? (
1478
+ <IzaraDivStyle
1479
+ styletags={createStyleDefualtTags(
1480
+ "loadingCircle",
1481
+ "20px",
1482
+ "template",
1483
+ )}
1484
+ ></IzaraDivStyle>
1485
+ ) : (
1486
+ <>
1487
+ <p> relationship type:</p>
1488
+ <select
1489
+ value={JSON.stringify(
1490
+ logicalElementObj[
1491
+ logicalElementOutput.active
1492
+ ].pathLinkType.relType,
1493
+ )}
1494
+ onChange={(e) =>
1495
+ handelSelectRelTypeAndDirection(e)
1496
+ }
1497
+ >
1498
+ <option
1499
+ disabled={
1500
+ logicalElementObj[
1501
+ logicalElementOutput.active
1502
+ ].pathLinkType.relType !== ""
1503
+ }
1504
+ value=""
1505
+ >
1506
+ -- relType --
1507
+ </option>
1508
+
1509
+ {allObjTypesLinkConfigs[
1510
+ createObjTypeConcat(
1511
+ logicalElementObj[
1512
+ logicalElementOutput.active
1513
+ ].objType,
1514
+ )
1515
+ ].map((data, index) => (
1516
+ <>
1517
+ <option
1518
+ key={index}
1519
+ value={JSON.stringify(data.relType)}
1520
+ >
1521
+ {createRelTypeConcat(data.relType)}
1522
+ </option>
1523
+ </>
1524
+ ))}
1525
+ </select>
1526
+
1527
+ {logicalElementObj[
1528
+ logicalElementOutput.active
1529
+ ]?.pathLinkType.objType && (
1530
+ <>
1531
+ <p> object type:</p>
1532
+ <span>
1533
+ {createObjTypeConcat(
1534
+ logicalElementObj[
1535
+ logicalElementOutput.active
1536
+ ].pathLinkType.objType,
1537
+ )}
1538
+ </span>
1539
+ <p>direction</p>
1540
+ <span>
1541
+ {
1542
+ logicalElementObj[
1543
+ logicalElementOutput.active
1544
+ ].pathLinkType.direction
1545
+ }
1546
+ </span>
1547
+ </>
1548
+ )}
1549
+ </>
1550
+ )}
1551
+
1552
+ {allObjTypesLinkConfigs[
1553
+ createObjTypeConcat(
1554
+ logicalElementObj[logicalElementOutput.active]
1555
+ .objType,
1556
+ )
1557
+ ].map((data, index) => (
1558
+ <>
1559
+ {_.isEqual(
1560
+ data.relType,
1561
+ logicalElementObj[
1562
+ logicalElementOutput.active
1563
+ ]?.pathLinkType.relType,
1564
+ ) && (
1565
+ <>
1566
+ {data.requestProperties && (
1567
+ <>
1568
+ {Object.keys(
1569
+ data.requestProperties,
1570
+ ).map(
1571
+ (keyRequestProperties, index) => (
1572
+ <>
1573
+ <p>{keyRequestProperties}</p>
1574
+ <select
1575
+ onChange={(e) =>
1576
+ handleValueSelect(
1577
+ e,
1578
+ keyRequestProperties,
1579
+ )
1580
+ }
1581
+ value={
1582
+ logicalElementObj[
1583
+ logicalElementOutput
1584
+ .active
1585
+ ].requestProperties[
1586
+ keyRequestProperties
1587
+ ]
1588
+ }
1589
+ >
1590
+ <option value="">
1591
+ -- choose --
1592
+ </option>
1593
+ {Object.entries(valueUserTags)
1594
+ .filter(
1595
+ ([key, val]) =>
1596
+ "defaultValue" in val,
1597
+ )
1598
+ .map(([key, val]) => (
1599
+ <option
1600
+ key={key}
1601
+ value={key}
1602
+ >
1603
+ {val.defaultValue
1604
+ ? key
1605
+ : ""}
1606
+ </option>
1607
+ ))}
1608
+ <option value="createUserTag">
1609
+ create new userTag
1610
+ </option>
1611
+ </select>
1612
+
1613
+ {logicalElementObj[
1614
+ logicalElementOutput.active
1615
+ ].requestProperties[
1616
+ keyRequestProperties
1617
+ ] === null && (
1618
+ <>
1619
+ <p>createUserTag </p>
1620
+ <fieldset>
1621
+ <legend>
1622
+ nameUserTag
1623
+ </legend>
1624
+
1625
+ <input
1626
+ onChange={(e) =>
1627
+ handleUpdateNewValueRequestProperties(
1628
+ e,
1629
+ "name",
1630
+ keyRequestProperties,
1631
+ )
1632
+ }
1633
+ ></input>
1634
+ </fieldset>
1635
+ <fieldset>
1636
+ <legend>
1637
+ defaultValue
1638
+ </legend>
1639
+
1640
+ <input
1641
+ onChange={(e) =>
1642
+ handleUpdateNewValueRequestProperties(
1643
+ e,
1644
+ "defaultValue",
1645
+ keyRequestProperties,
1646
+ )
1647
+ }
1648
+ ></input>
1649
+ </fieldset>
1650
+ <IzaraDivStyle
1651
+ styletags={createStyleDefualtTags(
1652
+ "gridColumn",
1653
+ "",
1654
+ "11",
1655
+ )}
1656
+ >
1657
+ <button
1658
+ onClick={(e) =>
1659
+ handleCreateNewValueRequestProperties(
1660
+ e,
1661
+ keyRequestProperties,
1662
+ )
1663
+ }
1664
+ >
1665
+ create
1666
+ </button>
1667
+ </IzaraDivStyle>
1668
+ </>
1669
+ )}
1670
+ </>
1671
+ ),
1672
+ )}
1673
+ </>
1674
+ )}
1675
+ {logicalElementObj[
1676
+ logicalElementOutput.active
1677
+ ].childIdentifiers.map(
1678
+ (
1679
+ valueChildIdentifiers,
1680
+ idChildIdentifiers,
1681
+ ) => (
1682
+ <>
1683
+ {JSON.stringify(
1684
+ valueChildIdentifiers,
1685
+ )}
1686
+ </>
1687
+ ),
1688
+ )}
1689
+ {Object.keys(fieldValueUserTag).length >
1690
+ 0 && (
1691
+ <>
1692
+ <p> fieldName:</p>
1693
+ <select
1694
+ value={fieldValueUserTag.fieldName}
1695
+ onChange={(e) => {
1696
+ handleSelectFieldNameAndValueUserTag(
1697
+ e,
1698
+ "fieldName",
1699
+ );
1700
+ }}
1701
+ >
1702
+ <option disabled value="">
1703
+ -- fieldName --
1704
+ </option>
1705
+ {resultFieldName[
1706
+ createObjTypeConcat(
1707
+ logicalElementObj[
1708
+ logicalElementOutput.active
1709
+ ].pathLinkType.objType,
1710
+ )
1711
+ ] && (
1712
+ <>
1713
+ {Object.keys(
1714
+ resultFieldName[
1715
+ createObjTypeConcat(
1716
+ logicalElementObj[
1717
+ logicalElementOutput
1718
+ .active
1719
+ ].pathLinkType.objType,
1720
+ )
1721
+ ].fieldNames,
1722
+ ).map((key) => (
1723
+ <option key={key} value={key}>
1724
+ {key}
1725
+ </option>
1726
+ ))}
1727
+ </>
1728
+ )}
1729
+ </select>
1730
+ <UserTagsSelectAndCreateComponent
1731
+ valueUserTags={valueUserTags}
1732
+ parentOutputId={parentOutputId}
1733
+ handleSelectUserTag={(e) =>
1734
+ handleSelectFieldNameAndValueUserTag(
1735
+ e,
1736
+ "valueUserTag",
1737
+ )
1738
+ }
1739
+ valueSelect={
1740
+ fieldValueUserTag.valueUserTag
1741
+ }
1742
+ />
1743
+ <button
1744
+ onClick={handleSaveChildIdentifiers}
1745
+ >
1746
+ save
1747
+ </button>
1748
+ </>
1749
+ )}
1750
+ <button onClick={handleAddFieldName}>
1751
+ add childIdentifiers
1752
+ </button>
1753
+ </>
1754
+ )}
1755
+ <></>
1756
+ </>
1757
+ ))}
1758
+ </IzaraDivStyle>
1759
+ )}
1760
+ {logicalElementObj[logicalElementOutput.active]
1761
+ .logicalElementType === "logical" && (
1762
+ <>
1763
+ {resultFieldName && (
1764
+ <>
1765
+ {!resultFieldName[
1766
+ logicalElementObj[
1767
+ logicalElementOutput.active
1768
+ ].previousLogicalElementId === null
1769
+ ? createObjTypeConcat(objTypeMain)
1770
+ : createObjTypeConcat(
1771
+ findObjTypeStep(
1772
+ logicalElementOutput.active,
1773
+ logicalElementObj,
1774
+ ),
1775
+ )
1776
+ ] ? (
1777
+ <IzaraDivStyle
1778
+ styletags={createStyleDefualtTags(
1779
+ "loadingCircle",
1780
+ "20px",
1781
+ "template",
1782
+ )}
1783
+ ></IzaraDivStyle>
1784
+ ) : (
1785
+ <>
1786
+ <IzaraDivStyle
1787
+ styletags={createStyleDefualtTags(
1788
+ "background",
1789
+ "scroll",
1790
+ "div",
1791
+ )}
1792
+ >
1793
+ {resultFieldName[
1794
+ logicalElementObj[
1795
+ logicalElementOutput.active
1796
+ ].previousLogicalElementId === null
1797
+ ? createObjTypeConcat(objTypeMain)
1798
+ : createObjTypeConcat(
1799
+ findObjTypeStep(
1800
+ logicalElementOutput.active,
1801
+ logicalElementObj,
1802
+ ),
1803
+ )
1804
+ ].identifiers.map(
1805
+ (identifier, index) => (
1806
+ <>
1807
+ {identifier.type ===
1808
+ "partitionKey" && (
1809
+ <>
1810
+ FieldName :
1811
+ <b>{identifier.fieldName}</b>
1812
+ <UserTagsSelectAndCreateComponent
1813
+ valueUserTags={
1814
+ valueUserTags
1815
+ }
1816
+ parentOutputId={
1817
+ parentOutputId
1818
+ }
1819
+ handleSelectUserTag={(e) =>
1820
+ selectValueUserTagForPartitionKey(
1821
+ e,
1822
+ identifier.fieldName,
1823
+ )
1824
+ }
1825
+ valueSelect={
1826
+ logicalElementObj[
1827
+ logicalElementOutput
1828
+ .active
1829
+ ]
1830
+ ?.partitionKeyValueUserTags[
1831
+ identifier.fieldName
1832
+ ]
1833
+ }
1834
+ />
1835
+ </>
1836
+ )}
1837
+ </>
1838
+ ),
1839
+ )}
1840
+ {/*
1841
+ {Object.entries(
1842
+ logicalElementObj[
1843
+ logicalElementOutput.active
1844
+ ].partitionKeyValueUserTags,
1845
+ ).map(([key, value]) => (
1846
+ <div key={key}>
1847
+ {key} - {value}
1848
+ <button
1849
+ onClick={(e) => {
1850
+ handleRemovePartitionKeyValueUserTags(
1851
+ key,
1852
+ );
1853
+ }}
1854
+ >
1855
+ X
1856
+ </button>
1857
+ </div>
1858
+ ))} */}
1859
+
1860
+ {/* <p> fieldname:</p>
1861
+ <select
1862
+ value={
1863
+ logicalElementObj[
1864
+ logicalElementOutput.active
1865
+ ].fieldName
1866
+ }
1867
+ onChange={(e) => {
1868
+ handleSelectFieldName(
1869
+ e,
1870
+ "fieldName"
1871
+ );
1872
+ }}
1873
+ >
1874
+ <option value="">
1875
+ -- fieldName --
1876
+ </option>
1877
+ {Object.keys(
1878
+ resultFieldName[
1879
+ logicalElementObj[
1880
+ logicalElementOutput.active
1881
+ ].previousLogicalElementId ===
1882
+ null
1883
+ ? createObjTypeConcat(
1884
+ objTypeMain
1885
+ )
1886
+ : createObjTypeConcat(
1887
+ findObjTypeStep(
1888
+ logicalElementOutput.active,
1889
+ logicalElementObj
1890
+ )
1891
+ )
1892
+ ].fieldNames
1893
+ ).map((key) => (
1894
+ <option key={key} value={key}>
1895
+ {key}
1896
+ </option>
1897
+ ))}
1898
+ </select> */}
1899
+
1900
+ {resultFieldName[
1901
+ logicalElementObj[
1902
+ logicalElementOutput.active
1903
+ ].previousLogicalElementId === null
1904
+ ? createObjTypeConcat(objTypeMain)
1905
+ : createObjTypeConcat(
1906
+ findObjTypeStep(
1907
+ logicalElementOutput.active,
1908
+ logicalElementObj,
1909
+ ),
1910
+ )
1911
+ ].identifiers.map(
1912
+ (identifier, index) => (
1913
+ <>
1914
+ {/* {JSON.stringify(identifier.type)} */}
1915
+ {identifier.type ===
1916
+ "partitionKey" ? (
1917
+ <>
1918
+ {Object.keys(
1919
+ fieldValueUserTag,
1920
+ ).length > 0 && (
1921
+ <>
1922
+ <p>
1923
+ {" "}
1924
+ conditionalFieldValues:
1925
+ </p>
1926
+ <select
1927
+ value={
1928
+ fieldValueUserTag.fieldName
1929
+ }
1930
+ onChange={(e) => {
1931
+ handleSelectFieldNameAndValueUserTag(
1932
+ e,
1933
+ "fieldName",
1934
+ );
1935
+ }}
1936
+ >
1937
+ <option
1938
+ disabled
1939
+ value=""
1940
+ >
1941
+ -- fieldName --
1942
+ </option>
1943
+
1944
+ {Object.keys(
1945
+ resultFieldName[
1946
+ logicalElementObj[
1947
+ logicalElementOutput
1948
+ .active
1949
+ ]
1950
+ .previousLogicalElementId ===
1951
+ null
1952
+ ? createObjTypeConcat(
1953
+ objTypeMain,
1954
+ )
1955
+ : createObjTypeConcat(
1956
+ findObjTypeStep(
1957
+ logicalElementOutput.active,
1958
+ logicalElementObj,
1959
+ ),
1960
+ )
1961
+ ].fieldNames,
1962
+ ).map((key) => (
1963
+ <>
1964
+ {console.log(
1965
+ "ewyyydsydfd",
1966
+ identifier.fieldName,
1967
+ key,
1968
+ )}
1969
+ {identifier.fieldName !==
1970
+ key && (
1971
+ <option
1972
+ key={key}
1973
+ value={key}
1974
+ >
1975
+ {key}
1976
+ </option>
1977
+ )}
1978
+ </>
1979
+ ))}
1980
+ </select>
1981
+ <UserTagsSelectAndCreateComponent
1982
+ valueUserTags={
1983
+ valueUserTags
1984
+ }
1985
+ parentOutputId={
1986
+ parentOutputId
1987
+ }
1988
+ handleSelectUserTag={(
1989
+ e,
1990
+ ) =>
1991
+ handleSelectFieldNameAndValueUserTag(
1992
+ e,
1993
+ "valueUserTag",
1994
+ )
1995
+ }
1996
+ valueSelect={
1997
+ fieldValueUserTag.valueUserTag
1998
+ }
1999
+ />
2000
+ <button
2001
+ onClick={
2002
+ handleSaveFieldValueUserTag
2003
+ }
2004
+ >
2005
+ save
2006
+ </button>
2007
+ </>
2008
+ )}
2009
+ <button
2010
+ onClick={handleAddFieldName}
2011
+ >
2012
+ add conditionalFieldValues
2013
+ </button>
2014
+ <br></br>
2015
+ {logicalElementObj[
2016
+ logicalElementOutput.active
2017
+ ]?.conditionalFieldValues && (
2018
+ <>
2019
+ {logicalElementObj[
2020
+ logicalElementOutput
2021
+ .active
2022
+ ]?.conditionalFieldValues.map(
2023
+ (
2024
+ keyFieldName,
2025
+ indexFieldName,
2026
+ ) => (
2027
+ <>
2028
+ {
2029
+ keyFieldName.fieldname
2030
+ }
2031
+ <button>X</button>
2032
+ </>
2033
+ ),
2034
+ )}
2035
+ </>
2036
+ )}
2037
+ </>
2038
+ ) : (
2039
+ <>
2040
+ <p> comparison:</p>
2041
+
2042
+ <select
2043
+ value={
2044
+ logicalElementObj[
2045
+ logicalElementOutput
2046
+ .active
2047
+ ].comparison
2048
+ }
2049
+ onChange={(e) => {
2050
+ handleSelectFieldName(
2051
+ e,
2052
+ "comparison",
2053
+ );
2054
+ }}
2055
+ >
2056
+ <option
2057
+ disabled={
2058
+ logicalElementObj[
2059
+ logicalElementOutput
2060
+ .active
2061
+ ].comparison !== ""
2062
+ }
2063
+ value=""
2064
+ >
2065
+ choose comparison
2066
+ </option>
2067
+
2068
+ {comparison.map((key) => (
2069
+ <option
2070
+ key={key}
2071
+ value={key}
2072
+ >
2073
+ {key}
2074
+ </option>
2075
+ ))}
2076
+ </select>
2077
+ <p>sortKeyValueUserTags :</p>
2078
+
2079
+ <select
2080
+ onChange={(e) =>
2081
+ handleSelectFieldName(
2082
+ e,
2083
+ "sortKeyValueUserTags",
2084
+ )
2085
+ }
2086
+ value={
2087
+ logicalElementObj[
2088
+ logicalElementOutput
2089
+ .active
2090
+ ].valueUserTag
2091
+ }
2092
+ >
2093
+ <option value="">
2094
+ -- choose --
2095
+ </option>
2096
+ <option value="createUserTag">
2097
+ create new userTag
2098
+ </option>
2099
+ {perParentIdentifierFieldname ? (
2100
+ <>
2101
+ {Object.entries(
2102
+ valueUserTags,
2103
+ )
2104
+ .filter(
2105
+ ([key, val]) =>
2106
+ "defaultValue" ||
2107
+ "perParentIdentifierFieldname" in
2108
+ val,
2109
+ )
2110
+ .map(([key, val]) => (
2111
+ <option
2112
+ key={key}
2113
+ value={key}
2114
+ >
2115
+ {key}
2116
+ {/* {val.defaultValue ||
2117
+ val.perParentIdentifierFieldname
2118
+ ? key
2119
+ : ""} */}
2120
+ </option>
2121
+ ))}
2122
+ </>
2123
+ ) : (
2124
+ <>
2125
+ {Object.entries(
2126
+ valueDataUserTags,
2127
+ )
2128
+ .filter(
2129
+ ([key, val]) =>
2130
+ "defaultValue" in
2131
+ val,
2132
+ )
2133
+ .map(([key, val]) => (
2134
+ <option
2135
+ key={key}
2136
+ value={key}
2137
+ >
2138
+ {val.defaultValue
2139
+ ? key
2140
+ : ""}
2141
+ </option>
2142
+ ))}
2143
+ </>
2144
+ )}
2145
+ </select>
2146
+ </>
2147
+ )}
2148
+ </>
2149
+ ),
2150
+ )}
2151
+
2152
+ {logicalElementOutput.status ===
2153
+ "createUserTag" && (
2154
+ <>
2155
+ <hr></hr>
2156
+ <p>createUserTag </p>
2157
+ {perParentIdentifierFieldname && (
2158
+ <select
2159
+ onChange={(e) =>
2160
+ handleSelectCreateNewValue(e)
2161
+ }
2162
+ >
2163
+ <option value="defaultValue">
2164
+ defaultValue
2165
+ </option>
2166
+ <option value="perParentIdentifier">
2167
+ perParentIdentifier
2168
+ </option>
2169
+ </select>
2170
+ )}
2171
+ <fieldset>
2172
+ <legend>nameUserTag</legend>
2173
+
2174
+ <input
2175
+ onChange={(e) =>
2176
+ handleUpdateNameNewValue(e)
2177
+ }
2178
+ ></input>
2179
+ </fieldset>
2180
+
2181
+ {newUserTags.obj.hasOwnProperty(
2182
+ "defaultValue",
2183
+ ) ? (
2184
+ <>
2185
+ <fieldset>
2186
+ <legend>defaultValue</legend>
2187
+
2188
+ <input
2189
+ onChange={(e) =>
2190
+ handleUpdateNewValue(
2191
+ e,
2192
+ "defaultValue",
2193
+ )
2194
+ }
2195
+ ></input>
2196
+ </fieldset>
2197
+ </>
2198
+ ) : (
2199
+ <>
2200
+ <fieldset>
2201
+ <legend>
2202
+ perParentIdentifierFieldname
2203
+ </legend>
2204
+
2205
+ <select
2206
+ onChange={(e) =>
2207
+ handleUpdateNewValue(
2208
+ e,
2209
+ "perParentIdentifierFieldname",
2210
+ )
2211
+ }
2212
+ >
2213
+ {perParentIdentifierFieldname.map(
2214
+ (identifier, index) => (
2215
+ <option>
2216
+ {identifier.fieldName}
2217
+ </option>
2218
+ ),
2219
+ )}
2220
+ </select>
2221
+ </fieldset>
2222
+ </>
2223
+ )}
2224
+
2225
+ <IzaraDivStyle
2226
+ styletags={createStyleDefualtTags(
2227
+ "gridColumn",
2228
+ "",
2229
+ "11",
2230
+ )}
2231
+ >
2232
+ <button
2233
+ onClick={(e) =>
2234
+ handleCreateNewValue(e)
2235
+ }
2236
+ >
2237
+ create
2238
+ </button>
2239
+ </IzaraDivStyle>
2240
+ </>
2241
+ )}
2242
+ </IzaraDivStyle>
2243
+ </>
2244
+ )}
2245
+ </>
2246
+ )}
2247
+ </>
2248
+ )}
2249
+ {logicalElementObj[logicalElementOutput.active]
2250
+ .logicalElementType === "traversal" && (
2251
+ <>
2252
+ {modalTraversal && (
2253
+ <ModalLinkStepsComponent
2254
+ titleModal={"traversal"}
2255
+ statusModalFunc={statusModalTraversal}
2256
+ objTypeMain={objTypeMain}
2257
+ objConfigUseCase={objConfigUseCase}
2258
+ nameReducer={nameReducer}
2259
+ parentOutputId={parentOutputId}
2260
+ // successFunc={successRequiredDataConfig}
2261
+ collectObjectLinksWithRequestProperties={
2262
+ collectObjectLinksWithRequestProperties
2263
+ }
2264
+ collectObjectSchemaWithHierarchy={
2265
+ collectObjectSchemaWithHierarchy
2266
+ }
2267
+ valueUserTags={valueUserTags}
2268
+ // nameObjectLinkStepEdit={
2269
+ // stausModalSortFiled === true
2270
+ // ? ""
2271
+ // : stausModalSortFiled
2272
+ // }
2273
+ //----------------------------------
2274
+ ComponentUseCase={TraversalComponent}
2275
+ LastStepsComponentUseCase={
2276
+ FieldValueUserTagsComponent
2277
+ }
2278
+ successFuncUseCase={
2279
+ sussessComplexFilterTypeTraversal
2280
+ }
2281
+ // nameUserTag={undefined}
2282
+ />
2283
+ )}
2284
+ <fieldset></fieldset>
2285
+
2286
+ <button
2287
+ onClick={() =>
2288
+ statusModalTraversal("traversal")
2289
+ }
2290
+ >
2291
+ add traversal
2292
+ </button>
2293
+ </>
2294
+ )}
2295
+ </IzaraDivStyle>
2296
+ </>
2297
+ </IzaraDivStyle>
2298
+
2299
+ {logicalElementObj[logicalElementOutput.active]
2300
+ .logicalElementType === "operation" && (
2301
+ <IzaraDivStyle
2302
+ styletags={createStyleDefualtTags(
2303
+ "background",
2304
+ "scroll",
2305
+ "div",
2306
+ )}
2307
+ >
2308
+ <fieldset>
2309
+ <legend>operation</legend>
2310
+ <select
2311
+ onChange={handleOperationChange}
2312
+ value={
2313
+ logicalElementObj[logicalElementOutput.active]
2314
+ .operation
2315
+ }
2316
+ >
2317
+ <option>--- choose ---</option>
2318
+ {operation.map((key, id) => (
2319
+ <option key={key}>{key}</option>
2320
+ ))}
2321
+ </select>
2322
+ </fieldset>
2323
+ </IzaraDivStyle>
2324
+ )}
2325
+ </>
2326
+ ) : (
2327
+ <>not found select</>
2328
+ )}
2329
+ </div>
2330
+ </IzaraDivStyle>
2331
+
2332
+ <IzaraDivStyle
2333
+ styletags={createStyleDefualtTags("gridColumn", "", "11")}
2334
+ >
2335
+ <IzaraButtonStyle
2336
+ styletags={createStyleDefualtTags("modal", "", "button")}
2337
+ type="button"
2338
+ onClick={(e) => handelCreateFilterElement()}
2339
+ >
2340
+ save
2341
+ </IzaraButtonStyle>
2342
+
2343
+ <IzaraButtonStyle
2344
+ styletags={createStyleDefualtTags("modal", "", "button")}
2345
+ type="button"
2346
+ onClick={(e) => statusModal(false)}
2347
+ >
2348
+ cancel
2349
+ </IzaraButtonStyle>
2350
+ </IzaraDivStyle>
2351
+ </IzaraDivStyle>
2352
+ </IzaraDivStyle>
2353
+ </IzaraDivStyle>
2354
+ </div>
2355
+ );
2356
+ };
2357
+
2358
+ export const TraversalComponent = ({
2359
+ linkSteps,
2360
+ setLinkSteps,
2361
+ linkStepsOutput,
2362
+ resultFieldName,
2363
+ valueUserTags,
2364
+ objTypeMain,
2365
+ parentOutputId,
2366
+ }) => {
2367
+ function handleHopsPassObjType(e) {
2368
+ setLinkSteps((linkSteps) => {
2369
+ linkSteps[linkStepsOutput.active].hopsPassObjType = e.target.checked;
2370
+ });
2371
+ }
2372
+
2373
+ function handleHopsStartEnd(e, type) {
2374
+ setLinkSteps((linkSteps) => {
2375
+ linkSteps[linkStepsOutput.active][type] = +e.target.value;
2376
+ });
2377
+ }
2378
+
2379
+ return (
2380
+ <div>
2381
+ {linkStepsOutput.status !== "lastStep" && (
2382
+ <>
2383
+ <fieldset>
2384
+ <legend>hopsPassObjType</legend>
2385
+ <input
2386
+ type="checkbox"
2387
+ checked={
2388
+ linkSteps[linkStepsOutput.active]?.hopsPassObjType || false
2389
+ }
2390
+ onChange={handleHopsPassObjType}
2391
+ />
2392
+ </fieldset>
2393
+ <fieldset>
2394
+ <legend>hopsStart</legend>
2395
+ <input
2396
+ type="number"
2397
+ value={linkSteps[linkStepsOutput.active]?.hopsStart || ""}
2398
+ onChange={(e) => handleHopsStartEnd(e, "hopsStart")}
2399
+ min={1}
2400
+ disabled={
2401
+ linkSteps[linkStepsOutput.active]?.hopsPassObjType === true
2402
+ }
2403
+ />
2404
+ </fieldset>
2405
+ <fieldset>
2406
+ <legend>hopsEnd</legend>
2407
+ <input
2408
+ type="number"
2409
+ value={linkSteps[linkStepsOutput.active]?.hopsEnd || ""}
2410
+ onChange={(e) => handleHopsStartEnd(e, "hopsEnd")}
2411
+ min={1}
2412
+ disabled={
2413
+ linkSteps[linkStepsOutput.active]?.hopsPassObjType === true
2414
+ }
2415
+ />
2416
+ </fieldset>
2417
+ </>
2418
+ )}
2419
+
2420
+ {/* <FieldValueUserTagsComponent
2421
+ resultFieldName={resultFieldName}
2422
+ linkSteps={linkSteps}
2423
+ setLinkSteps={setLinkSteps}
2424
+ linkStepsOutput={linkStepsOutput}
2425
+ objTypeMain={objTypeMain}
2426
+ valueUserTags={valueUserTags}
2427
+ parentOutputId={parentOutputId}
2428
+ /> */}
2429
+ </div>
2430
+ );
2431
+ };
2432
+
2433
+ export const FieldValueUserTagsComponent = ({
2434
+ linkSteps,
2435
+ setLinkSteps,
2436
+ linkStepsOutput,
2437
+ resultFieldName,
2438
+ objTypeMain,
2439
+ valueUserTags,
2440
+ parentOutputId,
2441
+ }) => {
2442
+ console.log(
2443
+ linkSteps[linkStepsOutput.active],
2444
+ "last step:FieldValueUserTagsComponent",
2445
+ );
2446
+ const [fieldValueUserTag, setFieldValueUserTag] = useImmer({
2447
+ // fieldName: "",
2448
+ // valueUserTag: "",
2449
+ });
2450
+
2451
+ function handleSelectFieldNameAndValueUserTag(e, type) {
2452
+ let value = e.target.value;
2453
+ console.log("type:sdadfdsfd ", type);
2454
+ console.log("value:sdadfdsfd ", value);
2455
+
2456
+ setFieldValueUserTag((fieldValueUserTag) => {
2457
+ fieldValueUserTag[type] = value;
2458
+ });
2459
+ }
2460
+
2461
+ function handleAddFieldName() {
2462
+ if (linkSteps[linkStepsOutput.active].fieldValueUserTags === undefined) {
2463
+ setLinkSteps((linkSteps) => {
2464
+ linkSteps[linkStepsOutput.active].fieldValueUserTags = [];
2465
+ delete linkSteps[linkStepsOutput.active].lastStep;
2466
+ });
2467
+ }
2468
+ setFieldValueUserTag({
2469
+ fieldName: "",
2470
+ valueUserTag: "",
2471
+ });
2472
+ }
2473
+
2474
+ function handleSaveFieldValueUserTag() {
2475
+ setLinkSteps((linkSteps) => {
2476
+ linkSteps[linkStepsOutput.active].fieldValueUserTags.push({
2477
+ [fieldValueUserTag.fieldName]: fieldValueUserTag.valueUserTag,
2478
+ });
2479
+ });
2480
+ setFieldValueUserTag({});
2481
+ }
2482
+ console.log("fieldValueUserTag:efdgcvgfdrg ", fieldValueUserTag);
2483
+ console.log("valueUserTags:FieldValueUserTagsComponent ", valueUserTags);
2484
+ return (
2485
+ <>
2486
+ {/* {(linkStepsOutput.status === "lastStep" ||
2487
+ linkSteps[linkStepsOutput.active]?.fieldValueUserTags) && ( */}
2488
+ <>
2489
+ {!resultFieldName[
2490
+ linkStepsOutput.active === 0
2491
+ ? createObjTypeConcat(objTypeMain)
2492
+ : createObjTypeConcat(
2493
+ linkSteps[linkStepsOutput.active - 1].pathLinkType.objType,
2494
+ )
2495
+ ] ? (
2496
+ <IzaraDivStyle
2497
+ styletags={createStyleDefualtTags(
2498
+ "loadingCircle",
2499
+ "20px",
2500
+ "template",
2501
+ )}
2502
+ ></IzaraDivStyle>
2503
+ ) : (
2504
+ <>
2505
+ <IzaraDivStyle
2506
+ styletags={createStyleDefualtTags("background", "scroll", "div")}
2507
+ >
2508
+ {console.log(
2509
+ linkSteps[linkStepsOutput.active]?.fieldValueUserTags,
2510
+ "dfjiusf0sdjfgop",
2511
+ )}
2512
+ {linkSteps[linkStepsOutput.active]?.fieldValueUserTags !==
2513
+ undefined && (
2514
+ <>
2515
+ {linkSteps[linkStepsOutput.active]?.fieldValueUserTags?.map(
2516
+ (fieldValueUserTag, index) => (
2517
+ <div key={index}>
2518
+ {console.log(fieldValueUserTag, "sdafdfsdfewrse")}
2519
+ <p>{JSON.stringify(fieldValueUserTag)}</p>
2520
+ </div>
2521
+ ),
2522
+ )}
2523
+ </>
2524
+ )}
2525
+
2526
+ {Object.keys(fieldValueUserTag).length > 0 && (
2527
+ <>
2528
+ <p> fieldName:</p>
2529
+ <select
2530
+ value={fieldValueUserTag.fieldName}
2531
+ onChange={(e) => {
2532
+ handleSelectFieldNameAndValueUserTag(e, "fieldName");
2533
+ }}
2534
+ >
2535
+ <option disabled value="">
2536
+ -- fieldName --
2537
+ </option>
2538
+ {Object.keys(
2539
+ resultFieldName[
2540
+ linkStepsOutput.active === 0
2541
+ ? createObjTypeConcat(objTypeMain)
2542
+ : createObjTypeConcat(
2543
+ linkSteps[linkStepsOutput.active - 1].pathLinkType
2544
+ .objType,
2545
+ )
2546
+ ].fieldNames,
2547
+ ).map((key) => (
2548
+ <option key={key} value={key}>
2549
+ {key}
2550
+ </option>
2551
+ ))}
2552
+ </select>
2553
+ <UserTagsSelectAndCreateComponent
2554
+ valueUserTags={valueUserTags}
2555
+ parentOutputId={parentOutputId}
2556
+ handleSelectUserTag={(e) =>
2557
+ handleSelectFieldNameAndValueUserTag(e, "valueUserTag")
2558
+ }
2559
+ valueSelect={fieldValueUserTag.valueUserTag}
2560
+ />
2561
+ <button onClick={handleSaveFieldValueUserTag}>save</button>
2562
+ </>
2563
+ )}
2564
+ <button onClick={handleAddFieldName}>add fieldname</button>
2565
+ </IzaraDivStyle>
2566
+ </>
2567
+ )}
2568
+ </>
2569
+ {/* )} */}
2570
+ </>
2571
+ );
2572
+ };