Files
wekan/client/components/boards/bigboardView.js
T
Lauri Ojansivu 5323fdbce6 Add a "Bigboard" board view listing every board at once (#4223).
Add "Bigboard" to the Board View menu, right after Dashboard, matching
the existing 19-entry pattern (menu row in boardHeader.jade, click
handler + boardViewName() entry in boardHeader.js, isViewBigboard()
helper + boardBody.jade branch, the two whitelist arrays in
client/lib/utils.js, and profile.boardView's allowedValues in
models/users.js).

Unlike the other views, Bigboard renders every board the current user
is a member of, not just the open one - the same idea as Kanboard's
BigBoard plugin. The new bigboardView template (bigboardView.jade/js)
queries the user's boards with the same membership selector the All
Boards page uses, subscribes each one's lists/swimlanes/cards through
the existing 'board' composite publication, and stacks each board as
its own section reusing the existing listsGroup/list/card templates -
so editing, dragging and opening a card behave exactly as on a normal
board page.

Rendering several boards' lists on one page at once exposed a bug the
single-board case never could: list drag-and-drop connects via a plain
'.js-swimlane, .js-lists' jQuery UI sortable selector, which would let
a list be dragged out of one board's section into another's now that
more than one board's lists share a page. Added a data-board-id
attribute to the swimlane/listsGroup root elements and a
connectWithSelector() helper (swimlanes.js) that scopes the connect
selector to the dragged list's own board id when one is present -
ordinary single-board views still have exactly one board id on the
page, so their behaviour is unchanged.

Thanks to Jieiku and xet7 !
2026-09-10 19:47:26 +03:00

63 lines
2.3 KiB
JavaScript

import { ReactiveCache } from '/imports/reactiveCache';
import { ReactiveVar } from 'meteor/reactive-var';
const { notHelperBoardTitle } = require('/models/lib/helperBoards');
// #4223: Kanboard's BigBoard plugin shows every board the user can access,
// stacked on one page, each as its own mini kanban board - no manual setup,
// automatic based on board membership. This mirrors that: the same
// membership query the All Boards page already uses (boardsList.js), minus
// templates and the archive, each board's lists/cards published via the same
// 'board' composite subscription a normal single-board page uses so the
// existing swimlanes/listsGroup + list/card templates (and their
// drag-and-drop) work unmodified per board.
function bigboardQuery() {
return {
archived: false,
type: 'board',
'members.userId': Meteor.userId(),
title: notHelperBoardTitle(),
};
}
Template.bigboardView.onCreated(function () {
const instance = this;
instance.subsReady = new ReactiveVar(false);
// The metadata-only 'boards' subscription is already kept alive app-wide
// (client/components/main/header.js), so the board list itself is
// available immediately. What is still missing per board is its lists,
// swimlanes and cards, which normally only get subscribed to when that
// one board is opened - so subscribe to each visible board's own 'board'
// composite here.
instance.autorun(() => {
const boards = ReactiveCache.getBoards(bigboardQuery(), {
sort: { sort: 1 },
});
let allReady = true;
boards.forEach((board) => {
const handle = instance.subscribe('board', board._id, false);
if (!handle.ready()) allReady = false;
});
instance.subsReady.set(allReady);
});
});
Template.bigboardView.helpers({
isLoading() {
return !Template.instance().subsReady.get();
},
bigboardBoards() {
return ReactiveCache.getBoards(bigboardQuery(), { sort: { sort: 1 } });
},
hasBoards() {
return ReactiveCache.getBoards(bigboardQuery(), {}).length > 0;
},
});
Template.bigboardView.events({
// See statsView.js: stop the board canvas's drag-to-scroll from swallowing
// the pointer/touch events a board section's own controls need.
'mousedown .bigboard-board-title'(event) {
event.stopPropagation();
},
});