Fix move card last selection is gone.

Thanks to mimZD and xet7 !

Fixes #6046
This commit is contained in:
Lauri Ojansivu 2025-12-29 19:17:06 +02:00
parent 74f1dfde72
commit 2d87ba18b3
2 changed files with 42 additions and 9 deletions

View file

@ -843,7 +843,7 @@ template(name="copyAndMoveCard")
label {{_ 'cards'}}:
select.js-select-cards
each cards
option(value="{{_id}}") {{add @index 1}}. {{title}}
option(value="{{_id}}" selected="{{#if isDialogOptionCardId _id}}selected{{/if}}") {{add @index 1}}. {{title}}
div
input(type="radio" name="position" value="above" checked id="position-above" style="display: inline")

View file

@ -12,6 +12,23 @@ export class DialogWithBoardSwimlaneListCard extends DialogWithBoardSwimlaneList
return ret;
}
onCreated() {
super.onCreated();
this.selectedCardId = new ReactiveVar('');
}
/** set the last confirmed dialog field values
* @param boardId the current board id
*/
setOption(boardId) {
super.setOption(boardId);
// Also set cardId if available
if (this.cardOption && this.cardOption.cardId) {
this.selectedCardId.set(this.cardOption.cardId);
}
}
/** returns if the card id was the last confirmed one
* @param cardId check this card id
* @return if the card id was the last confirmed one
@ -21,14 +38,28 @@ export class DialogWithBoardSwimlaneListCard extends DialogWithBoardSwimlaneList
return ret;
}
/** returns all available cards of the current list */
cards() {
const list = ReactiveCache.getList(this.selectedListId.get());
let ret = [];
if (list) {
ret = list.cards(this.selectedSwimlaneId.get());
}
return ret;
/** get the board data from the server
* @param boardId get the board data of this board id
*/
getBoardData(boardId) {
const self = this;
Meteor.subscribe('board', boardId, false, {
onReady() {
const sameBoardId = self.selectedBoardId.get() == boardId;
self.selectedBoardId.set(boardId);
if (!sameBoardId) {
// reset swimlane id
self.setFirstSwimlaneId();
// reset list id
self.setFirstListId();
// reset card id
self.selectedCardId.set('');
}
},
});
}
events() {
@ -65,6 +96,8 @@ export class DialogWithBoardSwimlaneListCard extends DialogWithBoardSwimlaneList
},
'change .js-select-lists'(event) {
this.selectedListId.set($(event.currentTarget).val());
// Reset card selection when list changes
this.selectedCardId.set('');
},
},
];