diff options
-rw-r--r-- | client/components/cards/labels.jade | 2 | ||||
-rw-r--r-- | models/boards.js | 35 | ||||
-rw-r--r-- | models/import.js | 14 |
3 files changed, 24 insertions, 27 deletions
diff --git a/client/components/cards/labels.jade b/client/components/cards/labels.jade index a868627c..31bd4d06 100644 --- a/client/components/cards/labels.jade +++ b/client/components/cards/labels.jade @@ -18,7 +18,7 @@ template(name="editLabelPopup") form.edit-label +formLabel button.primary.wide.left(type="submit") {{_ 'save'}} - span.right + button.js-delete-label.negate.wide.right {{_ 'delete'}} template(name="deleteLabelPopup") p {{_ "label-delete-pop"}} diff --git a/models/boards.js b/models/boards.js index e42e06c6..4d9fd7c0 100644 --- a/models/boards.js +++ b/models/boards.js @@ -143,29 +143,26 @@ Boards.mutations({ }, addLabel(name, color) { - const _id = Random.id(6); - - // If an empty label of a given color already exists we don't want to create - // an other one because they would be indistinguishable in the UI (they - // would still have different `_id` but that is not exposed to the user). - if (name === '' && this.getLabel(name, color)) { - return {}; + // If label with the same name and color already exists we don't want to + // create another one because they would be indistinguishable in the UI + // (they would still have different `_id` but that is not exposed to the + // user). + if (!this.getLabel(name, color)) { + const _id = Random.id(6); + return { $push: {labels: { _id, name, color }}}; } - return { $push: {labels: { _id, name, color }}}; }, editLabel(labelId, name, color) { - const labelIndex = this.labelIndex(labelId); - - if (name === '' && this.getLabel(name, color)) { - return {}; + if (!this.getLabel(name, color)) { + const labelIndex = this.labelIndex(labelId); + return { + $set: { + [`labels.${labelIndex}.name`]: name, + [`labels.${labelIndex}.color`]: color, + }, + }; } - return { - $set: { - [`labels.${labelIndex}.name`]: name, - [`labels.${labelIndex}.color`]: color, - }, - }; }, removeLabel(labelId) { @@ -330,7 +327,7 @@ if (Meteor.isServer) { { boardId: doc._id }, { $pull: { - labels: removedLabelId, + labelIds: removedLabelId, }, }, { multi: true } diff --git a/models/import.js b/models/import.js index 7b441df6..a6e9f3d5 100644 --- a/models/import.js +++ b/models/import.js @@ -186,7 +186,7 @@ class TrelloCreator { userId: Meteor.userId(), }; // add labels - if(card.idLabels) { + if (card.idLabels) { cardToCreate.labelIds = card.idLabels.map((trelloId) => { return this.labels[trelloId]; }); @@ -211,7 +211,7 @@ class TrelloCreator { }); // add comments const comments = this.comments[card.id]; - if(comments) { + if (comments) { comments.forEach((comment) => { const commentToCreate = { boardId, @@ -258,7 +258,7 @@ class TrelloCreator { } getPermission(trelloPermissionCode) { - if(trelloPermissionCode === 'public') { + if (trelloPermissionCode === 'public') { return 'public'; } // Wekan does NOT have organization level, so we default both 'private' and @@ -282,7 +282,7 @@ class TrelloCreator { break; case 'commentCard': const id = action.data.card.id; - if(this.comments[id]) { + if (this.comments[id]) { this.comments[id].push(action); } else { this.comments[id] = [action]; @@ -309,7 +309,7 @@ Meteor.methods({ trelloCreator.checkLabels(trelloBoard.labels); trelloCreator.checkLists(trelloBoard.lists); trelloCreator.checkCards(trelloBoard.cards); - } catch(e) { + } catch (e) { throw new Meteor.Error('error-json-schema'); } @@ -344,10 +344,10 @@ Meteor.methods({ // 2. check parameters are ok from a business point of view (exist & // authorized) const list = Lists.findOne(data.listId); - if(!list) { + if (!list) { throw new Meteor.Error('error-list-doesNotExist'); } - if(Meteor.isServer) { + if (Meteor.isServer) { if (!allowIsBoardMember(Meteor.userId(), Boards.findOne(list.boardId))) { throw new Meteor.Error('error-board-notAMember'); } |