Refactoring to implement new layout with filters: board/calendar/list views (work in progress)

This commit is contained in:
Frederic Guillot
2015-07-04 11:14:21 -04:00
parent a327f790ee
commit 554500aa49
52 changed files with 463 additions and 758 deletions

View File

@@ -1,4 +1,4 @@
Kanboard.Board = (function() {
(function() {
var checkInterval = null;
@@ -243,7 +243,6 @@ Kanboard.Board = (function() {
$("#main").append(data);
Kanboard.InitAfterAjax();
board_load_events();
filter_apply();
stack_show();
compactview_reload();
}
@@ -264,7 +263,6 @@ Kanboard.Board = (function() {
Kanboard.InitAfterAjax();
board_unload_events();
board_load_events();
filter_apply();
stack_show();
compactview_reload();
}
@@ -273,93 +271,6 @@ Kanboard.Board = (function() {
}
}
// Apply user or date filter (change tasks opacity)
function filter_apply()
{
var selectedUserId = $("#form-user_id").val();
var selectedCategoryId = $("#form-category_id").val();
var filterDueDate = $("#more-filters option[value=filter-due-date]").is(":selected")
var filterRecent = $("#more-filters option[value=filter-recent]").is(":selected")
var projectId = $('#board').data('project-id');
$("[data-task-id]").each(function(index, item) {
var ownerId = item.getAttribute("data-owner-id");
var dueDate = item.getAttribute("data-due-date");
var categoryId = item.getAttribute("data-category-id");
var recent = $(item).hasClass("task-board-recent");
if (ownerId != selectedUserId && selectedUserId != -1) {
item.style.display = "none";
}
else {
item.style.display = "block";
}
if (filterDueDate && (dueDate == "" || dueDate == "0")) {
item.style.display = "none";
}
if (categoryId != selectedCategoryId && selectedCategoryId != -1) {
item.style.display = "none";
}
if (filterRecent && ! recent) {
item.style.display = "none";
}
});
// Save filter settings
Kanboard.SetStorageItem("board_filter_" + projectId + "_form-user_id", selectedUserId);
Kanboard.SetStorageItem("board_filter_" + projectId + "_form-category_id", selectedCategoryId);
Kanboard.SetStorageItem("board_filter_" + projectId + "_filter-due-date", ~~(filterDueDate));
Kanboard.SetStorageItem("board_filter_" + projectId + "_filter-recent", ~~(filterRecent));
}
// Load filter events
function filter_load_events()
{
var projectId = $('#board').data('project-id');
$("#form-user_id").chosen({
width: "180px",
no_results_text: $("#form-user_id").data("notfound")
});
$("#form-category_id").chosen({
width: "200px",
no_results_text: $("#form-category_id").data("notfound")
});
$("#more-filters").chosen({
width: "30%",
no_results_text: $("#more-filters").data("notfound")
});
$(".apply-filters").change(function(e) {
filter_apply();
});
// Get and set filters from localStorage
$("#form-user_id").val(Kanboard.GetStorageItem("board_filter_" + projectId + "_form-user_id") || -1);
$("#form-user_id").trigger("chosen:updated");
$("#form-category_id").val(Kanboard.GetStorageItem("board_filter_" + projectId + "_form-category_id") || -1);
$("#form-category_id").trigger("chosen:updated");
if (+Kanboard.GetStorageItem("board_filter_" + projectId + "_filter-due-date")) {
$("#more-filters option[value=filter-due-date]").attr("selected", true);
}
if (+Kanboard.GetStorageItem("board_filter_" + projectId + "_filter-recent")) {
$("#more-filters option[value=filter-recent]").attr("selected", true);
}
$("#more-filters").trigger("chosen:updated");
filter_apply();
}
function compactview_load_events()
{
jQuery(document).on('click', ".filter-toggle-scrolling", function(e) {
@@ -401,7 +312,6 @@ Kanboard.Board = (function() {
if (Kanboard.Exists("board")) {
board_load_events();
filter_load_events();
stack_load_events();
compactview_load_events();
keyboard_shortcuts();