rez_core 2.1.41 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "2.1.41",
3
+ "version": "2.1.42",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -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
- // If 'All' is selected, include 'all'
181
- if (layout?.isAllSelected) {
182
- if (!showList.includes('all')) {
183
- showList.push('all');
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 `allTabs` using showList (case-insensitive)
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 allTab = allTabs.find(
222
+ const originalAllTab = allTabs.find(
195
223
  (tab) => tab.tab_value.toLowerCase() === 'all',
196
224
  );
197
- const allCount = allTab?.tab_value_count ?? 0;
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, // safe fallback
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