@izara_frontend/shared-complex-filter 1.0.3 → 1.0.4

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.
@@ -13,37 +13,24 @@ import {
13
13
  } from "@izaraFrontends/styles";
14
14
  import { useImmer } from "use-immer";
15
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
16
  import { useDispatch, useSelector } from "react-redux";
28
17
  import { nanoid } from "nanoid";
29
18
  import { ModalLinkStepsComponent } from "../linkSteps/modalLinkStepsComponent.jsx";
30
19
  import { UserTagsSelectAndCreateComponent } from "../valueUserTags/valueUserTagsComponent.jsx";
31
20
  import { successTraversalConfig } from "../function/createActionLibCreateLinkStepAndComplexFilter";
32
21
 
33
- // import { ModalRequiredData } from "./modalRequiredData";
34
- // import _, { flatMap, last } from "lodash";
35
22
  var hash = require("object-hash");
36
23
 
37
24
  function createObjTypeConcat(objType) {
38
- console.log("objType:sdsadwsd ", objType);
25
+
39
26
  return `${objType?.serviceTag}_${objType?.objectType}`;
40
27
  }
41
28
  function createRelTypeConcat(relType) {
42
- console.log("objType:sdsadwsd ", relType);
29
+
43
30
  return `${relType?.serviceTag}_${relType?.relationshipTag}`;
44
31
  }
45
32
  function objTypeFromObjTypeConcat(objTypeConcat) {
46
- console.log("objTypeConcat:aeaeaeww ", objTypeConcat);
33
+
47
34
  let result = objTypeConcat.split("_");
48
35
 
49
36
  if (result.length !== 2) {
@@ -58,8 +45,8 @@ function objTypeFromObjTypeConcat(objTypeConcat) {
58
45
 
59
46
  export function findLogicalRoot(activeId, logicalElementObj) {
60
47
  const prevId = logicalElementObj[activeId]?.previousLogicalElementId;
61
- console.log("prevId:sdasdaszc ", prevId);
62
- console.log("activeId:sdasdaszc ", activeId);
48
+
49
+
63
50
 
64
51
  if (prevId) {
65
52
  if (
@@ -191,41 +178,15 @@ export const ModalComplexFilterComponent = ({
191
178
  collectObjectLinksWithRequestProperties,
192
179
  collectObjectSchemaWithHierarchy,
193
180
  objConfigUseCase,
194
- // successTraversal,
195
181
  }) => {
196
- // console.log("keyUseCase:dfecvxvd ", keyUseCase);
197
182
  if (!objTypeMain) {
198
183
  objTypeMain = objConfigUseCase.objType;
199
184
  }
200
185
 
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
186
  const dispatch = useDispatch();
223
187
  const [modalTraversal, setModalTraversal] = useState(false);
224
188
 
225
- //----------------------------logical-----------------------------------------
226
189
  const [fieldValueUserTag, setFieldValueUserTag] = useImmer({
227
- // fieldName: "",
228
- // valueUserTag: "",
229
190
  });
230
191
 
231
192
  function selectValueUserTagForPartitionKey(e, key) {
@@ -240,8 +201,8 @@ export const ModalComplexFilterComponent = ({
240
201
 
241
202
  function handleSelectFieldNameAndValueUserTag(e, type) {
242
203
  let value = e.target.value;
243
- console.log("type:sdadfdsfd ", type);
244
- console.log("value:sdadfdsfd ", value);
204
+
205
+
245
206
 
246
207
  setFieldValueUserTag((fieldValueUserTag) => {
247
208
  fieldValueUserTag[type] = value;
@@ -290,21 +251,15 @@ export const ModalComplexFilterComponent = ({
290
251
  setFieldValueUserTag({});
291
252
  }
292
253
 
293
- //----------------------------logical-----------------------------------------
294
-
295
254
  const [allObjTypesLinkConfigs, collectRequireLinksFn, collectLinksOpt] =
296
255
  collectObjectLinksWithRequestProperties(); // allObjTypesLinkConfigs
297
256
 
298
257
  const [resultFieldName, getObjSchemaHieFn, collectLinksOpt2] =
299
258
  collectObjectSchemaWithHierarchy();
300
259
 
301
- console.log("objConfigUseCase:dsfevcxvzxc ", objConfigUseCase);
260
+
302
261
 
303
- console.log(
304
- "dataRelationship:wsxzx data ",
305
- allObjTypesLinkConfigs,
306
- resultFieldName,
307
- );
262
+
308
263
  const [initialLogicalElementId, setInitialLogicalElementId] = useState(
309
264
  objConfigUseCase ? objConfigUseCase.initialLogicalElementId : "",
310
265
  );
@@ -322,19 +277,14 @@ export const ModalComplexFilterComponent = ({
322
277
  const [newUserTagsRequestProperties, setNewUserTagsRequestProperties] =
323
278
  useImmer({});
324
279
 
325
- console.log(
326
- "logicalElementOutput: awscxzzvbm",
327
- initialLogicalElementId,
328
- logicalElementOutput,
329
- logicalElementObj,
330
- );
280
+
331
281
 
332
282
  useEffect(() => {
333
283
  collectRequireLinksFn(objTypeMain);
334
284
  getObjSchemaHieFn(objTypeMain);
335
285
  }, []);
336
286
 
337
- console.log("objTypeMain:sdwdxzxzxcc ", objTypeMain);
287
+
338
288
  function createArrObjTypeLogical(activeId, logicalElementObj) {
339
289
  const result = {
340
290
  arrOutput: [],
@@ -342,22 +292,17 @@ export const ModalComplexFilterComponent = ({
342
292
  };
343
293
 
344
294
  function loopLogical(id) {
345
- console.log("logicalElementObj:xsadfdfds ", logicalElementObj, id);
295
+
346
296
  const currentLogical = logicalElementObj[id];
347
- console.log("currentLogical:createArrObjTypeLogical ", currentLogical);
297
+
348
298
 
349
299
  if (!currentLogical) return;
350
300
  if (currentLogical.previousLogicalElementId !== null) {
351
- console.log("IF:createArrObjTypeLogical");
301
+
352
302
 
353
303
  loopLogical(currentLogical.previousLogicalElementId);
354
304
  }
355
- console.log(
356
- "createArrObjTypeLogical",
357
- id,
358
- logicalElementObj[currentLogical.previousLogicalElementId]
359
- ?.childLogicalElementId,
360
- );
305
+
361
306
  if (
362
307
  id ===
363
308
  logicalElementObj[currentLogical.previousLogicalElementId]
@@ -372,7 +317,7 @@ export const ModalComplexFilterComponent = ({
372
317
  .pathLinkType.objType,
373
318
  );
374
319
  }
375
- console.log("objTypeOutput:createArrObjTypeLogical", objTypeOutput);
320
+
376
321
 
377
322
  result.lastObjtype = objTypeOutput;
378
323
  result.arrOutput.push({ [objTypeOutput]: id });
@@ -381,7 +326,7 @@ export const ModalComplexFilterComponent = ({
381
326
 
382
327
  loopLogical(activeId);
383
328
 
384
- console.log("result:createArrObjTypeLogical ", result);
329
+
385
330
  return result;
386
331
  }
387
332
 
@@ -389,22 +334,21 @@ export const ModalComplexFilterComponent = ({
389
334
  let result = null;
390
335
 
391
336
  function loop(id) {
392
- console.log("id:wdsfdfdf ", id);
337
+
393
338
  const current = logicalElementObj[id];
394
- console.log("current:sadfdf ", current);
339
+
395
340
  if (!current) return;
396
341
 
397
342
  if (
398
343
  current.logicalElementType === "childComplexFilter" ||
399
344
  current.logicalElementType === "logical"
400
- // !current.previousLogicalElementId
401
345
  ) {
402
346
  result = current.objType || null;
403
347
  return;
404
348
  }
405
349
 
406
350
  const prevId = current.previousLogicalElementId;
407
- console.log("prevId:findObjTypeStep ", prevId);
351
+
408
352
 
409
353
  if (!prevId) {
410
354
  if (current.objType) {
@@ -416,7 +360,6 @@ export const ModalComplexFilterComponent = ({
416
360
  const prev = logicalElementObj[prevId];
417
361
  if (!prev) return;
418
362
 
419
- // ถ้า previous มี childLogicalElementId === currentId แสดงว่า current เป็น child ของ prev หยุด (ไม่ข้ามขึ้น)
420
363
  if (prev.childLogicalElementId === id) {
421
364
  // แต่ถ้ามี objType ของตัวเอง ใช้ตัวเอง
422
365
  if (current.objType) {
@@ -444,28 +387,8 @@ export const ModalComplexFilterComponent = ({
444
387
  let result = null;
445
388
 
446
389
  function loop(id) {
447
- console.log("id:wdsfdfdf ", id);
448
390
  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
391
  const prevId = current.previousLogicalElementId;
468
- console.log("prevId:findObjTypeStep ", prevId);
469
392
 
470
393
  if (!prevId) {
471
394
  if (current.objType) {
@@ -477,7 +400,6 @@ export const ModalComplexFilterComponent = ({
477
400
  const prev = logicalElementObj[prevId];
478
401
  if (!prev) return;
479
402
 
480
- // ถ้า previous มี childLogicalElementId === currentId แสดงว่า current เป็น child ของ prev หยุด (ไม่ข้ามขึ้น)
481
403
  if (prev.childLogicalElementId === id) {
482
404
  // แต่ถ้ามี objType ของตัวเอง ใช้ตัวเอง
483
405
  if (current.objType) {
@@ -509,7 +431,7 @@ export const ModalComplexFilterComponent = ({
509
431
  logicalElementObj[logicalElementOutput.active].nextLogicalElementId,
510
432
  );
511
433
  let logicalObj = {};
512
- console.log("dfofjdf", logicalElementObj[logicalElementOutput.active]);
434
+
513
435
 
514
436
  setLogicalElementOutput((logicalElementOutput) => {
515
437
  logicalElementOutput.status = false;
@@ -554,28 +476,12 @@ export const ModalComplexFilterComponent = ({
554
476
  }
555
477
 
556
478
  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
- );
479
+
571
480
 
572
481
  logicalObj = {
573
482
  ...mainLoigcalObj,
574
483
  objType: objType,
575
484
  partitionKeyValueUserTags: {},
576
- // fieldName: "",
577
- // comparison: "",
578
- // valueUserTag: "",
579
485
  };
580
486
  }
581
487
 
@@ -596,20 +502,6 @@ export const ModalComplexFilterComponent = ({
596
502
  });
597
503
  }
598
504
 
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
505
  function handleOperationChange(e) {
614
506
  let operation = e.target.value;
615
507
 
@@ -678,7 +570,7 @@ export const ModalComplexFilterComponent = ({
678
570
  function handleAddLogicalElement(action) {
679
571
  const uuid = nanoid(10);
680
572
 
681
- console.log("action:asfdsgsdg ", action);
573
+
682
574
  if (action === "addChild") {
683
575
  collectRequireLinksFn(
684
576
  logicalElementObj[logicalElementOutput.active].pathLinkType.objType,
@@ -750,16 +642,13 @@ export const ModalComplexFilterComponent = ({
750
642
  }
751
643
 
752
644
  function hadelActiveTopParent(objType) {
753
- console.log("objType:sdsacascz ", objType);
645
+
754
646
  setLogicalElementOutput((logicalElementOutput) => {
755
647
  logicalElementOutput.active = Object.values(objType)[0];
756
648
  });
757
649
  }
758
650
 
759
- console.log(
760
- "afsofiud",
761
- createArrObjTypeLogical(logicalElementOutput.active, logicalElementObj),
762
- );
651
+
763
652
 
764
653
  function handleSelectFieldName(e, type) {
765
654
  let value = e.target.value;
@@ -798,7 +687,7 @@ export const ModalComplexFilterComponent = ({
798
687
  }
799
688
 
800
689
  function handleUpdateNewValue(e, type) {
801
- console.log("type: safddfdgcxg", type, newUserTags);
690
+
802
691
 
803
692
  setNewUserTags((newUserTags) => {
804
693
  newUserTags.obj[type] = e.target.value;
@@ -817,7 +706,7 @@ export const ModalComplexFilterComponent = ({
817
706
 
818
707
  function handleSelectCreateNewValue(e) {
819
708
  let type = e.target.value;
820
- console.log("type:fgrgdfgfdh ", type);
709
+
821
710
 
822
711
  setNewUserTags((newUserTags) => {
823
712
  if (type === "valueUserTag") {
@@ -839,14 +728,9 @@ export const ModalComplexFilterComponent = ({
839
728
  }
840
729
  }
841
730
  });
842
- // setNewUserTags({});
843
731
  }
844
732
 
845
- console.log(
846
- "newUserTags:sadsxczvbbvb ",
847
- newUserTagsRequestProperties,
848
- valueDataUserTags,
849
- );
733
+
850
734
 
851
735
  function handleCreateNewValue(e) {
852
736
  setLogicalElementObj((logicalElementObj) => {
@@ -889,7 +773,7 @@ export const ModalComplexFilterComponent = ({
889
773
  });
890
774
  }
891
775
 
892
- console.log("newUserTags: ", newUserTags);
776
+
893
777
  const logicalElementType = [
894
778
  "openBracket",
895
779
  "closeBracket",
@@ -913,7 +797,7 @@ export const ModalComplexFilterComponent = ({
913
797
  ];
914
798
 
915
799
  function handelCreateFilterElement() {
916
- console.log("createFilterElement:dcvnnnbjxdx ", createFilterElement);
800
+
917
801
  if (createFilterElement) {
918
802
  createFilterElement(
919
803
  createObjTypeConcat(objTypeMain),
@@ -926,7 +810,6 @@ export const ModalComplexFilterComponent = ({
926
810
  dispatch(
927
811
  successFunction({
928
812
  parentOutputId: parentOutputId,
929
- // keyElement,
930
813
  initialLogicalElementId: initialLogicalElementId,
931
814
  logicalElements: logicalElementObj,
932
815
  valueDataUserTags: valueDataUserTags,
@@ -964,17 +847,14 @@ export const ModalComplexFilterComponent = ({
964
847
  parentOutputId,
965
848
  arrTraversalSteps,
966
849
  ) {
967
- console.log("arrTraversalSteps:dsfcxvxbx ", arrTraversalSteps);
850
+
968
851
 
969
852
  let linkStepsArr = [];
970
853
  let linkStepObj = {};
971
854
  for (const index in arrTraversalSteps) {
972
855
  const linkStep = arrTraversalSteps[index];
973
- console.log("linkStep:fdvdcxfedfxcv ", linkStep);
974
- console.log(
975
- "linkStep?.pathLinkType?.relType:fdvdcxfedfxcv ",
976
- linkStep?.pathLinkType?.relType,
977
- );
856
+
857
+
978
858
  if (linkStep?.pathLinkType?.relType) {
979
859
  if (Object.keys(linkStep?.pathLinkType?.relType).length === 0) {
980
860
  alert("relType in traversal step is empty, please select relType");
@@ -1004,7 +884,6 @@ export const ModalComplexFilterComponent = ({
1004
884
  successTraversalConfig({
1005
885
  parentOutputId: parentOutputId,
1006
886
  traversalLinkStepsObj: linkStepObj,
1007
- // keyElement,
1008
887
  }),
1009
888
  );
1010
889
  }
@@ -1016,10 +895,10 @@ export const ModalComplexFilterComponent = ({
1016
895
  });
1017
896
  }
1018
897
 
1019
- console.log("createFilterElement:fsdfbcsdfe", createFilterElement);
1020
- console.log("valueDataUserTags: ", valueDataUserTags);
898
+
899
+
1021
900
 
1022
- console.log("logicalElementObj:dfcxvxzzcs ", logicalElementObj);
901
+
1023
902
 
1024
903
  return (
1025
904
  <div>
@@ -1151,22 +1030,7 @@ export const ModalComplexFilterComponent = ({
1151
1030
  {key}
1152
1031
  </option>
1153
1032
  ))}
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
- )} */}
1033
+ {/* {} */}
1170
1034
  {/* {createArrObjTypeLogical(
1171
1035
  logicalElementOutput.active,
1172
1036
  logicalElementObj,
@@ -1212,10 +1076,7 @@ export const ModalComplexFilterComponent = ({
1212
1076
  "div",
1213
1077
  )}
1214
1078
  >
1215
- {console.log(
1216
- allObjTypesLinkConfigs,
1217
- "foopesofods",
1218
- )}
1079
+ {}
1219
1080
 
1220
1081
  {!allObjTypesLinkConfigs[
1221
1082
  logicalElementObj[logicalElementOutput.active]
@@ -1961,11 +1822,7 @@ export const ModalComplexFilterComponent = ({
1961
1822
  ].fieldNames,
1962
1823
  ).map((key) => (
1963
1824
  <>
1964
- {console.log(
1965
- "ewyyydsydfd",
1966
- identifier.fieldName,
1967
- key,
1968
- )}
1825
+ {}
1969
1826
  {identifier.fieldName !==
1970
1827
  key && (
1971
1828
  <option
@@ -2257,7 +2114,6 @@ export const ModalComplexFilterComponent = ({
2257
2114
  objConfigUseCase={objConfigUseCase}
2258
2115
  nameReducer={nameReducer}
2259
2116
  parentOutputId={parentOutputId}
2260
- // successFunc={successRequiredDataConfig}
2261
2117
  collectObjectLinksWithRequestProperties={
2262
2118
  collectObjectLinksWithRequestProperties
2263
2119
  }
@@ -2265,12 +2121,6 @@ export const ModalComplexFilterComponent = ({
2265
2121
  collectObjectSchemaWithHierarchy
2266
2122
  }
2267
2123
  valueUserTags={valueUserTags}
2268
- // nameObjectLinkStepEdit={
2269
- // stausModalSortFiled === true
2270
- // ? ""
2271
- // : stausModalSortFiled
2272
- // }
2273
- //----------------------------------
2274
2124
  ComponentUseCase={TraversalComponent}
2275
2125
  LastStepsComponentUseCase={
2276
2126
  FieldValueUserTagsComponent
@@ -2278,7 +2128,6 @@ export const ModalComplexFilterComponent = ({
2278
2128
  successFuncUseCase={
2279
2129
  sussessComplexFilterTypeTraversal
2280
2130
  }
2281
- // nameUserTag={undefined}
2282
2131
  />
2283
2132
  )}
2284
2133
  <fieldset></fieldset>
@@ -2439,19 +2288,14 @@ export const FieldValueUserTagsComponent = ({
2439
2288
  valueUserTags,
2440
2289
  parentOutputId,
2441
2290
  }) => {
2442
- console.log(
2443
- linkSteps[linkStepsOutput.active],
2444
- "last step:FieldValueUserTagsComponent",
2445
- );
2291
+
2446
2292
  const [fieldValueUserTag, setFieldValueUserTag] = useImmer({
2447
- // fieldName: "",
2448
- // valueUserTag: "",
2449
2293
  });
2450
2294
 
2451
2295
  function handleSelectFieldNameAndValueUserTag(e, type) {
2452
2296
  let value = e.target.value;
2453
- console.log("type:sdadfdsfd ", type);
2454
- console.log("value:sdadfdsfd ", value);
2297
+
2298
+
2455
2299
 
2456
2300
  setFieldValueUserTag((fieldValueUserTag) => {
2457
2301
  fieldValueUserTag[type] = value;
@@ -2479,8 +2323,8 @@ export const FieldValueUserTagsComponent = ({
2479
2323
  });
2480
2324
  setFieldValueUserTag({});
2481
2325
  }
2482
- console.log("fieldValueUserTag:efdgcvgfdrg ", fieldValueUserTag);
2483
- console.log("valueUserTags:FieldValueUserTagsComponent ", valueUserTags);
2326
+
2327
+
2484
2328
  return (
2485
2329
  <>
2486
2330
  {/* {(linkStepsOutput.status === "lastStep" ||
@@ -2505,17 +2349,14 @@ export const FieldValueUserTagsComponent = ({
2505
2349
  <IzaraDivStyle
2506
2350
  styletags={createStyleDefualtTags("background", "scroll", "div")}
2507
2351
  >
2508
- {console.log(
2509
- linkSteps[linkStepsOutput.active]?.fieldValueUserTags,
2510
- "dfjiusf0sdjfgop",
2511
- )}
2352
+ {}
2512
2353
  {linkSteps[linkStepsOutput.active]?.fieldValueUserTags !==
2513
2354
  undefined && (
2514
2355
  <>
2515
2356
  {linkSteps[linkStepsOutput.active]?.fieldValueUserTags?.map(
2516
2357
  (fieldValueUserTag, index) => (
2517
2358
  <div key={index}>
2518
- {console.log(fieldValueUserTag, "sdafdfsdfewrse")}
2359
+ {}
2519
2360
  <p>{JSON.stringify(fieldValueUserTag)}</p>
2520
2361
  </div>
2521
2362
  ),