summaryrefslogtreecommitdiffstats
path: root/client/components/cards
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 /client/components/cards
parent439d7c3dbc38e6b8165b3d65f78d0f90e7e5d7db (diff)
downloadwekan-b7d508e8c4cf858559e144053d119ceaebfa9697.tar.gz
wekan-b7d508e8c4cf858559e144053d119ceaebfa9697.tar.bz2
wekan-b7d508e8c4cf858559e144053d119ceaebfa9697.zip
Added ability to change card's parent.
Diffstat (limited to 'client/components/cards')
-rw-r--r--client/components/cards/cardDetails.jade27
-rw-r--r--client/components/cards/cardDetails.js137
2 files changed, 137 insertions, 27 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',