Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

fix(monthView): generate correct new start date when dropping an event

Closes #588
  • Loading branch information...
Matt Lewis
Matt Lewis committed May 21, 2017
1 parent 1d110c1 commit e92d6476444d6ac1bb7db32758d2c0d0e781a764
Showing with 23 additions and 2 deletions.
  1. +2 −2 src/directives/mwlCalendarMonth.js
  2. +21 −0 test/unit/directives/mwlCalendarMonth.spec.js
@@ -93,9 +93,9 @@ angular
vm.handleEventDrop = function(event, newDayDate, draggedFromDate) {

var newStart = moment(event.startsAt)
.date(moment(newDayDate).date())
.year(moment(newDayDate).year())
.month(moment(newDayDate).month())
.year(moment(newDayDate).year());
.date(moment(newDayDate).date());

var newEnd = calendarHelper.adjustEndDateFromStartDiff(event.startsAt, newStart, event.endsAt);

@@ -197,6 +197,27 @@ describe('mwlCalendarMonth directive', function() {
});
});

it('should apply the year, month and date modifications in the right order', function() {
scope.viewDate = new Date('2017-01-05');
scope.events = [{
title: 'An event',
type: 'warning',
startsAt: new Date('2017-02-01'),
draggable: true,
resizable: true
}];
scope.$apply();
var draggedFromDate = new Date('2017-02-01');
MwlCalendarCtrl.handleEventDrop(scope.events[0], new Date('2017-01-31'), draggedFromDate);
expect(showModal).to.have.been.calledWith('Dropped or resized', {
calendarEvent: scope.events[0],
calendarDate: new Date('2017-01-31'),
calendarNewEventStart: new Date('2017-01-31'),
calendarNewEventEnd: null,
calendarDraggedFromDate: draggedFromDate
});
});

it('should get the week label', function() {
expect(MwlCalendarCtrl.getWeekNumberLabel({date: moment().startOf('year').endOf('week').add(1, 'day')})).to.equal('Week 1');
});

0 comments on commit e92d647

Please sign in to comment.
You can’t perform that action at this time.