summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/boards.js27
-rw-r--r--models/cards.js6
-rw-r--r--models/lists.js34
-rw-r--r--models/swimlanes.js34
4 files changed, 100 insertions, 1 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 9b32e89a..ff19a9a0 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -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, {
diff --git a/models/lists.js b/models/lists.js
index 0e1ba801..54e7d037 100644
--- a/models/lists.js
+++ b/models/lists.js
@@ -92,6 +92,21 @@ Lists.attachSchema(new SimpleSchema({
type: Boolean,
defaultValue: false,
},
+ color: {
+ /**
+ * the color of the list
+ */
+ 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',
+ ],
+ },
}));
Lists.allow({
@@ -148,6 +163,12 @@ Lists.helpers({
return list.wipLimit[option] ? list.wipLimit[option] : 0; // Necessary check to avoid exceptions for the case where the doc doesn't have the wipLimit field yet set
}
},
+
+ colorClass() {
+ if (this.color)
+ return this.color;
+ return '';
+ },
});
Lists.mutations({
@@ -174,6 +195,17 @@ Lists.mutations({
setWipLimit(limit) {
return { $set: { 'wipLimit.value': limit } };
},
+
+ setColor(newColor) {
+ if (newColor === 'silver') {
+ newColor = null;
+ }
+ return {
+ $set: {
+ color: newColor,
+ },
+ };
+ },
});
Meteor.methods({
@@ -314,9 +346,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,