summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2019-01-25 10:47:36 +0100
committerBenjamin Tissoires <benjamin.tissoires@redhat.com>2019-01-25 11:04:56 +0100
commit5c6a725712a443b4d03b4f86262033ddfb66bc3d (patch)
treeb3b2d0e70df516900e626a7edb17d27cdee319a6 /client
parent03efeaeb1abae0c8c39ad5644d44bad36f415d99 (diff)
downloadwekan-5c6a725712a443b4d03b4f86262033ddfb66bc3d.tar.gz
wekan-5c6a725712a443b4d03b4f86262033ddfb66bc3d.tar.bz2
wekan-5c6a725712a443b4d03b4f86262033ddfb66bc3d.zip
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.
Diffstat (limited to 'client')
-rw-r--r--client/components/boards/boardBody.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/client/components/boards/boardBody.js b/client/components/boards/boardBody.js
index ccbd0f23..ae5b67fd 100644
--- a/client/components/boards/boardBody.js
+++ b/client/components/boards/boardBody.js
@@ -35,6 +35,37 @@ BlazeComponent.extendComponent({
this._isDragging = false;
// Used to set the overlay
this.mouseHasEnterCardDetails = false;
+
+ // fix swimlanes sort field if there are null values
+ const currentBoardData = Boards.findOne(Session.get('currentBoard'));
+ const nullSortSwimlanes = currentBoardData.nullSortSwimlanes();
+ if (nullSortSwimlanes.count() > 0) {
+ const swimlanes = currentBoardData.swimlanes();
+ let count = 0;
+ swimlanes.forEach((s) => {
+ Swimlanes.update(s._id, {
+ $set: {
+ sort: count,
+ },
+ });
+ count += 1;
+ });
+ }
+
+ // fix lists sort field if there are null values
+ const nullSortLists = currentBoardData.nullSortLists();
+ if (nullSortLists.count() > 0) {
+ const lists = currentBoardData.lists();
+ let count = 0;
+ lists.forEach((l) => {
+ Lists.update(l._id, {
+ $set: {
+ sort: count,
+ },
+ });
+ count += 1;
+ });
+ }
},
onRendered() {
const boardComponent = this;