From 3c4549fe64c8b57f1f9e2eb700889aa1488ad056 Mon Sep 17 00:00:00 2001 From: Nicu Tofan Date: Wed, 27 Jun 2018 22:23:28 +0300 Subject: Can show card on top of calendar --- client/components/boards/boardBody.jade | 8 ++++- client/components/boards/boardBody.js | 63 ++++----------------------------- 2 files changed, 13 insertions(+), 58 deletions(-) (limited to 'client/components') diff --git a/client/components/boards/boardBody.jade b/client/components/boards/boardBody.jade index b480bc0f..0a454e92 100644 --- a/client/components/boards/boardBody.jade +++ b/client/components/boards/boardBody.jade @@ -26,4 +26,10 @@ template(name="boardBody") if isViewLists +listsGroup if isViewCalendar - +fullcalendar(calendarOptions) + +calendarView + +template(name="calendarView") + .swimlane.list-group.js-lists + if currentCard + +cardDetails(currentCard) + +fullcalendar diff --git a/client/components/boards/boardBody.js b/client/components/boards/boardBody.js index 935c550f..911b0120 100644 --- a/client/components/boards/boardBody.js +++ b/client/components/boards/boardBody.js @@ -113,63 +113,6 @@ BlazeComponent.extendComponent({ .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() { return [{ // XXX The board-overlay div should probably be moved to the parent @@ -202,3 +145,9 @@ BlazeComponent.extendComponent({ }, }).register('boardBody'); + +BlazeComponent.extendComponent({ + onRendered() { + + }, +}).register('calendarView'); -- cgit v1.2.3-1-g7c22 From 374e9865792dd8219d1d7d10fcc23f98ed7c5817 Mon Sep 17 00:00:00 2001 From: Nicu Tofan Date: Wed, 27 Jun 2018 22:37:32 +0300 Subject: Can show card on event click --- client/components/boards/boardBody.jade | 4 ++-- client/components/boards/boardBody.js | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'client/components') diff --git a/client/components/boards/boardBody.jade b/client/components/boards/boardBody.jade index 0a454e92..9e4b9c61 100644 --- a/client/components/boards/boardBody.jade +++ b/client/components/boards/boardBody.jade @@ -29,7 +29,7 @@ template(name="boardBody") +calendarView template(name="calendarView") - .swimlane.list-group.js-lists + .calendar-view.swimlane if currentCard +cardDetails(currentCard) - +fullcalendar + +fullcalendar(calendarOptions) diff --git a/client/components/boards/boardBody.js b/client/components/boards/boardBody.js index 911b0120..1308c280 100644 --- a/client/components/boards/boardBody.js +++ b/client/components/boards/boardBody.js @@ -150,4 +150,28 @@ BlazeComponent.extendComponent({ onRendered() { }, + calendarOptions() { + return { + id: 'calendar-view', + defaultView: 'basicWeek', + 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); + }, + }; + }, }).register('calendarView'); -- cgit v1.2.3-1-g7c22 From 9cb8aab3ba8554ae85141ac5e7e199867949bef2 Mon Sep 17 00:00:00 2001 From: Nicu Tofan Date: Wed, 27 Jun 2018 23:00:14 +0300 Subject: Reactive change when a date is modified. --- client/components/boards/boardBody.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'client/components') diff --git a/client/components/boards/boardBody.js b/client/components/boards/boardBody.js index 1308c280..dc6b9bef 100644 --- a/client/components/boards/boardBody.js +++ b/client/components/boards/boardBody.js @@ -148,12 +148,31 @@ BlazeComponent.extendComponent({ BlazeComponent.extendComponent({ onRendered() { - + this.autorun(function(){ + $('#calendar-view').fullCalendar('refetchEvents'); + }); }, calendarOptions() { return { id: 'calendar-view', - defaultView: 'basicWeek', + defaultView: 'agendaDay', + 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 = []; -- cgit v1.2.3-1-g7c22 From db5ff4e1e2640b7312533cb276b545c4b9920110 Mon Sep 17 00:00:00 2001 From: Nicu Tofan Date: Thu, 28 Jun 2018 00:13:35 +0300 Subject: Changing events in calendar updates the card --- client/components/boards/boardBody.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'client/components') 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'); -- cgit v1.2.3-1-g7c22