Merge pull-request #487 (Store filters in localStorage)

This commit is contained in:
Frederic Guillot 2015-01-05 21:36:19 -05:00
commit 23b84cf121
1 changed files with 24 additions and 0 deletions

View File

@ -213,6 +213,14 @@ Kanboard.Board = (function() {
item.style.opacity = "0.2";
}
});
//Save filter settings for active project to localStorage
if (typeof(Storage) !== "undefined") {
var projectId = $('#board').data('project-id');
localStorage.setItem(projectId + "_form-user_id", selectedUserId);
localStorage.setItem(projectId + "_form-category_id", selectedCategoryId);
localStorage.setItem(projectId + "_filter-due-date", ~~(filterDueDate));
}
}
// Load filter events
@ -227,6 +235,22 @@ Kanboard.Board = (function() {
filter_apply();
e.preventDefault();
});
// Get and set filters from localStorage for active project
if (typeof(Storage) !== "undefined") {
var projectId = $('#board').data('project-id');
$("#form-user_id").val(localStorage.getItem(projectId + "_form-user_id") || -1);
$("#form-category_id").val(localStorage.getItem(projectId + "_form-category_id") || -1);
if (+localStorage.getItem(projectId + "_filter-due-date")) {
$("#filter-due-date").addClass("filter-on");
} else {
$("#filter-due-date").removeClass("filter-on");
}
// apply filters on load
filter_apply();
}
}
return {