mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
A feature's guide now sits under the menu it is used from, read from the templates rather than from where somebody once put it: Header-Bar, All-Boards, Pages, Board-Header (search and every Board View), Board-Sidebar (Board Settings, Filter, Members, Labels, Archive), Rules, Swimlanes, Lists, Cards, Member-Settings, Admin-Panel and Login-Page. Topics used from several menus (editor, history, theme, translations, email, troubleshooting) are in General. - Each area has a README mapping its menu entries to their guides and to the template or server module that implements them. Board-Header/README.md lists all 40 Board View entries with the template boardBody.jade renders; five views (Table, Calendar Mode, Time, Timeline, Map) have no guide of their own yet and say so. - Board-View.md listed 25 views while BOARD_VIEWS has 40; it now lists all of them with their English labels. - Pages keep their file names. Where a released changelog links an old path, a "# Moved" page stays there and points to the new one; test-menu.sh skips folders holding only those. - Undo was filed under Login; it is General/Undo now. - Every link in docs, code comments, scripts and tests follows the move; docsLinksResolve checks them all. Tests that read a doc follow it to its new place. boardViewSettings now fails when Board-View.md or Board-Header/README.md differs from BOARD_VIEWS, or names a template boardBody.jade does not render. 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/Features/All-Boards/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 : '');
|
|
}
|