mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
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,
51 lines
1.7 KiB
JavaScript
51 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const {
|
|
tableViewGroupingStorageKey,
|
|
readTableViewGrouping,
|
|
writeTableViewGrouping,
|
|
addSwimlaneGroupHeaders,
|
|
} = require('../models/lib/tableViewGrouping');
|
|
|
|
const values = new Map();
|
|
const storage = {
|
|
getItem: key => values.get(key) ?? null,
|
|
setItem: (key, value) => values.set(key, value),
|
|
};
|
|
assert.strictEqual(readTableViewGrouping(storage, 'a'), false);
|
|
writeTableViewGrouping(storage, 'a', true);
|
|
assert.strictEqual(readTableViewGrouping(storage, 'a'), true);
|
|
assert.strictEqual(readTableViewGrouping(storage, 'b'), false);
|
|
assert.notStrictEqual(tableViewGroupingStorageKey('a'), tableViewGroupingStorageKey('b'));
|
|
|
|
const rows = [
|
|
{ title: 'A', swimlaneId: 'one', swimlaneTitle: 'One' },
|
|
{ title: 'B', swimlaneId: 'one', swimlaneTitle: 'One' },
|
|
{ title: 'C', swimlaneId: 'two', swimlaneTitle: 'Two' },
|
|
];
|
|
const grouped = addSwimlaneGroupHeaders(rows);
|
|
assert.deepStrictEqual(
|
|
grouped.map(row => row.isGroupHeader ? `header:${row.swimlaneTitle}` : row.title),
|
|
['header:One', 'A', 'B', 'header:Two', 'C'],
|
|
);
|
|
assert.deepStrictEqual(addSwimlaneGroupHeaders([]), []);
|
|
|
|
const root = path.join(__dirname, '..');
|
|
const jade = fs.readFileSync(
|
|
path.join(root, 'client/components/boards/tableView.jade'),
|
|
'utf8',
|
|
);
|
|
const js = fs.readFileSync(
|
|
path.join(root, 'client/components/boards/tableView.js'),
|
|
'utf8',
|
|
);
|
|
assert.match(jade, /tr\.table-view-swimlane-group/);
|
|
assert.match(jade, /js-table-view-toggle-swimlane-groups/);
|
|
assert.match(js, /addSwimlaneGroupHeaders\(pageRows\)/);
|
|
assert.match(js, /tpl\.page\.set\(1\)/);
|
|
|
|
console.log('tableViewGrouping: 10 checks passed');
|