mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Design: docs/Design/Page/All-Boards.md, whose Table view is the shared table page (docs/Design/Page/Table.md) and which describes only what is different here. ONE ROW OF CONTROLS. The page carried its own row above the board icons - Multi-Selection with its archive and duplicate actions, Sort, the search box - in .boards-path-header, while the second top header bar above it held only the title. Two rows of controls on one page, one of them styled like the board header of the Swimlanes view and one not. Starred, Sort, Search, Multi-Selection and the view menu are in the header bar now, as .board-header-btn with the same Font Awesome glyphs and the same emphasis state, so this page agrees with every other page about where a WeKan page puts its controls. The actions ON a selection stayed with the boards: Archive, Duplicate and the "Selected:" star/home actions appear only while something is selected and are about those rows, not about the page. SEARCH IS A FIELD, not a button that opens a search view. It filters as you type, searches across all your boards ignoring the selected section while it has text, and Escape clears it - the old right-pane behaviour exactly. That is a deliberate difference from the board header, whose Search opens a search view over cards; here it filters the list it sits above. THE VIEW MENU names the CURRENT view - "Lists" or "Table" - not the words "Board View", the same as the board header, which says "Swimlanes" or "Lists" rather than naming the menu. Lists is the default and is what an account that has never chosen sees. The choice is kept in localStorage rather than on the user document: it is a view preference for one page and changes nothing anybody else can see. A board's view IS on the profile, because it follows the user between devices; this deliberately does not. THE TABLE VIEW is the shared table page, editable - which is what separates it from the other board table, /public, which is read-only. Columns: Edit, Board title, Board description. Ten rows a page. Edit opens the SAME popup the Swimlanes view opens from its board menu, not a copy of it. That took one change: boardChangeTitlePopup's submit read Utils.getCurrentBoard(), which is the board you are looking at - and on All Boards you are not looking at one. It takes the board from its own data context when it has one and falls back to the current board, so the board header is unchanged. TWO THINGS THE REFACTOR NEEDED. The state had to be shared. boardListHeaderBar and boardList are separate Blaze instances - the bar is rendered into the layout's headerBar region, the page into its content region - so the search field would have filtered nothing. The search term and the selected section are module-level ReactiveVars now, assigned onto the page instance so every `tpl.boardSearchVar.get()` already written keeps working. And "which boards am I looking at" had to stay one answer: the `boards` helper's body is `boardsForView(tpl)` now, called by both views, because two copies of a membership + section + search + sort + paging query would drift. The view module is split in two for the same reason the others are: which views exist and which is the default is pure (models/lib/allBoardsView.js) and unit tested; the ReactiveVars and localStorage are Meteor glue and cannot be loaded in a plain Node test. The guard in tests/addBoardTileHeight.test.cjs pinned the ORDER of the three controls inside .path-right. That row is gone on purpose, so the guard now pins the order where the controls are - and that the page body does not also carry them, which is the thing that was wrong. Thanks to xet7 !
71 lines
2.6 KiB
JavaScript
71 lines
2.6 KiB
JavaScript
import { ReactiveVar } from 'meteor/reactive-var';
|
|
const {
|
|
VIEWS,
|
|
STORAGE_KEY,
|
|
normalizeAllBoardsView,
|
|
resolveAllBoardsView,
|
|
} = require('/models/lib/allBoardsView');
|
|
|
|
// The state the All Boards controls share, and where the view choice is kept.
|
|
// Design: docs/Design/Page/All-Boards.md
|
|
//
|
|
// The controls live in `boardListHeaderBar` and the boards live in `boardList`.
|
|
// Those are two SEPARATE Blaze template instances - the header bar is rendered
|
|
// into the layout's headerBar region, the page into its content region - so a
|
|
// ReactiveVar on either instance is invisible to the other. The state they share
|
|
// lives here instead, at module scope, which is what lets the search field in the
|
|
// header bar filter the list in the page.
|
|
//
|
|
// Which views exist and which is the default is models/lib/allBoardsView.js: that
|
|
// part is pure and unit-tested, this part is the Meteor and browser glue.
|
|
|
|
// Remembered per BROWSER, not on the user document: it is a view preference for
|
|
// one page, it changes nothing anybody else can see, and it is not worth a
|
|
// profile field or a round trip. A board's view IS on the profile, because it
|
|
// follows the user between devices; this deliberately does not.
|
|
const viewVar = new ReactiveVar(null);
|
|
|
|
function readStoredView() {
|
|
try {
|
|
return normalizeAllBoardsView(window.localStorage.getItem(STORAGE_KEY));
|
|
} catch (e) {
|
|
return null; // private mode, or storage disabled
|
|
}
|
|
}
|
|
|
|
export function allBoardsView() {
|
|
return resolveAllBoardsView(viewVar.get() || readStoredView());
|
|
}
|
|
|
|
export function setAllBoardsView(view) {
|
|
if (!VIEWS.includes(view)) return;
|
|
viewVar.set(view);
|
|
try {
|
|
window.localStorage.setItem(STORAGE_KEY, view);
|
|
} catch (e) {
|
|
/* the choice still applies for this session */
|
|
}
|
|
}
|
|
|
|
export function isAllBoardsView(view) {
|
|
return allBoardsView() === view;
|
|
}
|
|
|
|
// The search term and the selected section, shared for the same reason: the
|
|
// controls are in the header bar and the boards they act on are in the page.
|
|
//
|
|
// Exported as the ReactiveVars themselves, not behind getters, because
|
|
// `boardList` assigns them onto its own instance (`this.boardSearchVar = …`) -
|
|
// so every `tpl.boardSearchVar.get()` already written against an instance
|
|
// variable keeps working, and the two templates read one object instead of two.
|
|
export const allBoardsSearchVar = new ReactiveVar('');
|
|
export const allBoardsMenuVar = new ReactiveVar('starred');
|
|
|
|
export function allBoardsSearch() {
|
|
return allBoardsSearchVar.get();
|
|
}
|
|
|
|
export function setAllBoardsSearch(term) {
|
|
allBoardsSearchVar.set(typeof term === 'string' ? term : '');
|
|
}
|