summaryrefslogtreecommitdiff
path: root/assets/js/src/Board.js
diff options
context:
space:
mode:
authorGerardo Zamudio <gerardozamudio@users.noreply.github.com>2016-02-24 23:48:50 -0600
committerGerardo Zamudio <gerardozamudio@users.noreply.github.com>2016-02-24 23:48:50 -0600
commite4de6b3898b64b26d29aff31f21df5fda8055686 (patch)
tree575f8a65440f291d70a070d168eafca8c82a6459 /assets/js/src/Board.js
parentd9ffbea174ea6524d0a22f8375ca8b3aa04a3c96 (diff)
parenta6540bc604c837d92c9368540c145606723e97f7 (diff)
Merge pull request #1 from fguillot/master
Update from upstream
Diffstat (limited to 'assets/js/src/Board.js')
-rw-r--r--assets/js/src/Board.js74
1 files changed, 55 insertions, 19 deletions
diff --git a/assets/js/src/Board.js b/assets/js/src/Board.js
index b98aa366..c99f3cd3 100644
--- a/assets/js/src/Board.js
+++ b/assets/js/src/Board.js
@@ -1,18 +1,19 @@
function Board(app) {
this.app = app;
this.checkInterval = null;
+ this.savingInProgress = false;
}
Board.prototype.execute = function() {
this.app.swimlane.refresh();
this.restoreColumnViewMode();
this.compactView();
- this.columnScrolling();
this.poll();
this.keyboardShortcuts();
this.listen();
this.dragAndDrop();
+ $(window).on("load", this.columnScrolling);
$(window).resize(this.columnScrolling);
};
@@ -42,8 +43,7 @@ Board.prototype.reloadFilters = function(search) {
};
Board.prototype.check = function() {
- if (this.app.isVisible()) {
-
+ if (this.app.isVisible() && ! this.savingInProgress) {
var self = this;
this.app.showLoadingIcon();
@@ -59,7 +59,9 @@ Board.prototype.check = function() {
};
Board.prototype.save = function(taskId, columnId, position, swimlaneId) {
+ var self = this;
this.app.showLoadingIcon();
+ this.savingInProgress = true;
$.ajax({
cache: false,
@@ -73,8 +75,14 @@ Board.prototype.save = function(taskId, columnId, position, swimlaneId) {
"swimlane_id": swimlaneId,
"position": position
}),
- success: this.refresh.bind(this),
- error: this.app.hideLoadingIcon.bind(this)
+ success: function(data) {
+ self.refresh(data);
+ this.savingInProgress = false;
+ },
+ error: function() {
+ self.app.hideLoadingIcon();
+ this.savingInProgress = false;
+ }
});
};
@@ -83,12 +91,12 @@ Board.prototype.refresh = function(data) {
this.app.refresh();
this.app.swimlane.refresh();
- this.columnScrolling();
this.app.hideLoadingIcon();
this.listen();
this.dragAndDrop();
this.compactView();
this.restoreColumnViewMode();
+ this.columnScrolling();
};
Board.prototype.dragAndDrop = function() {
@@ -100,13 +108,22 @@ Board.prototype.dragAndDrop = function() {
placeholder: "draggable-placeholder",
items: ".draggable-item",
stop: function(event, ui) {
- ui.item.removeClass("draggable-item-selected");
- self.save(
- ui.item.attr('data-task-id'),
- ui.item.parent().attr("data-column-id"),
- ui.item.index() + 1,
- ui.item.parent().attr('data-swimlane-id')
- );
+ var task = ui.item;
+ var taskId = task.attr('data-task-id');
+ var taskPosition = task.attr('data-position');
+ var taskColumnId = task.attr('data-column-id');
+ var taskSwimlaneId = task.attr('data-swimlane-id');
+
+ var newColumnId = task.parent().attr("data-column-id");
+ var newSwimlaneId = task.parent().attr('data-swimlane-id');
+ var newPosition = task.index() + 1;
+
+ task.removeClass("draggable-item-selected");
+
+ if (newColumnId != taskColumnId || newSwimlaneId != taskSwimlaneId || newPosition != taskPosition) {
+ self.changeTaskState(taskId);
+ self.save(taskId, newColumnId, newPosition, newSwimlaneId);
+ }
},
start: function(event, ui) {
ui.item.addClass("draggable-item-selected");
@@ -122,6 +139,12 @@ Board.prototype.dragAndDrop = function() {
$(".board-task-list").sortable(params);
};
+Board.prototype.changeTaskState = function(taskId) {
+ var task = $("div[data-task-id=" + taskId + "]");
+ task.addClass('task-board-saving-state');
+ task.find('.task-board-saving-icon').show();
+};
+
Board.prototype.listen = function() {
var self = this;
@@ -141,27 +164,40 @@ Board.prototype.listen = function() {
self.toggleColumnScrolling();
});
- $(document).on("click", ".board-column-title", function() {
+ $(document).on("click", ".board-toggle-column-view", function() {
self.toggleColumnViewMode($(this).data("column-id"));
});
};
Board.prototype.toggleColumnScrolling = function() {
- var scrolling = localStorage.getItem("column_scroll") || 1;
+ var scrolling = localStorage.getItem("column_scroll");
+
+ if (scrolling == undefined) {
+ scrolling = 1;
+ }
+
localStorage.setItem("column_scroll", scrolling == 0 ? 1 : 0);
this.columnScrolling();
};
Board.prototype.columnScrolling = function() {
if (localStorage.getItem("column_scroll") == 0) {
+ var height = 80;
+
$(".filter-max-height").show();
$(".filter-min-height").hide();
+ $(".board-rotation-wrapper").css("min-height", '');
$(".board-task-list").each(function() {
- $(this).css("min-height", 80);
- $(this).css("height", '');
- $(".board-rotation-wrapper").css("min-height", '');
+ var columnHeight = $(this).height();
+
+ if (columnHeight > height) {
+ height = columnHeight;
+ }
});
+
+ $(".board-task-list").css("min-height", height);
+ $(".board-task-list").css("height", '');
}
else {
@@ -180,7 +216,7 @@ Board.prototype.columnScrolling = function() {
});
}
else {
- var height = $(window).height() - 145;
+ var height = $(window).height() - 170;
$(".board-task-list").css("height", height);
$(".board-rotation-wrapper").css("min-height", height);