From b0ac10d94a8200a1ad0199a82c3f9d9be7ac9882 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Tue, 24 Jul 2018 18:18:40 +0200 Subject: Add the ability to change the card background Currently the only way to set it is via the REST API --- models/cards.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'models') diff --git a/models/cards.js b/models/cards.js index a20da5ec..7251faeb 100644 --- a/models/cards.js +++ b/models/cards.js @@ -65,6 +65,17 @@ Cards.attachSchema(new SimpleSchema({ defaultValue: '', }, + color: { + type: String, + optional: true, + allowedValues: [ + 'green', 'yellow', 'orange', 'red', 'purple', + 'blue', 'sky', 'lime', 'pink', 'black', + 'silver', 'peachpuff', 'crimson', 'plum', 'darkgreen', + 'slateblue', 'magenta', 'gold', 'navy', 'gray', + 'saddlebrown', 'paleturquoise', 'mistyrose', 'indigo', + ], + }, createdAt: { /** * creation date @@ -435,7 +446,12 @@ Cards.helpers({ definition, }; }); + }, + colorClass() { + if (this.color) + return this.color; + return ''; }, absoluteUrl() { @@ -1542,6 +1558,15 @@ if (Meteor.isServer) { * @operation edit_card * @summary Edit Fields in a Card * + * @description Edit a card + * + * The color has to be chosen between `green`, `yellow`, `orange`, `red`, + * `purple`, `blue`, `sky`, `lime`, `pink`, `black`, `silver`, `peachpuff`, + * `crimson`, `plum`, `darkgreen`, `slateblue`, `magenta`, `gold`, `navy`, + * `gray`, `saddlebrown`, `paleturquoise`, `mistyrose`, `indigo`: + * + * Wekan card colors + * * @param {string} boardId the board ID of the card * @param {string} list the list ID of the card * @param {string} cardId the ID of the card @@ -1562,6 +1587,8 @@ if (Meteor.isServer) { * @param {string} [spentTime] the new spentTime field of the card * @param {boolean} [isOverTime] the new isOverTime field of the card * @param {string} [customFields] the new customFields value of the card + * @param {string} [color] the new color of the card + * @return_type {_id: string} */ JsonRoutes.add('PUT', '/api/boards/:boardId/lists/:listId/cards/:cardId', function(req, res) { Authentication.checkUserId(req.userId); @@ -1616,6 +1643,11 @@ if (Meteor.isServer) { }, }); } + if (req.body.hasOwnProperty('color')) { + const newColor = req.body.color; + Cards.direct.update({_id: paramCardId, listId: paramListId, boardId: paramBoardId, archived: false}, + {$set: {color: newColor}}); + } if (req.body.hasOwnProperty('labelIds')) { let newlabelIds = req.body.labelIds; if (_.isString(newlabelIds)) { -- cgit v1.2.3-1-g7c22