summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2018-07-24 18:18:40 +0200
committerBenjamin Tissoires <benjamin.tissoires@redhat.com>2019-01-22 11:10:29 +0100
commitb0ac10d94a8200a1ad0199a82c3f9d9be7ac9882 (patch)
treedbcfd3209358fd31a8bd7aeb79a54733bfe514f2 /models
parentc87a8b86aed70593bf8a9628df830ca5f03d50d5 (diff)
downloadwekan-b0ac10d94a8200a1ad0199a82c3f9d9be7ac9882.tar.gz
wekan-b0ac10d94a8200a1ad0199a82c3f9d9be7ac9882.tar.bz2
wekan-b0ac10d94a8200a1ad0199a82c3f9d9be7ac9882.zip
Add the ability to change the card background
Currently the only way to set it is via the REST API
Diffstat (limited to 'models')
-rw-r--r--models/cards.js32
1 files changed, 32 insertions, 0 deletions
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`:
+ *
+ * <img src="/card-colors.png" width="40%" alt="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)) {