summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicu Tofan <nicu.tofan@gmail.com>2018-06-26 17:39:31 +0300
committerNicu Tofan <nicu.tofan@gmail.com>2018-06-26 17:39:31 +0300
commitb7d508e8c4cf858559e144053d119ceaebfa9697 (patch)
treed909d73704705e9f78f3039fd3d10dd3dfc685ea
parent439d7c3dbc38e6b8165b3d65f78d0f90e7e5d7db (diff)
downloadwekan-b7d508e8c4cf858559e144053d119ceaebfa9697.tar.gz
wekan-b7d508e8c4cf858559e144053d119ceaebfa9697.tar.bz2
wekan-b7d508e8c4cf858559e144053d119ceaebfa9697.zip
Added ability to change card's parent.
-rw-r--r--client/components/cards/cardDetails.jade27
-rw-r--r--client/components/cards/cardDetails.js137
-rw-r--r--i18n/en.i18n.json3
-rw-r--r--models/boards.js4
-rw-r--r--models/cards.js15
5 files changed, 156 insertions, 30 deletions
diff --git a/client/components/cards/cardDetails.jade b/client/components/cards/cardDetails.jade
index 0110d12e..aaad7c7c 100644
--- a/client/components/cards/cardDetails.jade
+++ b/client/components/cards/cardDetails.jade
@@ -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
diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js
index d4957964..5fee1680 100644
--- a/client/components/cards/cardDetails.js
+++ b/client/components/cards/cardDetails.js
@@ -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,36 +558,119 @@ 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;
+ }
+ },
+
+ boards() {
+ const boards = Boards.find({
+ archived: false,
+ 'members.userId': Meteor.userId(),
+ }, {
+ sort: ['title'],
+ });
+ return boards;
+ },
-Template.cardMorePopup.events({
- '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
- const StringToCopyElement = document.getElementById('cardURL');
- StringToCopyElement.select();
- if (document.execCommand('copy')) {
- StringToCopyElement.blur();
+ cards() {
+ if (this.parentBoard) {
+ return this.parentBoard.cards();
} else {
- document.getElementById('cardURL').selectionStart = 0;
- document.getElementById('cardURL').selectionEnd = 999;
- document.execCommand('copy');
- if (window.getSelection) {
- if (window.getSelection().empty) { // Chrome
- window.getSelection().empty();
- } else if (window.getSelection().removeAllRanges) { // Firefox
- window.getSelection().removeAllRanges();
- }
- } else if (document.selection) { // IE?
- document.selection.empty();
- }
+ return [];
}
},
- 'click .js-delete': Popup.afterConfirm('cardDelete', function () {
- Popup.close();
- Cards.remove(this._id);
- Utils.goBoardId(this.boardId);
- }),
-});
+
+ 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
+ const StringToCopyElement = document.getElementById('cardURL');
+ StringToCopyElement.select();
+ if (document.execCommand('copy')) {
+ StringToCopyElement.blur();
+ } else {
+ document.getElementById('cardURL').selectionStart = 0;
+ document.getElementById('cardURL').selectionEnd = 999;
+ document.execCommand('copy');
+ if (window.getSelection) {
+ if (window.getSelection().empty) { // Chrome
+ window.getSelection().empty();
+ } else if (window.getSelection().removeAllRanges) { // Firefox
+ window.getSelection().removeAllRanges();
+ }
+ } else if (document.selection) { // IE?
+ document.selection.empty();
+ }
+ }
+ },
+ 'click .js-delete': Popup.afterConfirm('cardDelete', function () {
+ Popup.close();
+ 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',
diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json
index e89d6928..42dbd2d5 100644
--- a/i18n/en.i18n.json
+++ b/i18n/en.i18n.json
@@ -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"
}
diff --git a/models/boards.js b/models/boards.js
index 2d80a56a..c83050c0 100644
--- a/models/boards.js
+++ b/models/boards.js
@@ -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;
diff --git a/models/cards.js b/models/cards.js
index 323ec407..b6a7b4c6 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -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}};
+ },
+
});