Files
wekan/models/lib/allBoardsSidebar.js
T
Lauri Ojansivu fcfed1fd37 All Boards: Search and Multi-Selection become the board header's controls.
All Boards had a search FIELD in its header bar, and a Multi-Selection button
whose actions were four icons beside it. A board has a search BUTTON and a
Multi-Selection button, and both open the right sidebar. Two pages, the same two
control names in the same place, behaving differently - and one of them not the
way the rest of WeKan does. They are the board's now, and they are the same
markup: headerBarControls.jade holds one headerSearchButton and one
headerMultiSelectionButton, included by the board header of the Swimlanes view
and by the All Boards bar. The two copies had already drifted - the close button
that turns Multi-Selection off said "Clear filter" on the board header, which is
what a different control does, and says multi-selection-off in both now.

Only the markup is shared. What a click does is not - a board searches and
selects cards, All Boards searches and selects boards - and it does not need to
be: a Blaze event map catches events from the templates rendered inside it, so
each bar's own map sees the clicks on its own copy. isActive is passed in,
because the two pages keep different selection objects.

All Boards has a right sidebar of its own. Not the board one: that is built
around a board's members, labels, activities and settings, and this page has no
board. It borrows the SHELL - the same .board-sidebar.sidebar classes, the same
close button, the same title-and-back-arrow above a view - so the two look and
behave alike, and it has three views. home, what the hamburger opens, is the
page's menu: Search, Multi-Selection, and Boards in Archive, which had a handler
in the header bar and no way to reach it. search is the field that was in the
bar, still writing the page's own search term so the boards behind it narrow as
you type. multiselection is where the actions on a selection went - star, home,
archive, duplicate and a way out - each with its name beside it instead of being
a crowded icon. Open/closed and which view are separate, so closing does not
forget where you were, and Escape closes it by KEY only: the click half of
EscapeActions would close it on every click, including clicks inside it.

The bar also gained the divider and the hamburger, in their own flex item and
last in the source exactly as the board header has them, which is what keeps the
hamburger in the top right on a phone while the other buttons wrap.

Two things this turned up. A .jade file is not picked up by being on disk - it
has to be imported from client/features/, and the shared controls threw "No such
template: headerSearchButton" on render until they were; a guard now requires
every .jade under client/components to be imported and every +template it
includes to exist, and it found a dangling +subtaskDeleteDialog that has never
had a template (unreachable, so it has never thrown, and it is recorded with
that reason rather than hidden). And deriving a template name from a view name
gave allBoardsMultiselectionSidebar for allBoardsMultiSelectionSidebar - one
letter, renders nothing, no error worth the name - so the names are an explicit
map the guard checks.

Written down in docs/Design/Page/Search.md and Multi-Selection.md, one per
shared control, each covering both pages, with All-Boards.md pointing at them.

Four guards pinned the previous shape and now pin this one, each saying why it
changed: the search field in the bar, the four selection buttons in the bar, the
Multi-Selection parity check that is structural now that there is one template,
and the home-board action that moved to the sidebar.

Thanks to xet7 !
2026-07-31 07:14:52 +03:00

74 lines
2.6 KiB
JavaScript

'use strict';
// The views of the All Boards right sidebar, and what each one is called.
//
// The All Boards page has its own sidebar rather than the board one: that one
// is built around a board - its members, its labels, its activities, its
// settings - and All Boards has no board. What IS shared is the shape: the same
// `.board-sidebar.sidebar` shell, the same "a view at a time with a title and a
// back arrow", so the two look and behave alike.
//
// Pure: no Meteor, no DOM. The ReactiveVar that holds the current view is
// client/lib/allBoardsSidebar.js.
const SIDEBAR_HOME = 'home';
const SIDEBAR_SEARCH = 'search';
const SIDEBAR_MULTISELECTION = 'multiselection';
// `home` is what the hamburger opens, the way the board sidebar opens
// `homeSidebar`; the other two are what their header-bar buttons open.
const SIDEBAR_VIEWS = [SIDEBAR_HOME, SIDEBAR_SEARCH, SIDEBAR_MULTISELECTION];
const DEFAULT_SIDEBAR_VIEW = SIDEBAR_HOME;
// The i18n key of a view's title. `home` has none: like the board sidebar, the
// default view shows no title row and no back arrow, because there is nothing
// to go back to.
const SIDEBAR_VIEW_TITLES = {
[SIDEBAR_SEARCH]: 'search-boards',
[SIDEBAR_MULTISELECTION]: 'multi-selection',
};
// null when the stored/asked-for value is not a view, so a caller can tell
// "not a view" from "the default view".
function normalizeSidebarView(view) {
return SIDEBAR_VIEWS.includes(view) ? view : null;
}
function resolveSidebarView(view) {
return normalizeSidebarView(view) || DEFAULT_SIDEBAR_VIEW;
}
function sidebarViewTitleKey(view) {
return SIDEBAR_VIEW_TITLES[normalizeSidebarView(view)] || null;
}
// The Blaze template that draws a view - named explicitly, NOT derived from the
// view name. Deriving it (`allBoards` + capitalise + `Sidebar`) gave
// `allBoardsMultiselectionSidebar` for a template called
// `allBoardsMultiSelectionSidebar`, and a name that is one letter wrong renders
// nothing at all with no error worth the name. A map is checkable: the guard
// asserts every entry is a template that exists.
const SIDEBAR_VIEW_TEMPLATES = {
[SIDEBAR_HOME]: 'allBoardsHomeSidebar',
[SIDEBAR_SEARCH]: 'allBoardsSearchSidebar',
[SIDEBAR_MULTISELECTION]: 'allBoardsMultiSelectionSidebar',
};
function sidebarViewTemplate(view) {
return SIDEBAR_VIEW_TEMPLATES[resolveSidebarView(view)];
}
module.exports = {
SIDEBAR_HOME,
SIDEBAR_SEARCH,
SIDEBAR_MULTISELECTION,
SIDEBAR_VIEWS,
DEFAULT_SIDEBAR_VIEW,
SIDEBAR_VIEW_TITLES,
SIDEBAR_VIEW_TEMPLATES,
normalizeSidebarView,
resolveSidebarView,
sidebarViewTitleKey,
sidebarViewTemplate,
};