@visns-studio/visns-components 5.1.25 → 5.1.26
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
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
78
78
|
},
|
|
79
79
|
"name": "@visns-studio/visns-components",
|
|
80
|
-
"version": "5.1.
|
|
80
|
+
"version": "5.1.26",
|
|
81
81
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
82
82
|
"main": "src/index.js",
|
|
83
83
|
"files": [
|
|
@@ -226,18 +226,27 @@ const GenericEditableTable = ({
|
|
|
226
226
|
|
|
227
227
|
dataArray.forEach((entry, index) => {
|
|
228
228
|
const categoryInfo = entry[rows.categoryKey.id];
|
|
229
|
-
const
|
|
229
|
+
const categoryLabel = categoryInfo
|
|
230
230
|
? categoryInfo[rows.categoryKey.label]
|
|
231
231
|
: null;
|
|
232
232
|
const categoryId = categoryInfo ? categoryInfo.id : null;
|
|
233
233
|
const groupKey = categoryId || 'no_category';
|
|
234
|
+
// Use the category's sort_order if provided; otherwise, default to a high number (e.g. 9999)
|
|
235
|
+
|
|
236
|
+
console.info(categoryInfo);
|
|
237
|
+
|
|
238
|
+
const catSortOrder =
|
|
239
|
+
categoryInfo && typeof categoryInfo.sort_order !== 'undefined'
|
|
240
|
+
? categoryInfo.sort_order
|
|
241
|
+
: 9999;
|
|
234
242
|
|
|
235
243
|
if (!grouped[groupKey]) {
|
|
236
244
|
grouped[groupKey] = {
|
|
237
245
|
id: groupKey,
|
|
238
246
|
category:
|
|
239
|
-
|
|
247
|
+
categoryLabel ||
|
|
240
248
|
(groupKey === 'no_category' ? 'No Category' : ''),
|
|
249
|
+
catSortOrder, // assign the sort order (or fallback)
|
|
241
250
|
entries: [],
|
|
242
251
|
};
|
|
243
252
|
}
|
|
@@ -247,15 +256,23 @@ const GenericEditableTable = ({
|
|
|
247
256
|
});
|
|
248
257
|
});
|
|
249
258
|
|
|
259
|
+
// Sort entries within each group by their universal sort_order
|
|
250
260
|
Object.values(grouped).forEach((group) => {
|
|
251
261
|
group.entries.sort((a, b) => a.sort_order - b.sort_order);
|
|
252
262
|
});
|
|
253
263
|
|
|
254
|
-
//
|
|
264
|
+
// Now sort the groups by the cost category's sort_order (catSortOrder)
|
|
255
265
|
const groupedArray = Object.values(grouped);
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
266
|
+
groupedArray.sort((a, b) => {
|
|
267
|
+
// Optionally, place 'no_category' first (or adjust as needed)
|
|
268
|
+
if (a.id === 'no_category') return -1;
|
|
269
|
+
if (b.id === 'no_category') return 1;
|
|
270
|
+
return a.catSortOrder - b.catSortOrder;
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
console.info(groupedArray);
|
|
274
|
+
|
|
275
|
+
return groupedArray;
|
|
259
276
|
};
|
|
260
277
|
|
|
261
278
|
const groupedCategories = useMemo(() => {
|