mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
A caret leads the group, at its leading edge - left of the lock in a left-to-right page, right of it in Arabic, because its direction comes from the same rule every other caret here uses. Folded, the seven controls after it are gone - Private, Muted, Sort Cards, Filter, Search, Show dependencies, Multi-Selection - and the bar is the logo, the board's name and the caret. The buttons a board's own Rules put in this bar are NOT folded with them: somebody added those to this board on purpose, so they sit outside the fold and the standard controls fold around them. It is named by the words the app already has - Collapse and Uncollapse - so no key was added to 147 language files to say them again, and it carries role="button" and a tabindex, so Enter and Space work. The sidebar's Members and Labels folds moved into the same store on the way: `client/lib/sidebarSectionState.js` is now `client/lib/foldState.js`, with `isFoldOpen` / `foldCaret` / `js-toggle-fold` for all three. One store, one rule, one class - a header caret and a sidebar caret pointing different ways in one language would be the bug this avoids. tests/sidebarSectionCollapse.test.cjs is tests/foldSections.test.cjs and covers both ends, including that the Rules buttons stay outside the fold. Thanks to xet7 !
40 lines
1.7 KiB
JavaScript
40 lines
1.7 KiB
JavaScript
import { Template } from 'meteor/templating';
|
|
import { ReactiveDict } from 'meteor/reactive-dict';
|
|
import { caretClassFor } from '/client/lib/sectionCaret';
|
|
|
|
// Which folding sections of the board's chrome are open.
|
|
//
|
|
// The same idea as an opened card's sections: the heading (or, in the header
|
|
// bar, a caret button of its own) is the handle, a caret says which way it is,
|
|
// and clicking it folds what belongs to it. Three of them so far:
|
|
//
|
|
// 'members' the right sidebar's People / Organizations / Teams /
|
|
// Domains tabs and the avatars in them
|
|
// 'labels' the right sidebar's labels, and the + that creates one
|
|
// 'board-controls' the first header bar's board controls - Private, Muted,
|
|
// Sort Cards, Filter, Search, Show dependencies,
|
|
// Multi-Selection
|
|
//
|
|
// Module-level, so a fold survives closing and reopening the sidebar and moving
|
|
// to another board in the same session - somebody who folded Members away did
|
|
// not mean "on this board only". Unknown keys default to OPEN, so a section
|
|
// added later shows up rather than hides.
|
|
//
|
|
// Activities is NOT here: it has a stored board setting of its own
|
|
// (`board.showActivities`), which also decides what the publication sends, so
|
|
// its caret writes that instead. client/components/sidebar/sidebar.js
|
|
const foldState = new ReactiveDict();
|
|
|
|
export function isFoldOpen(key) {
|
|
const state = foldState.get(key);
|
|
return state === undefined ? true : state;
|
|
}
|
|
|
|
export function toggleFold(key) {
|
|
if (!key) return;
|
|
foldState.set(key, !isFoldOpen(key));
|
|
}
|
|
|
|
Template.registerHelper('isFoldOpen', isFoldOpen);
|
|
Template.registerHelper('foldCaret', key => caretClassFor(isFoldOpen(key)));
|