wekan/client/lib/dialogWithBoardSwimlaneListCard.js
Harry Adel f1625ad1f5 Migrate client library code from BlazeComponent to Template pattern
Convert popup, inlinedform, multiSelection, spinner, cardSearch,
datepicker, and dialog helper libraries to use native Meteor
Template.onCreated/helpers/events instead of BlazeComponent.
Update reactiveCache to remove BlazeComponent dependency.
2026-03-08 11:04:53 +02:00

67 lines
1.8 KiB
JavaScript

import { ReactiveCache } from '/imports/reactiveCache';
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);
this.selectedCardId = new ReactiveVar('');
}
getDefaultOption() {
return {
boardId: '',
swimlaneId: '',
listId: '',
cardId: '',
};
}
/** Override to also set cardId if available */
setOption(boardId) {
super.setOption(boardId);
if (this.cardOption && this.cardOption.cardId) {
this.selectedCardId.set(this.cardOption.cardId);
}
}
/** returns all available cards of the current list */
cards() {
const list = ReactiveCache.getList({
_id: this.selectedListId.get(),
boardId: this.selectedBoardId.get(),
});
const swimlaneId = this.selectedSwimlaneId.get();
if (list && swimlaneId) {
return list.cards(swimlaneId).sort((a, b) => a.sort - b.sort);
} else {
return [];
}
}
/** returns if the card id was the last confirmed one */
isDialogOptionCardId(cardId) {
return this.cardOption.cardId == cardId;
}
/** Override to also reset card id on board change */
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('');
}
},
});
}
}