mirror of
https://github.com/wekan/wekan.git
synced 2025-09-22 01:50:48 +02: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 {
|
return {
|
||||||
id: 'calendar-view',
|
id: 'calendar-view',
|
||||||
defaultView: 'agendaDay',
|
defaultView: 'agendaDay',
|
||||||
|
editable: true,
|
||||||
|
timezone: 'local',
|
||||||
header: {
|
header: {
|
||||||
left: 'title today prev,next',
|
left: 'title today prev,next',
|
||||||
center: 'agendaDay,listDay,timelineDay agendaWeek,listWeek,timelineWeek month,timelineMonth timelineYear',
|
center: 'agendaDay,listDay,timelineDay agendaWeek,listWeek,timelineWeek month,timelineMonth timelineYear',
|
||||||
|
@ -178,10 +180,11 @@ BlazeComponent.extendComponent({
|
||||||
const events = [];
|
const events = [];
|
||||||
currentBoard.cardsInInterval(start.toDate(), end.toDate()).forEach(function(card){
|
currentBoard.cardsInInterval(start.toDate(), end.toDate()).forEach(function(card){
|
||||||
events.push({
|
events.push({
|
||||||
id: card.id,
|
id: card._id,
|
||||||
title: card.title,
|
title: card.title,
|
||||||
start: card.startAt,
|
start: card.startAt,
|
||||||
end: card.endAt,
|
end: card.endAt,
|
||||||
|
allDay: Math.abs(card.endAt.getTime() - card.startAt.getTime()) / 1000 === 24*3600,
|
||||||
url: FlowRouter.url('card', {
|
url: FlowRouter.url('card', {
|
||||||
boardId: currentBoard._id,
|
boardId: currentBoard._id,
|
||||||
slug: currentBoard.slug,
|
slug: currentBoard.slug,
|
||||||
|
@ -191,6 +194,33 @@ BlazeComponent.extendComponent({
|
||||||
});
|
});
|
||||||
callback(events);
|
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');
|
}).register('calendarView');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue