@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,28 @@
1
+ export function successTraversal(state, action) {
2
+ const { parentOutputId, traversalLinkStepsObj } = action.payload;
3
+
4
+ state[
5
+ parentOutputId
6
+ ].currentValues.pageOutputMainConfigUseCase.traversalSteps = {
7
+ ...state[parentOutputId].currentValues.pageOutputMainConfigUseCase
8
+ .traversalSteps,
9
+ ...traversalLinkStepsObj,
10
+ };
11
+ }
12
+
13
+ export function successFilterElement(state, action) {
14
+ const { parentOutputId, initialLogicalElementId, logicalElements } =
15
+ action.payload;
16
+
17
+ state[
18
+ parentOutputId
19
+ ].currentValues.pageOutputMainConfigUseCase.initialLogicalElementId =
20
+ initialLogicalElementId;
21
+ state[
22
+ parentOutputId
23
+ ].currentValues.pageOutputMainConfigUseCase.logicalElements = {
24
+ ...state[parentOutputId].currentValues.pageOutputMainConfigUseCase
25
+ .logicalElements,
26
+ ...logicalElements,
27
+ };
28
+ }
@@ -0,0 +1,47 @@
1
+ import { current, createEntityAdapter, createAction } from "@reduxjs/toolkit";
2
+
3
+ //--------------------------valueUserTag----------------------------------------
4
+ import {
5
+ valueUserTagCreate,
6
+ validateValueUserTagNotUsed,
7
+ } from "./valueUserTagFunction";
8
+
9
+ export const valueUserTagCreateConfig = createAction(
10
+ "valueUserTagCreateConfig",
11
+ );
12
+
13
+ export const validateValueUserTagNotUsedConfig = createAction(
14
+ "validateValueUserTagNotUsedConfig",
15
+ );
16
+
17
+ //-------------------------------complexFilterFunction-----------------------------------
18
+
19
+ import {
20
+ successTraversal,
21
+ // successFilterElement,
22
+ } from "./complexFilterFunction";
23
+
24
+ export const successTraversalConfig = createAction("successTraversalConfig");
25
+ // export const successFilterElementConfig = createAction(
26
+ // "successFilterElementConfig",
27
+ // );
28
+
29
+ //--------------------------------linkStepFunctionAndUseCase-----------------------------------
30
+ // import { successRequiredData } from "./linkStepFunction";
31
+
32
+ // export const successRequiredDataConfig = createAction(
33
+ // "successRequiredDataConfig",
34
+ // );
35
+
36
+ export const sendExtraReducerLibCreateLinkStepAndComplexFilter = (builder) => {
37
+ //----------------------------valueUserTag---------------------------------------
38
+ builder.addCase(valueUserTagCreateConfig, valueUserTagCreate);
39
+ builder.addCase(
40
+ validateValueUserTagNotUsedConfig,
41
+ validateValueUserTagNotUsed,
42
+ );
43
+ //----------------------------------complexFilterFunction----------------------------
44
+ builder.addCase(successTraversalConfig, successTraversal);
45
+ // builder.addCase(successFilterElementConfig, successFilterElement);
46
+ // builder.addCase(successRequiredDataConfig, successRequiredData);
47
+ };
@@ -0,0 +1,38 @@
1
+ export function successRequiredData(state, action) {
2
+ const {
3
+ parentOutputId,
4
+ linkSteps,
5
+ initialObjType,
6
+ nameLinkStepObject,
7
+ dataType,
8
+ linkStepsArr,
9
+ } = action.payload;
10
+
11
+ if (linkStepsArr === undefined) {
12
+ linkStepsArr = [];
13
+ for (const index in linkSteps) {
14
+ let linkStepObj = _.cloneDeep(linkSteps[index]);
15
+
16
+ let hashRequiredData = hash(linkStepObj);
17
+
18
+ state[
19
+ parentOutputId
20
+ ].currentValues.pageOutputMainConfigUseCase.requiredDataLinkSteps[
21
+ hashRequiredData
22
+ ] = linkStepObj;
23
+
24
+ linkStepsArr.push(hashRequiredData);
25
+ }
26
+ }
27
+
28
+ let requiredDataLinkStepObjects = {
29
+ initialObjType: initialObjType,
30
+ linkSteps: linkStepsArr,
31
+ };
32
+
33
+ state[
34
+ parentOutputId
35
+ ].currentValues.pageOutputMainConfigUseCase.requiredDataLinkStepObjects[
36
+ nameLinkStepObject
37
+ ] = requiredDataLinkStepObjects;
38
+ }
@@ -0,0 +1,188 @@
1
+ import { current, createEntityAdapter, createAction } from "@reduxjs/toolkit";
2
+
3
+ export const valueUserTagCreate = (state, action) => {
4
+ const { parentOutputId, objCreateValueUserTag } = action.payload;
5
+
6
+ console.log(
7
+ "objCreateValueUserTag:rdfsdgfhfb ",
8
+ parentOutputId,
9
+ objCreateValueUserTag,
10
+ );
11
+ state[parentOutputId].currentValues.pageOutputMainConfigUseCase.valueUserTags[
12
+ objCreateValueUserTag.keyName
13
+ ] = { defaultValue: objCreateValueUserTag.defaultValue };
14
+ };
15
+
16
+ export const validateValueUserTagNotUsed = (state, action) => {
17
+ //linkstep
18
+ for (const linkStepId in state[parentOutputId].currentValues
19
+ .pageOutputMainConfigUseCase.linkSteps) {
20
+ console.log("linkStepId: ", linkStepId);
21
+ }
22
+ };
23
+
24
+ // function scanLogicalElements(set, logicalElements) {
25
+ // if (!logicalElements) return;
26
+
27
+ // Object.values(logicalElements).forEach((el) => {
28
+ // addTagsFromObjectValues(set, el.partitionKeyValueUserTags);
29
+ // addTagsFromObjectValues(set, el.sortKeyValueUserTags);
30
+
31
+ // if (el.conditionalFieldValues) {
32
+ // el.conditionalFieldValues.forEach((cond) => {
33
+ // addTags(set, cond.includeValueUserTags);
34
+ // addTags(set, cond.excludeValueUserTags);
35
+ // });
36
+ // }
37
+
38
+ // addTagsFromObjectValues(set, el.requestProperties);
39
+ // });
40
+ // }
41
+
42
+ // function scanTraversalSteps(set, traversalSteps) {
43
+ // if (!traversalSteps) return;
44
+
45
+ // Object.values(traversalSteps).forEach((step) => {
46
+ // if (step.fieldValueUserTags) {
47
+ // step.fieldValueUserTags.forEach((obj) => {
48
+ // addTagsFromObjectValues(set, obj);
49
+ // });
50
+ // }
51
+ // });
52
+ // }
53
+
54
+ // function scanSortFields(set, sortFields) {
55
+ // if (!sortFields) return;
56
+
57
+ // sortFields.forEach((sf) => {
58
+ // addTags(set, sf.sortByValueUserTags);
59
+ // });
60
+ // }
61
+
62
+ // function scanCombinations(set, combinations) {
63
+ // if (!combinations) return;
64
+
65
+ // Object.values(combinations).forEach((c) => {
66
+ // scanLogicalElements(set, c.logicalElements);
67
+ // });
68
+ // }
69
+
70
+ //------------------------
71
+ const addTags = (usedSet, tagKeys, arr) => {
72
+ console.log(
73
+ "usedSet, tagKeys, arr:addTags:xzxzxawffbbc ",
74
+ usedSet,
75
+ tagKeys,
76
+ arr,
77
+ );
78
+ if (!Array.isArray(arr)) return;
79
+
80
+ for (const v of arr) {
81
+ addTags(usedSet, tagKeys, v);
82
+ }
83
+ };
84
+
85
+ const addTagsFromObjectValues = (usedSet, tagKeys, obj) => {
86
+ if (!obj) return;
87
+
88
+ for (const v of Object.values(obj)) {
89
+ addTags(usedSet, tagKeys, v);
90
+ }
91
+ };
92
+
93
+ function scanLogicalElements(usedSet, tagKeys, logicalElements) {
94
+ console.log(
95
+ "logicalElements:dxczxcvasrfdwaefasdf ",
96
+ usedSet,
97
+ tagKeys,
98
+ logicalElements,
99
+ );
100
+ if (!logicalElements) return;
101
+
102
+ for (const el of Object.values(logicalElements)) {
103
+ addTagsFromObjectValues(usedSet, tagKeys, el.partitionKeyValueUserTags);
104
+
105
+ addTagsFromObjectValues(usedSet, tagKeys, el.sortKeyValueUserTags);
106
+
107
+ // if (el.conditionalFieldValues) {
108
+ // for (const cond of el.conditionalFieldValues) {
109
+ // addTags(usedSet, tagKeys, cond.includeValueUserTags);
110
+
111
+ // addTags(usedSet, tagKeys, cond.excludeValueUserTags);
112
+ // }
113
+ // }
114
+
115
+ addTagsFromObjectValues(usedSet, tagKeys, el.requestProperties);
116
+ }
117
+ }
118
+
119
+ function scanTraversalSteps(usedSet, tagKeys, traversalSteps) {
120
+ if (!traversalSteps) return;
121
+
122
+ for (const step of Object.values(traversalSteps)) {
123
+ if (!step.fieldValueUserTags) continue;
124
+
125
+ for (const obj of step.fieldValueUserTags) {
126
+ addTagsFromObjectValues(usedSet, tagKeys, obj);
127
+ }
128
+ }
129
+ }
130
+
131
+ function scanRequiredDataLinkSteps(usedSet, tagKeys, steps) {
132
+ if (!steps) return;
133
+
134
+ for (const step of Object.values(steps)) {
135
+ addTagsFromObjectValues(usedSet, tagKeys, step.requestProperties);
136
+ console.log("step: dfcvxbcxb", step);
137
+ if (step.filterElements) {
138
+ scanLogicalElements(
139
+ usedSet,
140
+ tagKeys,
141
+ step.filterElements.logicalElements,
142
+ );
143
+ }
144
+
145
+ if (step.sortFields) {
146
+ for (const sf of step.sortFields) {
147
+ addTags(usedSet, tagKeys, sf.sortByValueUserTags);
148
+ }
149
+ }
150
+
151
+ addTags(usedSet, tagKeys, step.comparisonValue);
152
+ }
153
+ }
154
+ function scanSortFields(usedSet, tagKeys, sortFields) {
155
+ if (!sortFields) return;
156
+
157
+ for (const sf of sortFields) {
158
+ addTags(usedSet, tagKeys, sf.sortByValueUserTags);
159
+ }
160
+ }
161
+ function scanCombinations(usedSet, tagKeys, combinations) {
162
+ if (!combinations) return;
163
+
164
+ for (const combo of Object.values(combinations)) {
165
+ scanLogicalElements(usedSet, tagKeys, combo.logicalElements);
166
+ }
167
+ }
168
+
169
+ export function findUsedUserTagsFast(param) {
170
+ const used = new Set();
171
+
172
+ const tagKeys = new Set(Object.keys(param.valueUserTags));
173
+
174
+ scanLogicalElements(used, tagKeys, param.logicalElements);
175
+
176
+ scanTraversalSteps(used, tagKeys, param.traversalSteps);
177
+
178
+ scanRequiredDataLinkSteps(used, tagKeys, param.requiredDataLinkSteps);
179
+
180
+ scanSortFields(used, tagKeys, param.sortFields);
181
+
182
+ scanCombinations(used, tagKeys, param.complexFilterCombinations);
183
+
184
+ scanCombinations(used, tagKeys, param.perParentCombinations);
185
+
186
+ console.log("used:wsdxcvzvxcv ", used, tagKeys);
187
+ return used;
188
+ }
package/src/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export { MainCaseUseConditionAndMultipleIdentifersComponent, ConditionLinkStepAndMultipleIdentifersComponent } from "./complexFilterMain/mainCaseUseConditionAndMultipleIdentifersComponent.jsx";
2
+ export { ModalComplexFilterComponent } from "./complexFilterMain/modalComplexFilterComponent.jsx";
3
+ export { ModalLinkStepsComponent } from "./linkSteps/modalLinkStepsComponent.jsx";
4
+ export { UserTagsSelectAndCreateComponent } from "./valueUserTags/valueUserTagsComponent.jsx";
5
+ export { FieldNameComponent } from "./valueUserTags/fieldNameComponent.jsx";
6
+
7
+ export { sendExtraReducerLibCreateLinkStepAndComplexFilter } from "./function/createActionLibCreateLinkStepAndComplexFilter";
8
+ export { successFilterElement } from "./function/complexFilterFunction";
9
+ export { successRequiredData } from "./function/linkStepFunction";