Add user calendar view on the dashboard and in the user management section
This commit is contained in:
@@ -2,26 +2,6 @@ Kanboard.Calendar = (function() {
|
||||
|
||||
var filter_storage_key = "";
|
||||
|
||||
// Show the empty calendar
|
||||
function show_calendar()
|
||||
{
|
||||
var calendar = $("#calendar");
|
||||
var translations = calendar.data("translations");
|
||||
|
||||
calendar.fullCalendar({
|
||||
lang: $("body").data("js-lang"),
|
||||
editable: true,
|
||||
eventLimit: true,
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,agendaDay'
|
||||
},
|
||||
viewRender: load_filters,
|
||||
eventDrop: move_calendar_event
|
||||
});
|
||||
}
|
||||
|
||||
// Save the new due date for a moved task
|
||||
function move_calendar_event(calendar_event)
|
||||
{
|
||||
@@ -38,8 +18,70 @@ Kanboard.Calendar = (function() {
|
||||
});
|
||||
}
|
||||
|
||||
// Show the user calendar
|
||||
function show_user_calendar()
|
||||
{
|
||||
var calendar = $("#user-calendar");
|
||||
var translations = calendar.data("translations");
|
||||
|
||||
calendar.fullCalendar({
|
||||
lang: $("body").data("js-lang"),
|
||||
editable: false,
|
||||
eventLimit: true,
|
||||
defaultView: "agendaWeek",
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,agendaDay'
|
||||
},
|
||||
viewRender: refresh_user_calendar
|
||||
});
|
||||
}
|
||||
|
||||
// Refresh the calendar events
|
||||
function refresh_calendar(filters)
|
||||
function refresh_user_calendar(filters)
|
||||
{
|
||||
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");
|
||||
var translations = calendar.data("translations");
|
||||
|
||||
calendar.fullCalendar({
|
||||
lang: $("body").data("js-lang"),
|
||||
editable: true,
|
||||
eventLimit: true,
|
||||
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");
|
||||
@@ -62,7 +104,7 @@ Kanboard.Calendar = (function() {
|
||||
}
|
||||
|
||||
// Restore saved filters
|
||||
function load_filters()
|
||||
function load_project_filters()
|
||||
{
|
||||
var filters = Kanboard.GetStorageItem(filter_storage_key);
|
||||
|
||||
@@ -74,13 +116,13 @@ Kanboard.Calendar = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
refresh_calendar(filters || {});
|
||||
refresh_project_calendar(filters || {});
|
||||
|
||||
$('.calendar-filter').change(apply_filters);
|
||||
$('.calendar-filter').change(apply_project_filters);
|
||||
}
|
||||
|
||||
// Apply filters on change
|
||||
function apply_filters()
|
||||
function apply_project_filters()
|
||||
{
|
||||
var filters = {};
|
||||
|
||||
@@ -89,15 +131,18 @@ Kanboard.Calendar = (function() {
|
||||
});
|
||||
|
||||
Kanboard.SetStorageItem(filter_storage_key, JSON.stringify(filters));
|
||||
refresh_calendar(filters);
|
||||
refresh_project_calendar(filters);
|
||||
}
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
|
||||
if (Kanboard.Exists("calendar")) {
|
||||
filter_storage_key = "calendar_filters_" + $("#calendar").data("project-id");
|
||||
show_calendar();
|
||||
load_filters();
|
||||
show_project_calendar();
|
||||
load_project_filters();
|
||||
}
|
||||
else if (Kanboard.Exists("user-calendar")) {
|
||||
show_user_calendar();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user