@izara_project/izara-shared-search-and-sort 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/DataFieldsSharedLib.js +236 -142
- package/src/FiltersSharedLib.js +380 -616
- package/src/LogicalStructureSharedLib.js +159 -476
- package/src/SearchSortSharedLib.js +65 -37
|
@@ -34,8 +34,7 @@ async function createSearchRequest(
|
|
|
34
34
|
perParentCombinations,
|
|
35
35
|
requiredDataLinkStepObjects,
|
|
36
36
|
requiredDataLinkSteps,
|
|
37
|
-
|
|
38
|
-
getSchemaFn
|
|
37
|
+
valueUserTags,
|
|
39
38
|
) {
|
|
40
39
|
console.log('createSearchResult: ', {
|
|
41
40
|
objType,
|
|
@@ -46,7 +45,7 @@ async function createSearchRequest(
|
|
|
46
45
|
perParentCombinations,
|
|
47
46
|
requiredDataLinkStepObjects,
|
|
48
47
|
requiredDataLinkSteps,
|
|
49
|
-
|
|
48
|
+
valueUserTags
|
|
50
49
|
});
|
|
51
50
|
|
|
52
51
|
let filterElements = {};
|
|
@@ -57,13 +56,14 @@ async function createSearchRequest(
|
|
|
57
56
|
|
|
58
57
|
let requiredDataPromise = dataFieldsSharedLib.createRequiredData(
|
|
59
58
|
objType,
|
|
59
|
+
initialLogicalElementId,
|
|
60
|
+
logicalElements,
|
|
60
61
|
requiredDataFields,
|
|
61
62
|
complexFilterCombinations,
|
|
62
63
|
perParentCombinations,
|
|
63
64
|
requiredDataLinkStepObjects,
|
|
64
65
|
requiredDataLinkSteps,
|
|
65
|
-
|
|
66
|
-
getSchemaFn
|
|
66
|
+
valueUserTags,
|
|
67
67
|
);
|
|
68
68
|
|
|
69
69
|
//* create complexFilter normalize to send backend
|
|
@@ -76,7 +76,7 @@ async function createSearchRequest(
|
|
|
76
76
|
objType,
|
|
77
77
|
initialLogicalElementId,
|
|
78
78
|
logicalElements,
|
|
79
|
-
|
|
79
|
+
valueUserTags,
|
|
80
80
|
[]
|
|
81
81
|
);
|
|
82
82
|
console.log('return createComplexFilter: ', {
|
|
@@ -86,6 +86,9 @@ async function createSearchRequest(
|
|
|
86
86
|
complexErrorsFound
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
+
let searchResultId = null;
|
|
90
|
+
let searchDetailId = null;
|
|
91
|
+
|
|
89
92
|
if (complexErrorsFound.length > 0) {
|
|
90
93
|
errorsFound = errorsFound.concat(complexErrorsFound);
|
|
91
94
|
Object.assign(errorsObject, complexErrorsObject);
|
|
@@ -100,7 +103,7 @@ async function createSearchRequest(
|
|
|
100
103
|
// perParentCombinations,
|
|
101
104
|
// requiredDataLinkStepObjects,
|
|
102
105
|
// requiredDataLinkSteps,
|
|
103
|
-
//
|
|
106
|
+
// valueUserTags,
|
|
104
107
|
// );
|
|
105
108
|
let requiredData = await requiredDataPromise;
|
|
106
109
|
console.log('return create requiredData: ', requiredData);
|
|
@@ -112,7 +115,7 @@ async function createSearchRequest(
|
|
|
112
115
|
}
|
|
113
116
|
|
|
114
117
|
if (errorsFound.length > 0) {
|
|
115
|
-
return [null, 'invalid', errorsObject, errorsFound]
|
|
118
|
+
return [searchResultId, searchDetailId, null, 'invalid', errorsObject, errorsFound]
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
if (!isEmpty(requiredData.perParentCombinations)) {
|
|
@@ -137,10 +140,13 @@ async function createSearchRequest(
|
|
|
137
140
|
filterElements
|
|
138
141
|
});
|
|
139
142
|
|
|
143
|
+
searchResultId = complexFilterRequest.filterMainId;
|
|
144
|
+
searchDetailId = requiredData.requiredDataHash;
|
|
145
|
+
|
|
140
146
|
let searchResultRequest = {
|
|
141
147
|
objType: objType,
|
|
142
|
-
searchResultId:
|
|
143
|
-
searchDetailId:
|
|
148
|
+
searchResultId: searchResultId,
|
|
149
|
+
searchDetailId: searchDetailId,
|
|
144
150
|
requiredDataObjects: requiredData.requiredDataObjects,
|
|
145
151
|
searchParams: {
|
|
146
152
|
filterObjectId: complexFilterRequest.filterMainId
|
|
@@ -151,7 +157,7 @@ async function createSearchRequest(
|
|
|
151
157
|
};
|
|
152
158
|
console.log("searchResultRequest: ", searchResultRequest);
|
|
153
159
|
|
|
154
|
-
return [searchResultRequest, status, errorsObject, errorsFound]
|
|
160
|
+
return [searchResultId, searchDetailId, searchResultRequest, status, errorsObject, errorsFound]
|
|
155
161
|
|
|
156
162
|
}
|
|
157
163
|
|
|
@@ -165,7 +171,7 @@ async function createSortRequest(
|
|
|
165
171
|
requiredDataLinkStepObjects,
|
|
166
172
|
requiredDataLinkSteps,
|
|
167
173
|
sortFields,
|
|
168
|
-
|
|
174
|
+
valueUserTags,
|
|
169
175
|
) {
|
|
170
176
|
console.log('createSortResult: ', {
|
|
171
177
|
objType,
|
|
@@ -177,17 +183,24 @@ async function createSortRequest(
|
|
|
177
183
|
requiredDataLinkStepObjects,
|
|
178
184
|
requiredDataLinkSteps,
|
|
179
185
|
sortFields,
|
|
180
|
-
|
|
186
|
+
valueUserTags
|
|
181
187
|
});
|
|
182
188
|
|
|
183
189
|
let sortFieldMain = []
|
|
184
190
|
|
|
191
|
+
let errorsObject = {};
|
|
192
|
+
let errorsFound = [];
|
|
193
|
+
|
|
185
194
|
//* set sortField
|
|
186
195
|
for (const sortField of sortFields) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
196
|
+
|
|
197
|
+
if (!sortField.hasOwnProperty("dataType")) {
|
|
198
|
+
errorsFound.push(`${sortField.requiredDataLinkStepObjectId}: sortField is not set dataType`);
|
|
199
|
+
errorsObject = {
|
|
200
|
+
[sortField.requiredDataLinkStepObjectId]: 'sortField is not set dataType'
|
|
201
|
+
}
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
191
204
|
|
|
192
205
|
let requiredDataLinkStepObjectId = sortField.requiredDataLinkStepObjectId;
|
|
193
206
|
|
|
@@ -203,15 +216,35 @@ async function createSortRequest(
|
|
|
203
216
|
let linkStep = requiredDataLinkSteps[lastRequiredDataLinkStepId];
|
|
204
217
|
console.log('linkStep', linkStep);
|
|
205
218
|
|
|
206
|
-
|
|
219
|
+
let sortObject = {
|
|
207
220
|
fieldName: linkStep.fieldName,
|
|
208
221
|
dataType: sortField.dataType
|
|
209
|
-
}
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
if (sortField.dataType === "array") {
|
|
225
|
+
|
|
226
|
+
if (isEmpty(sortField.sortByValueUserTags)) {
|
|
227
|
+
errorsFound.push(`${sortField.requiredDataLinkStepObjectId}: sortField has sortByValueUserTags is empty`);
|
|
228
|
+
errorsObject = {
|
|
229
|
+
[sortField.requiredDataLinkStepObjectId]: 'sortField has sortByValueUserTags is empty'
|
|
230
|
+
}
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
sortObject.values = [];
|
|
235
|
+
for (let sort of sortField.sortByValueUserTags) {
|
|
236
|
+
sortObject.values.push(valueUserTags[sort].value);
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
sortFieldMain.push(sortObject);
|
|
240
|
+
}
|
|
241
|
+
console.log("sortFieldMain: ", sortFieldMain);
|
|
210
242
|
|
|
243
|
+
if (errorsFound.length > 0) {
|
|
244
|
+
return [null, null, 'invalid', errorsObject, errorsFound]
|
|
211
245
|
}
|
|
212
|
-
console.log("sortFieldMain: ", sortFieldMain)
|
|
213
246
|
|
|
214
|
-
let [searchResultRequest, status,
|
|
247
|
+
let [searchResultId, searchDetailId, searchResultRequest, status, searchErrorsObject, searchErrorsFound] = await createSearchRequest(
|
|
215
248
|
objType,
|
|
216
249
|
initialLogicalElementId,
|
|
217
250
|
logicalElements,
|
|
@@ -220,34 +253,29 @@ async function createSortRequest(
|
|
|
220
253
|
perParentCombinations,
|
|
221
254
|
requiredDataLinkStepObjects,
|
|
222
255
|
requiredDataLinkSteps,
|
|
223
|
-
|
|
256
|
+
valueUserTags
|
|
224
257
|
);
|
|
225
258
|
console.log('SearchResultRequest: ', {
|
|
259
|
+
searchResultId,
|
|
260
|
+
searchDetailId,
|
|
226
261
|
searchResultRequest,
|
|
227
262
|
status,
|
|
228
|
-
|
|
229
|
-
|
|
263
|
+
searchErrorsObject,
|
|
264
|
+
searchErrorsFound
|
|
230
265
|
});
|
|
231
266
|
|
|
267
|
+
if (searchErrorsFound.length > 0) {
|
|
268
|
+
Object.assign(errorsObject, searchErrorsObject);
|
|
269
|
+
errorsFound = errorsFound.concat(searchErrorsFound);
|
|
270
|
+
}
|
|
271
|
+
|
|
232
272
|
if (errorsFound.length > 0) {
|
|
233
273
|
return [null, null, 'invalid', errorsObject, errorsFound]
|
|
234
274
|
}
|
|
235
275
|
|
|
236
|
-
let searchResultId = searchResultRequest.searchResultId;
|
|
237
|
-
let searchDetailId = searchResultRequest.searchDetailId;
|
|
238
|
-
console.log('searchResultMain: ', {
|
|
239
|
-
searchResultId,
|
|
240
|
-
searchDetailId
|
|
241
|
-
});
|
|
242
|
-
|
|
243
276
|
let sortFieldsHash = hash(sortFieldMain);
|
|
244
277
|
let sortResultId = searchResultId + '__' + searchDetailId + '__' + sortFieldsHash;
|
|
245
|
-
|
|
246
|
-
// searchResultId,
|
|
247
|
-
// searchDetailId,
|
|
248
|
-
// sortFieldMain
|
|
249
|
-
// );
|
|
250
|
-
console.log('sortResultId: ', sortResultId)
|
|
278
|
+
console.log('sortResultId: ', sortResultId);
|
|
251
279
|
|
|
252
280
|
let sortRequest = {
|
|
253
281
|
objType: objType,
|