diff options
author | Nicu Tofan <nicu.tofan@gmail.com> | 2018-06-28 00:13:35 +0300 |
---|---|---|
committer | Nicu Tofan <nicu.tofan@gmail.com> | 2018-06-28 00:13:35 +0300 |
commit | db5ff4e1e2640b7312533cb276b545c4b9920110 (patch) | |
tree | d4ec292dfd352dd92dbf8110f9373360ddc0951e /client/components/boards/boardBody.js | |
parent | 9cb8aab3ba8554ae85141ac5e7e199867949bef2 (diff) | |
download | wekan-db5ff4e1e2640b7312533cb276b545c4b9920110.tar.gz wekan-db5ff4e1e2640b7312533cb276b545c4b9920110.tar.bz2 wekan-db5ff4e1e2640b7312533cb276b545c4b9920110.zip |
Changing events in calendar updates the card
Diffstat (limited to 'client/components/boards/boardBody.js')
-rw-r--r-- | client/components/boards/boardBody.js | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/client/components/boards/boardBody.js b/client/components/boards/boardBody.js index dc6b9bef..68ac8b27 100644 --- a/client/components/boards/boardBody.js +++ b/client/components/boards/boardBody.js @@ -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'); |