diff --git a/src/directives/mwlCalendarWeek.js b/src/directives/mwlCalendarWeek.js index 82ee8067..1c3bcfac 100644 --- a/src/directives/mwlCalendarWeek.js +++ b/src/directives/mwlCalendarWeek.js @@ -51,6 +51,11 @@ angular }); }; + vm.eventDropped = function(event, date) { + var daysDiff = moment(date).diff(moment(event.startsAt), 'days'); + vm.weekDragged(event, daysDiff); + }; + vm.weekResized = function(event, edge, daysDiff) { var start = moment(event.startsAt); diff --git a/src/less/theme.less b/src/less/theme.less index 3e225507..e0f06e88 100755 --- a/src/less/theme.less +++ b/src/less/theme.less @@ -15,7 +15,11 @@ .cal-month-day { height: @rowHeightMonth; } -[class*="cal-cell"]:hover, .cell-focus, [class*="cal-cell"] .drop-active, .cal-cell.drop-active { +[class*="cal-cell"]:hover, +.cell-focus, +[class*="cal-cell"] .drop-active, +.cal-cell.drop-active, +.cal-week-box .cal-cell1.drop-active { background-color: @dayHover; } .cal-year-box [class*="span"], diff --git a/src/templates/calendarMonthCell.html b/src/templates/calendarMonthCell.html index d54e6c8d..2d5ab3ad 100644 --- a/src/templates/calendarMonthCell.html +++ b/src/templates/calendarMonthCell.html @@ -3,13 +3,13 @@ on-drop="vm.handleEventDrop(dropData.event, day.date, dropData.draggedFromDate)" class="cal-month-day {{ day.cssClass }}" ng-class="{ - 'cal-day-outmonth': !day.inMonth, - 'cal-day-inmonth': day.inMonth, - 'cal-day-weekend': day.isWeekend, - 'cal-day-past': day.isPast, - 'cal-day-today': day.isToday, - 'cal-day-future': day.isFuture - }"> + 'cal-day-outmonth': !day.inMonth, + 'cal-day-inmonth': day.inMonth, + 'cal-day-weekend': day.isWeekend, + 'cal-day-past': day.isPast, + 'cal-day-today': day.isToday, + 'cal-day-future': day.isFuture + }"> + mwl-element-dimensions="vm.dayColumnDimensions" + mwl-droppable + on-drop="vm.eventDropped(dropData.event, day.date)">
diff --git a/test/unit/directives/mwlCalendarWeek.spec.js b/test/unit/directives/mwlCalendarWeek.spec.js index 3d1423de..84cc74ce 100644 --- a/test/unit/directives/mwlCalendarWeek.spec.js +++ b/test/unit/directives/mwlCalendarWeek.spec.js @@ -146,4 +146,11 @@ describe('mwlCalendarWeek directive', function() { }); }); + it('should allow events to be dropped on days', function() { + var event = {startsAt: moment().add(1, 'day').toDate()}; + MwlCalendarCtrl.weekDragged = sinon.spy(); + MwlCalendarCtrl.eventDropped(event, new Date()); + expect(MwlCalendarCtrl.weekDragged).to.have.been.calledWith(event, -1); + }); + });