mirror of
https://github.com/wekan/wekan.git
synced 2025-04-22 04:57:07 -04:00
Changing events in calendar updates the card
This commit is contained in:
parent
9cb8aab3ba
commit
db5ff4e1e2
1 changed files with 31 additions and 1 deletions
|
@ -156,6 +156,8 @@ BlazeComponent.extendComponent({
|
|||
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',
|
||||
|
@ -178,10 +180,11 @@ BlazeComponent.extendComponent({
|
|||
const events = [];
|
||||
currentBoard.cardsInInterval(start.toDate(), end.toDate()).forEach(function(card){
|
||||
events.push({
|
||||
id: card.id,
|
||||
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,
|
||||
|
@ -191,6 +194,33 @@ BlazeComponent.extendComponent({
|
|||
});
|
||||
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