rez_core 2.1.40 → 2.1.42
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/dist/module/filter/controller/filter.controller.d.ts +1 -1
- package/dist/module/filter/service/filter.service.d.ts +1 -1
- package/dist/module/filter/service/filter.service.js +23 -26
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/filter/service/filter.service.ts +62 -34
package/package.json
CHANGED
|
@@ -157,6 +157,7 @@ export class FilterService {
|
|
|
157
157
|
|
|
158
158
|
// Extract layout preference
|
|
159
159
|
const layout = layoutPreference?.[0]?.layout_json?.quick_tab || {};
|
|
160
|
+
|
|
160
161
|
let showList = layout?.show_list?.map((val) => val.toLowerCase()) || [];
|
|
161
162
|
|
|
162
163
|
let allTabs;
|
|
@@ -177,35 +178,62 @@ export class FilterService {
|
|
|
177
178
|
let filteredTabs;
|
|
178
179
|
|
|
179
180
|
if (showList?.length > 0) {
|
|
180
|
-
//
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
181
|
+
// Add 'all' if needed
|
|
182
|
+
const isAllNeeded = layout?.isAllSelected && !showList.includes('all');
|
|
183
|
+
if (isAllNeeded) {
|
|
184
|
+
showList.push('all');
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
// Filter
|
|
187
|
+
// Filter tabs based on showList (case-insensitive)
|
|
188
188
|
filteredTabs = allTabs.filter((tab) =>
|
|
189
189
|
showList.includes(tab.tab_value.toLowerCase()),
|
|
190
190
|
);
|
|
191
191
|
|
|
192
|
+
// Separate out 'all' tab before sorting
|
|
193
|
+
const allTab = filteredTabs.find(
|
|
194
|
+
(tab) => tab.tab_value.toLowerCase() === 'all',
|
|
195
|
+
);
|
|
196
|
+
filteredTabs = filteredTabs.filter(
|
|
197
|
+
(tab) => tab.tab_value.toLowerCase() !== 'all',
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
// 🔽 SORTING LOGIC
|
|
201
|
+
if (layout.sorting === 'asc') {
|
|
202
|
+
filteredTabs.sort((a, b) =>
|
|
203
|
+
a.tab_value.toLowerCase().localeCompare(b.tab_value.toLowerCase()),
|
|
204
|
+
);
|
|
205
|
+
} else if (layout.sorting === 'dsc') {
|
|
206
|
+
filteredTabs.sort((a, b) =>
|
|
207
|
+
b.tab_value.toLowerCase().localeCompare(a.tab_value.toLowerCase()),
|
|
208
|
+
);
|
|
209
|
+
} else if (layout.sorting === 'count_asc') {
|
|
210
|
+
filteredTabs.sort((a, b) => a.tab_value_count - b.tab_value_count);
|
|
211
|
+
} else if (layout.sorting === 'count_dsc') {
|
|
212
|
+
filteredTabs.sort((a, b) => b.tab_value_count - a.tab_value_count);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Re-insert 'all' at the beginning
|
|
216
|
+
if (allTab) {
|
|
217
|
+
filteredTabs.unshift(allTab);
|
|
218
|
+
}
|
|
219
|
+
|
|
192
220
|
// If combine other is enabled
|
|
193
221
|
if (layout?.isCombineOther) {
|
|
194
|
-
const
|
|
222
|
+
const originalAllTab = allTabs.find(
|
|
195
223
|
(tab) => tab.tab_value.toLowerCase() === 'all',
|
|
196
224
|
);
|
|
197
|
-
const allCount =
|
|
225
|
+
const allCount = originalAllTab?.tab_value_count ?? 0;
|
|
198
226
|
|
|
199
|
-
// Calculate sum of filtered (excluding 'All')
|
|
200
227
|
const knownTabCountSum = filteredTabs
|
|
201
228
|
.filter((tab) => tab.tab_value.toLowerCase() !== 'all')
|
|
202
229
|
.reduce((acc, tab) => acc + tab.tab_value_count, 0);
|
|
203
230
|
|
|
204
231
|
const othersCount = allCount - knownTabCountSum;
|
|
205
232
|
|
|
233
|
+
// Append 'OTHERS' at the end
|
|
206
234
|
filteredTabs.push({
|
|
207
235
|
tab_value: 'OTHERS',
|
|
208
|
-
tab_value_count: othersCount < 0 ? 0 : othersCount,
|
|
236
|
+
tab_value_count: othersCount < 0 ? 0 : othersCount,
|
|
209
237
|
});
|
|
210
238
|
}
|
|
211
239
|
} else {
|
|
@@ -300,8 +328,8 @@ export class FilterService {
|
|
|
300
328
|
},
|
|
301
329
|
);
|
|
302
330
|
}
|
|
303
|
-
}
|
|
304
|
-
|
|
331
|
+
}
|
|
332
|
+
|
|
305
333
|
qb.addOrderBy('e.created_date', 'DESC');
|
|
306
334
|
|
|
307
335
|
// Pagination
|
|
@@ -323,29 +351,29 @@ export class FilterService {
|
|
|
323
351
|
// };
|
|
324
352
|
|
|
325
353
|
// 1. Extract all date-type attribute keys
|
|
326
|
-
const dateAttributes = Object.entries(attributeMetaMap)
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
// 2. Format function using moment
|
|
331
|
-
const formatDate = (dateStr: string | null): string | null => {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
};
|
|
354
|
+
// const dateAttributes = Object.entries(attributeMetaMap)
|
|
355
|
+
// .filter(([_, attr]) => attr.data_type === 'date')
|
|
356
|
+
// .map(([key]) => key); // only the keys (e.g., 'created_date', 'modified_date')
|
|
357
|
+
|
|
358
|
+
// // 2. Format function using moment
|
|
359
|
+
// const formatDate = (dateStr: string | null): string | null => {
|
|
360
|
+
// if (!dateStr) return null;
|
|
361
|
+
// return moment(dateStr).format('MMM DD, YYYY'); // e.g., "Jun 25, 2025"
|
|
362
|
+
// };
|
|
335
363
|
|
|
336
|
-
// 3. Function to format only those keys in each entity row
|
|
337
|
-
const formatDatesInRow = (row: any): any => {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
};
|
|
364
|
+
// // 3. Function to format only those keys in each entity row
|
|
365
|
+
// const formatDatesInRow = (row: any): any => {
|
|
366
|
+
// const formattedRow = { ...row };
|
|
367
|
+
// for (const key of dateAttributes) {
|
|
368
|
+
// if (formattedRow[key]) {
|
|
369
|
+
// formattedRow[key] = formatDate(formattedRow[key]);
|
|
370
|
+
// }
|
|
371
|
+
// }
|
|
372
|
+
// return formattedRow;
|
|
373
|
+
// };
|
|
346
374
|
|
|
347
|
-
// 4. Final transformation
|
|
348
|
-
const formattedEntityList = entity_list.map(formatDatesInRow);
|
|
375
|
+
// // 4. Final transformation
|
|
376
|
+
// const formattedEntityList = entity_list.map(formatDatesInRow);
|
|
349
377
|
|
|
350
378
|
// Count query (without pagination)
|
|
351
379
|
const countQb = this.dataSource
|
|
@@ -362,7 +390,7 @@ export class FilterService {
|
|
|
362
390
|
success: true,
|
|
363
391
|
data: {
|
|
364
392
|
entity_tabs: filteredTabs,
|
|
365
|
-
|
|
393
|
+
entity_list,
|
|
366
394
|
pagination: {
|
|
367
395
|
total,
|
|
368
396
|
page,
|