Refactoring to implement new layout with filters: board/calendar/list views (work in progress)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
|
||||
Kanboard.Analytic = (function() {
|
||||
(function() {
|
||||
|
||||
// CFD diagram
|
||||
function drawCfd()
|
||||
@@ -185,6 +184,4 @@ Kanboard.Analytic = (function() {
|
||||
}
|
||||
});
|
||||
|
||||
return {};
|
||||
|
||||
})();
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// Common functions
|
||||
var Kanboard = (function() {
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -1,150 +1,50 @@
|
||||
Kanboard.Calendar = (function() {
|
||||
|
||||
var filter_storage_key = "";
|
||||
|
||||
// Save the new due date for a moved task
|
||||
function move_calendar_event(calendar_event)
|
||||
{
|
||||
var url = $("#calendar").data("save-url") || $("#user-calendar").data("save-url");
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
url: url,
|
||||
contentType: "application/json",
|
||||
type: "POST",
|
||||
processData: false,
|
||||
data: JSON.stringify({
|
||||
"task_id": calendar_event.id,
|
||||
"date_due": calendar_event.start.format()
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// Show the user calendar
|
||||
function show_user_calendar()
|
||||
{
|
||||
var calendar = $("#user-calendar");
|
||||
|
||||
calendar.fullCalendar({
|
||||
lang: $("body").data("js-lang"),
|
||||
editable: true,
|
||||
eventLimit: true,
|
||||
defaultView: "month",
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,agendaDay'
|
||||
},
|
||||
viewRender: refresh_user_calendar,
|
||||
eventDrop: move_calendar_event
|
||||
});
|
||||
}
|
||||
|
||||
// Refresh the calendar events
|
||||
function refresh_user_calendar()
|
||||
{
|
||||
var calendar = $("#user-calendar");
|
||||
var url = calendar.data("check-url");
|
||||
var params = {
|
||||
"start": calendar.fullCalendar('getView').start.format(),
|
||||
"end": calendar.fullCalendar('getView').end.format(),
|
||||
"user_id": calendar.data("user-id")
|
||||
};
|
||||
|
||||
for (var key in params) {
|
||||
url += "&" + key + "=" + params[key];
|
||||
}
|
||||
|
||||
$.getJSON(url, function(events) {
|
||||
calendar.fullCalendar('removeEvents');
|
||||
calendar.fullCalendar('addEventSource', events);
|
||||
calendar.fullCalendar('rerenderEvents');
|
||||
});
|
||||
}
|
||||
|
||||
// Show the project calendar
|
||||
function show_project_calendar()
|
||||
{
|
||||
var calendar = $("#calendar");
|
||||
|
||||
calendar.fullCalendar({
|
||||
lang: $("body").data("js-lang"),
|
||||
editable: true,
|
||||
eventLimit: true,
|
||||
defaultView: "month",
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,agendaDay'
|
||||
},
|
||||
viewRender: load_project_filters,
|
||||
eventDrop: move_calendar_event
|
||||
});
|
||||
}
|
||||
|
||||
// Refresh the calendar events
|
||||
function refresh_project_calendar(filters)
|
||||
{
|
||||
var calendar = $("#calendar");
|
||||
var url = calendar.data("check-url");
|
||||
var params = {
|
||||
"start": calendar.fullCalendar('getView').start.format(),
|
||||
"end": calendar.fullCalendar('getView').end.format()
|
||||
};
|
||||
|
||||
jQuery.extend(params, filters);
|
||||
|
||||
for (var key in params) {
|
||||
url += "&" + key + "=" + params[key];
|
||||
}
|
||||
|
||||
$.getJSON(url, function(events) {
|
||||
calendar.fullCalendar('removeEvents');
|
||||
calendar.fullCalendar('addEventSource', events);
|
||||
calendar.fullCalendar('rerenderEvents');
|
||||
});
|
||||
}
|
||||
|
||||
// Restore saved filters
|
||||
function load_project_filters()
|
||||
{
|
||||
var filters = Kanboard.GetStorageItem(filter_storage_key);
|
||||
|
||||
if (filters !== "") {
|
||||
filters = JSON.parse(filters);
|
||||
|
||||
for (var filter in filters) {
|
||||
$("select[name=" + filter + "]").val(filters[filter]);
|
||||
}
|
||||
}
|
||||
|
||||
refresh_project_calendar(filters || {});
|
||||
|
||||
$('.calendar-filter').change(apply_project_filters);
|
||||
}
|
||||
|
||||
// Apply filters on change
|
||||
function apply_project_filters()
|
||||
{
|
||||
var filters = {};
|
||||
|
||||
$('.calendar-filter').each(function() {
|
||||
filters[$(this).attr("name")] = $(this).val();
|
||||
});
|
||||
|
||||
Kanboard.SetStorageItem(filter_storage_key, JSON.stringify(filters));
|
||||
refresh_project_calendar(filters);
|
||||
}
|
||||
(function() {
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
|
||||
if (Kanboard.Exists("calendar")) {
|
||||
filter_storage_key = "calendar_filters_" + $("#calendar").data("project-id");
|
||||
show_project_calendar();
|
||||
load_project_filters();
|
||||
}
|
||||
else if (Kanboard.Exists("user-calendar")) {
|
||||
show_user_calendar();
|
||||
var calendar = $('#calendar');
|
||||
|
||||
calendar.fullCalendar({
|
||||
lang: $("body").data("js-lang"),
|
||||
editable: true,
|
||||
eventLimit: true,
|
||||
defaultView: "month",
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,agendaDay'
|
||||
},
|
||||
eventDrop: function(event) {
|
||||
$.ajax({
|
||||
cache: false,
|
||||
url: calendar.data("save-url"),
|
||||
contentType: "application/json",
|
||||
type: "POST",
|
||||
processData: false,
|
||||
data: JSON.stringify({
|
||||
"task_id": event.id,
|
||||
"date_due": event.start.format()
|
||||
})
|
||||
});
|
||||
},
|
||||
viewRender: function() {
|
||||
var url = calendar.data("check-url");
|
||||
var params = {
|
||||
"start": calendar.fullCalendar('getView').start.format(),
|
||||
"end": calendar.fullCalendar('getView').end.format()
|
||||
};
|
||||
|
||||
for (var key in params) {
|
||||
url += "&" + key + "=" + params[key];
|
||||
}
|
||||
|
||||
$.getJSON(url, function(events) {
|
||||
calendar.fullCalendar('removeEvents');
|
||||
calendar.fullCalendar('addEventSource', events);
|
||||
calendar.fullCalendar('rerenderEvents');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Kanboard.Swimlane = (function() {
|
||||
(function() {
|
||||
|
||||
// Expand a Swimlane via display attributes
|
||||
function expand(swimlaneId)
|
||||
|
||||
Reference in New Issue
Block a user