From c075187088e69d30db31489d75b22f991e1972ff Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Thu, 24 Jan 2019 20:45:52 +0100 Subject: swimlane: insert the new swimlane after the one we clicked on --- models/boards.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'models') diff --git a/models/boards.js b/models/boards.js index 99480ca7..d92bec47 100644 --- a/models/boards.js +++ b/models/boards.js @@ -351,6 +351,17 @@ Boards.helpers({ 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 }, + }); + }, + hasOvertimeCards(){ const card = Cards.findOne({isOvertime: true, boardId: this._id, archived: false} ); return card !== undefined; -- cgit v1.2.3-1-g7c22 From 03efeaeb1abae0c8c39ad5644d44bad36f415d99 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Thu, 24 Jan 2019 16:47:09 +0100 Subject: Add colors to swimlanes fixes #1688 --- models/swimlanes.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'models') diff --git a/models/swimlanes.js b/models/swimlanes.js index fa5245da..93057362 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 }; -- cgit v1.2.3-1-g7c22 From 5c6a725712a443b4d03b4f86262033ddfb66bc3d Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Fri, 25 Jan 2019 10:47:36 +0100 Subject: Make sure Swimlanes and Lists have a populated sort field When moving around the swimlanes or the lists, if one element has a sort with a null value, the computation of the new sort value is aborted, meaning that there are glitches in the UI. This happens on the first swimlane created with the new board, or when a swimlane or a list gets added through the API. --- models/boards.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'models') diff --git a/models/boards.js b/models/boards.js index d92bec47..b0f5cecb 100644 --- a/models/boards.js +++ b/models/boards.js @@ -347,6 +347,14 @@ 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 } }); }, @@ -362,6 +370,14 @@ Boards.helpers({ }); }, + 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; -- cgit v1.2.3-1-g7c22 From b5411841cf6aa33b2c0d29d85cbc795e3faa7f4f Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Fri, 25 Jan 2019 10:57:46 +0100 Subject: api: fix the sort field when inserting a swimlane or a list This has the side effect of always inserting the element at the end. --- models/lists.js | 2 ++ models/swimlanes.js | 2 ++ 2 files changed, 4 insertions(+) (limited to 'models') 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 93057362..e2c3925c 100644 --- a/models/swimlanes.js +++ b/models/swimlanes.js @@ -256,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, -- cgit v1.2.3-1-g7c22 From 6c3dbc3c6f52a42ddbeeaec9bbfcc82c1c839f7d Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Fri, 25 Jan 2019 12:44:27 +0100 Subject: api: new_card: add the card at the end of the list If we keep the `0` value, the card might be inserted in the middle of the list, making it hard to find it later on. Always append the card at the end of the list by setting a sort value based on the number of cards in the list. --- models/cards.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'models') 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, { -- cgit v1.2.3-1-g7c22 From d0a9d8c581f9356f5e72ccb698fc3963c59e96cd Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Fri, 25 Jan 2019 15:56:40 +0100 Subject: colors: add per list color Hamburger menu only. Note that I am definitively not responsible for the resulting Christmas tree. fixes #328 --- models/lists.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'models') diff --git a/models/lists.js b/models/lists.js index 39ff130a..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({ -- cgit v1.2.3-1-g7c22