Skip to content
This repository has been archived by the owner on Jun 19, 2018. It is now read-only.

Commit

Permalink
feat(drag-and-drop): expose the date the calendar event was dragged f…
Browse files Browse the repository at this point in the history
…rom on the month view

Closes #250
  • Loading branch information
Matt Lewis committed Jan 1, 2016
1 parent b0887a1 commit 5ca6920
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ This expression is called when an event is clicked on the calendar. `calendarEve

### on-event-times-changed

This expression is called when an event is dragged and dropped or resized into a different date / time on the calendar. The available values that are passed to the expression are: `calendarEvent`, `calendarNewEventStart` and `calendarNewEventEnd`. The directive won't change the event object and leaves that up to you to implement. Please note drag and drop is only available by including the [interact.js](http://interactjs.io/) library.
This expression is called when an event is dragged and dropped or resized into a different date / time on the calendar. The available values that are passed to the expression are: `calendarEvent`, `calendarNewEventStart`, `calendarNewEventEnd` and `calendarDraggedFromDate` (month view only). The directive won't change the event object and leaves that up to you to implement. Please note drag and drop is only available by including the [interact.js](http://interactjs.io/) library.

### edit-event-html

Expand Down
5 changes: 3 additions & 2 deletions src/directives/mwlCalendarMonth.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ angular

};

vm.handleEventDrop = function(event, newDayDate) {
vm.handleEventDrop = function(event, newDayDate, draggedFromDate) {

var newStart = moment(event.startsAt)
.date(moment(newDayDate).date())
Expand All @@ -84,7 +84,8 @@ angular
calendarEvent: event,
calendarDate: newDayDate,
calendarNewEventStart: newStart.toDate(),
calendarNewEventEnd: newEnd ? newEnd.toDate() : null
calendarNewEventEnd: newEnd ? newEnd.toDate() : null,
calendarDraggedFromDate: draggedFromDate
});
};

Expand Down
2 changes: 1 addition & 1 deletion src/templates/calendarMonthCell.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div
mwl-droppable
on-drop="vm.handleEventDrop(dropData.event, day.date)"
on-drop="vm.handleEventDrop(dropData.event, day.date, dropData.draggedFromDate)"
class="cal-month-day {{ day.cssClass }}"
ng-class="{
'cal-day-outmonth': !day.inMonth,
Expand Down
2 changes: 1 addition & 1 deletion src/templates/calendarMonthCellEvents.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
tooltip-append-to-body="true"
uib-tooltip-html="((event.startsAt | calendarDate:'time':true) + (vm.calendarConfig.displayEventEndTimes && event.endsAt ? ' - ' + (event.endsAt | calendarDate:'time':true) : '') + ' - ' + event.title) | calendarTrustAsHtml"
mwl-draggable="event.draggable === true"
drop-data="{event: event}">
drop-data="{event: event, draggedFromDate: day.date.toDate()}">
</a>
</div>

0 comments on commit 5ca6920

Please sign in to comment.