mirror of
https://github.com/wekan/wekan.git
synced 2025-12-17 16:00:13 +01:00
Merge branch 'calendar' of https://github.com/TNick/wekan into TNick-calendar
This commit is contained in:
commit
a02c51cc3b
2 changed files with 86 additions and 58 deletions
|
|
@ -26,4 +26,10 @@ template(name="boardBody")
|
||||||
if isViewLists
|
if isViewLists
|
||||||
+listsGroup
|
+listsGroup
|
||||||
if isViewCalendar
|
if isViewCalendar
|
||||||
+fullcalendar(calendarOptions)
|
+calendarView
|
||||||
|
|
||||||
|
template(name="calendarView")
|
||||||
|
.calendar-view.swimlane
|
||||||
|
if currentCard
|
||||||
|
+cardDetails(currentCard)
|
||||||
|
+fullcalendar(calendarOptions)
|
||||||
|
|
|
||||||
|
|
@ -113,63 +113,6 @@ BlazeComponent.extendComponent({
|
||||||
.childComponents('addListForm')[0].open();
|
.childComponents('addListForm')[0].open();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
calendarOptions() {
|
|
||||||
return {
|
|
||||||
id: 'calendar-view',
|
|
||||||
defaultView: 'basicWeek',
|
|
||||||
header: {
|
|
||||||
left: 'title',
|
|
||||||
center: 'agendaDay,listDay,timelineDay agendaWeek,listWeek,timelineWeek month,timelineMonth timelineYear',
|
|
||||||
right: 'today prev,next',
|
|
||||||
},
|
|
||||||
views: {
|
|
||||||
basic: {
|
|
||||||
// options apply to basicWeek and basicDay views
|
|
||||||
},
|
|
||||||
agenda: {
|
|
||||||
// options apply to agendaWeek and agendaDay views
|
|
||||||
},
|
|
||||||
week: {
|
|
||||||
// options apply to basicWeek and agendaWeek views
|
|
||||||
},
|
|
||||||
day: {
|
|
||||||
// options apply to basicDay and agendaDay views
|
|
||||||
},
|
|
||||||
},
|
|
||||||
themeSystem: 'jquery-ui',
|
|
||||||
height: 'parent',
|
|
||||||
/* TODO: lists as resources: https://fullcalendar.io/docs/vertical-resource-view */
|
|
||||||
navLinks: true,
|
|
||||||
nowIndicator: true,
|
|
||||||
businessHours: {
|
|
||||||
// days of week. an array of zero-based day of week integers (0=Sunday)
|
|
||||||
dow: [ 1, 2, 3, 4, 5 ], // Monday - Thursday
|
|
||||||
start: '8:00',
|
|
||||||
end: '18:00',
|
|
||||||
},
|
|
||||||
locale: TAPi18n.getLanguage(),
|
|
||||||
events(start, end, timezone, callback) {
|
|
||||||
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
|
||||||
const events = [];
|
|
||||||
currentBoard.cardsInInterval(start.toDate(), end.toDate()).forEach(function(card){
|
|
||||||
events.push({
|
|
||||||
id: card.id,
|
|
||||||
title: card.title,
|
|
||||||
start: card.startAt,
|
|
||||||
end: card.endAt,
|
|
||||||
url: FlowRouter.url('card', {
|
|
||||||
boardId: currentBoard._id,
|
|
||||||
slug: currentBoard.slug,
|
|
||||||
cardId: card._id,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
callback(events);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
events() {
|
events() {
|
||||||
return [{
|
return [{
|
||||||
// XXX The board-overlay div should probably be moved to the parent
|
// XXX The board-overlay div should probably be moved to the parent
|
||||||
|
|
@ -202,3 +145,82 @@ BlazeComponent.extendComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
}).register('boardBody');
|
}).register('boardBody');
|
||||||
|
|
||||||
|
BlazeComponent.extendComponent({
|
||||||
|
onRendered() {
|
||||||
|
this.autorun(function(){
|
||||||
|
$('#calendar-view').fullCalendar('refetchEvents');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
calendarOptions() {
|
||||||
|
return {
|
||||||
|
id: 'calendar-view',
|
||||||
|
defaultView: 'agendaDay',
|
||||||
|
editable: true,
|
||||||
|
timezone: 'local',
|
||||||
|
header: {
|
||||||
|
left: 'title today prev,next',
|
||||||
|
center: 'agendaDay,listDay,timelineDay agendaWeek,listWeek,timelineWeek month,timelineMonth timelineYear',
|
||||||
|
right: '',
|
||||||
|
},
|
||||||
|
// height: 'parent', nope, doesn't work as the parent might be small
|
||||||
|
height: 'auto',
|
||||||
|
/* TODO: lists as resources: https://fullcalendar.io/docs/vertical-resource-view */
|
||||||
|
navLinks: true,
|
||||||
|
nowIndicator: true,
|
||||||
|
businessHours: {
|
||||||
|
// days of week. an array of zero-based day of week integers (0=Sunday)
|
||||||
|
dow: [ 1, 2, 3, 4, 5 ], // Monday - Friday
|
||||||
|
start: '8:00',
|
||||||
|
end: '18:00',
|
||||||
|
},
|
||||||
|
locale: TAPi18n.getLanguage(),
|
||||||
|
events(start, end, timezone, callback) {
|
||||||
|
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
||||||
|
const events = [];
|
||||||
|
currentBoard.cardsInInterval(start.toDate(), end.toDate()).forEach(function(card){
|
||||||
|
events.push({
|
||||||
|
id: card._id,
|
||||||
|
title: card.title,
|
||||||
|
start: card.startAt,
|
||||||
|
end: card.endAt,
|
||||||
|
allDay: Math.abs(card.endAt.getTime() - card.startAt.getTime()) / 1000 === 24*3600,
|
||||||
|
url: FlowRouter.url('card', {
|
||||||
|
boardId: currentBoard._id,
|
||||||
|
slug: currentBoard.slug,
|
||||||
|
cardId: card._id,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
callback(events);
|
||||||
|
},
|
||||||
|
eventResize(event, delta, revertFunc) {
|
||||||
|
let isOk = false;
|
||||||
|
const card = Cards.findOne(event.id);
|
||||||
|
|
||||||
|
if (card) {
|
||||||
|
card.setEnd(event.end.toDate());
|
||||||
|
isOk = true;
|
||||||
|
}
|
||||||
|
if (!isOk) {
|
||||||
|
revertFunc();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
eventDrop(event, delta, revertFunc) {
|
||||||
|
let isOk = false;
|
||||||
|
const card = Cards.findOne(event.id);
|
||||||
|
if (card) {
|
||||||
|
// TODO: add a flag for allDay events
|
||||||
|
if (!event.allDay) {
|
||||||
|
card.setStart(event.start.toDate());
|
||||||
|
card.setEnd(event.end.toDate());
|
||||||
|
isOk = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isOk) {
|
||||||
|
revertFunc();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
}).register('calendarView');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue