mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Added ability to change card's parent.
This commit is contained in:
parent
439d7c3dbc
commit
b7d508e8c4
5 changed files with 157 additions and 31 deletions
|
|
@ -283,10 +283,37 @@ template(name="cardMorePopup")
|
|||
button.js-copy-card-link-to-clipboard(class="btn") {{_ 'copy-card-link-to-clipboard'}}
|
||||
span.clearfix
|
||||
br
|
||||
h2 {{_ 'change-card-parent'}}
|
||||
label {{_ 'source-board'}}:
|
||||
select.js-field-parent-board
|
||||
each boards
|
||||
if isParentBoard
|
||||
option(value="{{_id}}" selected) {{title}}
|
||||
else
|
||||
option(value="{{_id}}") {{title}}
|
||||
if isTopLevel
|
||||
option(value="none" selected) {{_ 'custom-field-dropdown-none'}}
|
||||
else
|
||||
option(value="none") {{_ 'custom-field-dropdown-none'}}
|
||||
|
||||
label {{_ 'parent-card'}}:
|
||||
select.js-field-parent-card
|
||||
if isTopLevel
|
||||
option(value="none" selected) {{_ 'custom-field-dropdown-none'}}
|
||||
else
|
||||
each cards
|
||||
if isParentCard
|
||||
option(value="{{_id}}" selected) {{title}}
|
||||
else
|
||||
option(value="{{_id}}") {{title}}
|
||||
option(value="none") {{_ 'custom-field-dropdown-none'}}
|
||||
br
|
||||
| {{_ 'added'}}
|
||||
span.date(title=card.createdAt) {{ moment createdAt 'LLL' }}
|
||||
a.js-delete(title="{{_ 'card-delete-notice'}}") {{_ 'delete'}}
|
||||
|
||||
|
||||
|
||||
template(name="cardDeletePopup")
|
||||
p {{_ "card-delete-pop"}}
|
||||
unless archived
|
||||
|
|
|
|||
|
|
@ -390,7 +390,6 @@ Template.moveCardPopup.events({
|
|||
Popup.close();
|
||||
},
|
||||
});
|
||||
|
||||
BlazeComponent.extendComponent({
|
||||
onCreated() {
|
||||
subManager.subscribe('board', Session.get('currentBoard'));
|
||||
|
|
@ -427,6 +426,7 @@ BlazeComponent.extendComponent({
|
|||
},
|
||||
}).register('boardsAndLists');
|
||||
|
||||
|
||||
function cloneCheckList(_id, checklist) {
|
||||
'use strict';
|
||||
const checklistId = checklist._id;
|
||||
|
|
@ -558,8 +558,63 @@ Template.copyChecklistToManyCardsPopup.events({
|
|||
},
|
||||
});
|
||||
|
||||
BlazeComponent.extendComponent({
|
||||
onCreated() {
|
||||
this.currentCard = this.currentData();
|
||||
this.parentCard = this.currentCard.parentCard();
|
||||
if (this.parentCard) {
|
||||
this.parentBoard = this.parentCard.board();
|
||||
} else {
|
||||
this.parentBoard = null;
|
||||
}
|
||||
},
|
||||
|
||||
Template.cardMorePopup.events({
|
||||
boards() {
|
||||
const boards = Boards.find({
|
||||
archived: false,
|
||||
'members.userId': Meteor.userId(),
|
||||
}, {
|
||||
sort: ['title'],
|
||||
});
|
||||
return boards;
|
||||
},
|
||||
|
||||
cards() {
|
||||
if (this.parentBoard) {
|
||||
return this.parentBoard.cards();
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
|
||||
isParentBoard() {
|
||||
const board = this.currentData();
|
||||
if (this.parentBoard) {
|
||||
return board._id === this.parentBoard;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
isParentCard() {
|
||||
const card = this.currentData();
|
||||
if (this.parentCard) {
|
||||
return card._id === this.parentCard;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
setParentCardId(cardId) {
|
||||
if (cardId === 'null') {
|
||||
cardId = null;
|
||||
this.parentCard = null;
|
||||
} else {
|
||||
this.parentCard = Cards.findOne(cardId);
|
||||
}
|
||||
this.currentCard.setParentId(cardId);
|
||||
},
|
||||
|
||||
events() {
|
||||
return [{
|
||||
'click .js-copy-card-link-to-clipboard' () {
|
||||
// Clipboard code from:
|
||||
// https://stackoverflow.com/questions/6300213/copy-selected-text-to-the-clipboard-without-using-flash-must-be-cross-browser
|
||||
|
|
@ -587,7 +642,35 @@ Template.cardMorePopup.events({
|
|||
Cards.remove(this._id);
|
||||
Utils.goBoardId(this.boardId);
|
||||
}),
|
||||
'change .js-field-parent-board'(evt) {
|
||||
const selection = $(evt.currentTarget).val();
|
||||
const list = $('.js-field-parent-card');
|
||||
list.empty();
|
||||
if (selection === 'none') {
|
||||
this.parentBoard = null;
|
||||
list.prop('disabled', true);
|
||||
} else {
|
||||
this.parentBoard = Boards.findOne(selection);
|
||||
this.parentBoard.cards().forEach(function(card) {
|
||||
list.append(
|
||||
$('<option></option>').val(card._id).html(card.title)
|
||||
);
|
||||
});
|
||||
list.prop('disabled', false);
|
||||
}
|
||||
list.append(
|
||||
`<option value='none' selected='selected'>${TAPi18n.__('custom-field-dropdown-none')}</option>`
|
||||
);
|
||||
this.setParentCardId('null');
|
||||
},
|
||||
'change .js-field-parent-card'(evt) {
|
||||
const selection = $(evt.currentTarget).val();
|
||||
this.setParentCardId(selection);
|
||||
},
|
||||
}];
|
||||
},
|
||||
}).register('cardMorePopup');
|
||||
|
||||
|
||||
// Close the card details pane by pressing escape
|
||||
EscapeActions.register('detailsPane',
|
||||
|
|
|
|||
|
|
@ -493,6 +493,9 @@
|
|||
"prefix-with-parent": "Prefix with parent",
|
||||
"subtext-with-full-path": "Subtext with full path",
|
||||
"subtext-with-parent": "Subtext with parent",
|
||||
"change-card-parent": "Change card's parent",
|
||||
"parent-card": "Parent card",
|
||||
"source-board": "Source board",
|
||||
"no-parent": "Don't show parent"
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -220,6 +220,10 @@ Boards.helpers({
|
|||
return Swimlanes.find({ boardId: this._id, archived: false }, { sort: { sort: 1 } });
|
||||
},
|
||||
|
||||
cards() {
|
||||
return Cards.find({ boardId: this._id, archived: false }, { sort: { sort: 1 } });
|
||||
},
|
||||
|
||||
hasOvertimeCards(){
|
||||
const card = Cards.findOne({isOvertime: true, boardId: this._id, archived: false} );
|
||||
return card !== undefined;
|
||||
|
|
|
|||
|
|
@ -327,10 +327,14 @@ Cards.helpers({
|
|||
},
|
||||
|
||||
parentCardName() {
|
||||
if (this.parentId === '') {
|
||||
return '';
|
||||
let result = '';
|
||||
if (this.parentId !== '') {
|
||||
const card = Cards.findOne(this.parentId);
|
||||
if (card) {
|
||||
result = card.title;
|
||||
}
|
||||
return Cards.findOne(this.parentId).title;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
parentListId() {
|
||||
|
|
@ -541,6 +545,11 @@ Cards.mutations({
|
|||
unsetSpentTime() {
|
||||
return {$unset: {spentTime: '', isOvertime: false}};
|
||||
},
|
||||
|
||||
setParentId(parentId) {
|
||||
return {$set: {parentId}};
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue