|
@@ -388,7 +388,9 @@ BlazeComponent.extendComponent({
|
|
let card = this.data();
|
|
let card = this.data();
|
|
const listSelect = this.$('.js-select-card-details-lists')[0];
|
|
const listSelect = this.$('.js-select-card-details-lists')[0];
|
|
const listId = listSelect.options[listSelect.selectedIndex].value;
|
|
const listId = listSelect.options[listSelect.selectedIndex].value;
|
|
- card.move(card.boardId, card.swimlaneId, listId, card.sort);
|
|
|
|
|
|
+
|
|
|
|
+ const minOrder = card.getMinSort(listId, card.swimlaneId);
|
|
|
|
+ card.move(card.boardId, card.swimlaneId, listId, minOrder - 1);
|
|
},
|
|
},
|
|
'click .js-go-to-linked-card'() {
|
|
'click .js-go-to-linked-card'() {
|
|
Utils.goCardId(this.data().linkedId);
|
|
Utils.goCardId(this.data().linkedId);
|
|
@@ -677,21 +679,13 @@ Template.cardDetailsActionsPopup.events({
|
|
'click .js-set-card-color': Popup.open('setCardColor'),
|
|
'click .js-set-card-color': Popup.open('setCardColor'),
|
|
'click .js-move-card-to-top'(event) {
|
|
'click .js-move-card-to-top'(event) {
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
- const minOrder = _.min(
|
|
|
|
- this.list()
|
|
|
|
- .cardsUnfiltered(this.swimlaneId)
|
|
|
|
- .map((c) => c.sort),
|
|
|
|
- );
|
|
|
|
|
|
+ const minOrder = this.getMinSort();
|
|
this.move(this.boardId, this.swimlaneId, this.listId, minOrder - 1);
|
|
this.move(this.boardId, this.swimlaneId, this.listId, minOrder - 1);
|
|
Popup.back();
|
|
Popup.back();
|
|
},
|
|
},
|
|
'click .js-move-card-to-bottom'(event) {
|
|
'click .js-move-card-to-bottom'(event) {
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
- const maxOrder = _.max(
|
|
|
|
- this.list()
|
|
|
|
- .cardsUnfiltered(this.swimlaneId)
|
|
|
|
- .map((c) => c.sort),
|
|
|
|
- );
|
|
|
|
|
|
+ const maxOrder = this.getMaxSort();
|
|
this.move(this.boardId, this.swimlaneId, this.listId, maxOrder + 1);
|
|
this.move(this.boardId, this.swimlaneId, this.listId, maxOrder + 1);
|
|
Popup.back();
|
|
Popup.back();
|
|
},
|
|
},
|
|
@@ -836,7 +830,9 @@ Template.moveCardPopup.events({
|
|
const listId = lSelect.options[lSelect.selectedIndex].value;
|
|
const listId = lSelect.options[lSelect.selectedIndex].value;
|
|
const slSelect = $('.js-select-swimlanes')[0];
|
|
const slSelect = $('.js-select-swimlanes')[0];
|
|
const swimlaneId = slSelect.options[slSelect.selectedIndex].value;
|
|
const swimlaneId = slSelect.options[slSelect.selectedIndex].value;
|
|
- card.move(boardId, swimlaneId, listId, 0);
|
|
|
|
|
|
+
|
|
|
|
+ const minOrder = card.getMinSort(listId, swimlaneId);
|
|
|
|
+ card.move(boardId, swimlaneId, listId, minOrder - 1);
|
|
|
|
|
|
// set new id's to card object in case the card is moved to top by the comment "moveCard" after this command (.js-move-card)
|
|
// set new id's to card object in case the card is moved to top by the comment "moveCard" after this command (.js-move-card)
|
|
this.boardId = boardId;
|
|
this.boardId = boardId;
|
|
@@ -964,8 +960,10 @@ Template.copyCardPopup.events({
|
|
const boardId = bSelect.options[bSelect.selectedIndex].value;
|
|
const boardId = bSelect.options[bSelect.selectedIndex].value;
|
|
const textarea = $('#copy-card-title');
|
|
const textarea = $('#copy-card-title');
|
|
const title = textarea.val().trim();
|
|
const title = textarea.val().trim();
|
|
- // insert new card to the bottom of new list
|
|
|
|
- card.sort = Lists.findOne(card.listId).cards().count();
|
|
|
|
|
|
+
|
|
|
|
+ // insert new card to the top of new list
|
|
|
|
+ const minOrder = card.getMinSort(listId, swimlaneId);
|
|
|
|
+ card.sort = minOrder - 1;
|
|
|
|
|
|
if (title) {
|
|
if (title) {
|
|
card.title = title;
|
|
card.title = title;
|