Files
wekan/models/lib/tableViewGrouping.js
Lauri Ojansivu 0847af8ec6 Add optional swimlane grouping to Table view
Keep the flat table as the default and let each user persist an optional grouped mode. Group cards in board swimlane order, preserve the selected column sort inside each lane, and insert section rows after pagination so headers never consume card slots.

Add user-isolation, empty-state, section-boundary and browser persistence coverage.

Thanks to rmb82 and xet7 !

Fixes #6634,
2026-08-25 17:39:23 +03:00

42 lines
995 B
JavaScript

'use strict';
const STORAGE_PREFIX = 'wekan-table-group-swimlanes:';
function tableViewGroupingStorageKey(userId) {
return `${STORAGE_PREFIX}${userId || 'anonymous'}`;
}
function readTableViewGrouping(storage, userId) {
return !!storage && storage.getItem(tableViewGroupingStorageKey(userId)) === 'true';
}
function writeTableViewGrouping(storage, userId, enabled) {
if (storage) {
storage.setItem(tableViewGroupingStorageKey(userId), enabled ? 'true' : 'false');
}
}
function addSwimlaneGroupHeaders(rows) {
const result = [];
let previousId;
for (const row of rows || []) {
if (row.swimlaneId !== previousId) {
result.push({
isGroupHeader: true,
swimlaneId: row.swimlaneId,
swimlaneTitle: row.swimlaneTitle,
});
previousId = row.swimlaneId;
}
result.push(row);
}
return result;
}
module.exports = {
tableViewGroupingStorageKey,
readTableViewGrouping,
writeTableViewGrouping,
addSwimlaneGroupHeaders,
};