2023-01-14 19:33:36 +01:00
|
|
|
import { ReactiveCache } from '/imports/reactiveCache';
|
2026-03-08 10:57:20 +02:00
|
|
|
import { BoardSwimlaneListDialog } from '/client/lib/dialogWithBoardSwimlaneList';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Extension of BoardSwimlaneListDialog that adds card selection.
|
|
|
|
|
* Used by popup templates that need board + swimlane + list + card selectors.
|
|
|
|
|
*/
|
|
|
|
|
export class BoardSwimlaneListCardDialog extends BoardSwimlaneListDialog {
|
|
|
|
|
constructor(tpl, callbacks = {}) {
|
|
|
|
|
super(tpl, callbacks);
|
2026-01-31 09:20:24 +02:00
|
|
|
this.selectedCardId = new ReactiveVar('');
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-08 10:57:20 +02:00
|
|
|
getDefaultOption() {
|
|
|
|
|
return {
|
|
|
|
|
boardId: '',
|
|
|
|
|
swimlaneId: '',
|
|
|
|
|
listId: '',
|
|
|
|
|
cardId: '',
|
|
|
|
|
};
|
2025-12-29 19:17:06 +02:00
|
|
|
}
|
|
|
|
|
|
2026-03-08 10:57:20 +02:00
|
|
|
/** Override to also set cardId if available */
|
2025-12-29 19:17:06 +02:00
|
|
|
setOption(boardId) {
|
|
|
|
|
super.setOption(boardId);
|
|
|
|
|
if (this.cardOption && this.cardOption.cardId) {
|
|
|
|
|
this.selectedCardId.set(this.cardOption.cardId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-29 21:42:19 +02:00
|
|
|
/** returns all available cards of the current list */
|
|
|
|
|
cards() {
|
2026-03-08 10:57:20 +02:00
|
|
|
const list = ReactiveCache.getList({
|
|
|
|
|
_id: this.selectedListId.get(),
|
|
|
|
|
boardId: this.selectedBoardId.get(),
|
|
|
|
|
});
|
2026-02-08 01:35:31 +02:00
|
|
|
const swimlaneId = this.selectedSwimlaneId.get();
|
|
|
|
|
if (list && swimlaneId) {
|
|
|
|
|
return list.cards(swimlaneId).sort((a, b) => a.sort - b.sort);
|
2025-12-29 21:42:19 +02:00
|
|
|
} else {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-08 10:57:20 +02:00
|
|
|
/** returns if the card id was the last confirmed one */
|
2022-07-03 23:57:53 +02:00
|
|
|
isDialogOptionCardId(cardId) {
|
2026-03-08 10:57:20 +02:00
|
|
|
return this.cardOption.cardId == cardId;
|
2022-07-03 23:57:53 +02:00
|
|
|
}
|
|
|
|
|
|
2026-03-08 10:57:20 +02:00
|
|
|
/** Override to also reset card id on board change */
|
2025-12-29 19:17:06 +02:00
|
|
|
getBoardData(boardId) {
|
|
|
|
|
const self = this;
|
|
|
|
|
Meteor.subscribe('board', boardId, false, {
|
|
|
|
|
onReady() {
|
|
|
|
|
const sameBoardId = self.selectedBoardId.get() == boardId;
|
|
|
|
|
self.selectedBoardId.set(boardId);
|
|
|
|
|
|
|
|
|
|
if (!sameBoardId) {
|
|
|
|
|
self.setFirstSwimlaneId();
|
|
|
|
|
self.setFirstListId();
|
|
|
|
|
self.selectedCardId.set('');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
2022-07-03 23:57:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|