summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/boards.js27
-rw-r--r--models/cards.js19
-rw-r--r--models/lists.js2
-rw-r--r--models/swimlanes.js34
4 files changed, 76 insertions, 6 deletions
diff --git a/models/boards.js b/models/boards.js
index 99480ca7..b0f5cecb 100644
--- a/models/boards.js
+++ b/models/boards.js
@@ -347,10 +347,37 @@ Boards.helpers({
return Lists.find({ boardId: this._id, archived: false }, { sort: { sort: 1 } });
},
+ nullSortLists() {
+ return Lists.find({
+ boardId: this._id,
+ archived: false,
+ sort: { $eq: null },
+ });
+ },
+
swimlanes() {
return Swimlanes.find({ boardId: this._id, archived: false }, { sort: { sort: 1 } });
},
+ nextSwimlane(swimlane) {
+ return Swimlanes.findOne({
+ boardId: this._id,
+ archived: false,
+ sort: { $gte: swimlane.sort },
+ _id: { $ne: swimlane._id },
+ }, {
+ sort: { sort: 1 },
+ });
+ },
+
+ nullSortSwimlanes() {
+ return Swimlanes.find({
+ boardId: this._id,
+ archived: false,
+ sort: { $eq: null },
+ });
+ },
+
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 c5d9bf05..ff19a9a0 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -69,7 +69,7 @@ Cards.attachSchema(new SimpleSchema({
type: String,
optional: true,
allowedValues: [
- 'green', 'yellow', 'orange', 'red', 'purple',
+ 'white', 'green', 'yellow', 'orange', 'red', 'purple',
'blue', 'sky', 'lime', 'pink', 'black',
'silver', 'peachpuff', 'crimson', 'plum', 'darkgreen',
'slateblue', 'magenta', 'gold', 'navy', 'gray',
@@ -1526,6 +1526,10 @@ if (Meteor.isServer) {
Authentication.checkUserId(req.userId);
const paramBoardId = req.params.boardId;
const paramListId = req.params.listId;
+ const currentCards = Cards.find({
+ listId: paramListId,
+ archived: false,
+ }, { sort: ['sort'] });
const check = Users.findOne({
_id: req.body.authorId,
});
@@ -1538,7 +1542,7 @@ if (Meteor.isServer) {
description: req.body.description,
userId: req.body.authorId,
swimlaneId: req.body.swimlaneId,
- sort: 0,
+ sort: currentCards.count(),
members,
});
JsonRoutes.sendResult(res, {
@@ -1571,13 +1575,16 @@ if (Meteor.isServer) {
*
* @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`:
+ * The color has to be chosen between `white`, `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" />
*
+ * Note: setting the color to white has the same effect than removing it.
+ *
* @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
diff --git a/models/lists.js b/models/lists.js
index 0e1ba801..39ff130a 100644
--- a/models/lists.js
+++ b/models/lists.js
@@ -314,9 +314,11 @@ if (Meteor.isServer) {
try {
Authentication.checkUserId( req.userId);
const paramBoardId = req.params.boardId;
+ const board = Boards.findOne(paramBoardId);
const id = Lists.insert({
title: req.body.title,
boardId: paramBoardId,
+ sort: board.lists().count(),
});
JsonRoutes.sendResult(res, {
code: 200,
diff --git a/models/swimlanes.js b/models/swimlanes.js
index fa5245da..e2c3925c 100644
--- a/models/swimlanes.js
+++ b/models/swimlanes.js
@@ -49,6 +49,21 @@ Swimlanes.attachSchema(new SimpleSchema({
// XXX We should probably provide a default
optional: true,
},
+ color: {
+ /**
+ * the color of the swimlane
+ */
+ type: String,
+ optional: true,
+ // silver is the default, so it is left out
+ allowedValues: [
+ 'white', 'green', 'yellow', 'orange', 'red', 'purple',
+ 'blue', 'sky', 'lime', 'pink', 'black',
+ 'peachpuff', 'crimson', 'plum', 'darkgreen',
+ 'slateblue', 'magenta', 'gold', 'navy', 'gray',
+ 'saddlebrown', 'paleturquoise', 'mistyrose', 'indigo',
+ ],
+ },
updatedAt: {
/**
* when was the swimlane last edited
@@ -93,6 +108,12 @@ Swimlanes.helpers({
board() {
return Boards.findOne(this.boardId);
},
+
+ colorClass() {
+ if (this.color)
+ return this.color;
+ return '';
+ },
});
Swimlanes.mutations({
@@ -107,6 +128,17 @@ Swimlanes.mutations({
restore() {
return { $set: { archived: false } };
},
+
+ setColor(newColor) {
+ if (newColor === 'silver') {
+ newColor = null;
+ }
+ return {
+ $set: {
+ color: newColor,
+ },
+ };
+ },
});
Swimlanes.hookOptions.after.update = { fetchPrevious: false };
@@ -224,9 +256,11 @@ if (Meteor.isServer) {
try {
Authentication.checkUserId( req.userId);
const paramBoardId = req.params.boardId;
+ const board = Boards.findOne(paramBoardId);
const id = Swimlanes.insert({
title: req.body.title,
boardId: paramBoardId,
+ sort: board.swimlanes().count(),
});
JsonRoutes.sendResult(res, {
code: 200,