mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
The add-list form gets "or link a list from another board": pick a board you can see and one of its lists, and this board gets a list that shows that list's cards as they are, live. They stay the source board's cards, under its rules - opened, edited, moved by whoever may write the source board - and a card typed into the mirror is added to the source list by addCardToLinkedList, which checks the right to write in that list. In the Swimlanes view the mirror shows its cards once, in the first swimlane. The source cards come through linkedListCards, published only to a subscriber who may see both boards, so the board publication is not widened. A list cannot mirror its own board, an archived or foreign list, or another mirror. models/lib/linkedList.js decides; tests/linkedList.test.cjs covers the selector, the swimlane rule, the refused links, both visibility checks and the source board's write rule. A Meteor runtime run started with the new list fields. The new strings are English placeholders until the next translation pass. Thanks to javen9881 and xet7 ! Fixes #2809.
32 lines
1.5 KiB
JavaScript
32 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
// #2809: a linked whole list - a list on this board that is a live mirror of
|
|
// a list on another board. It shows the source list's cards as they are, and
|
|
// whoever may write the source board edits them (they stay that board's
|
|
// cards, under its rules); a card added in it is added to the source list.
|
|
// In the Swimlanes view the mirror shows its cards once, in the first
|
|
// swimlane, rather than repeating them in every swimlane.
|
|
// Pure: tests/linkedList.test.cjs.
|
|
|
|
function isLinkedList(list) {
|
|
return !!(list && typeof list.linkedListId === 'string' && list.linkedListId && typeof list.linkedBoardId === 'string' && list.linkedBoardId);
|
|
}
|
|
|
|
// The cards a linked list shows in `swimlaneId`: the source list's, in the
|
|
// board's first swimlane (or with no swimlanes); nothing elsewhere.
|
|
function linkedListCardsSelector(list, { swimlaneId, firstSwimlaneId } = {}) {
|
|
if (!isLinkedList(list)) return null;
|
|
if (swimlaneId && firstSwimlaneId && swimlaneId !== firstSwimlaneId) return { _id: { $in: [] } };
|
|
return { boardId: list.linkedBoardId, listId: list.linkedListId, archived: false };
|
|
}
|
|
|
|
// Linking a list to itself, or to a list of its own board, is no mirror.
|
|
function validLink({ boardId, sourceBoardId, sourceListId, sourceList }) {
|
|
if (!boardId || !sourceBoardId || !sourceListId || !sourceList) return false;
|
|
if (sourceBoardId === boardId) return false;
|
|
if (sourceList.boardId !== sourceBoardId || sourceList.archived) return false;
|
|
return !isLinkedList(sourceList);
|
|
}
|
|
|
|
module.exports = { isLinkedList, linkedListCardsSelector, validLink };
|