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

Commit

Permalink
fix(dayView): support updating the day view chunk and split options o…
Browse files Browse the repository at this point in the history
…n the fly

Closes #358
  • Loading branch information
Matt Lewis committed Jun 26, 2016
1 parent a6d2bdb commit 12d99a2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/directives/mwlCalendarDay.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ angular

vm.$sce = $sce;

$scope.$on('calendar.refreshView', function() {
function refreshView() {
vm.dayViewSplit = vm.dayViewSplit || 30;
vm.dayViewHeight = calendarHelper.getDayViewHeight(
vm.dayViewStart,
Expand All @@ -34,7 +34,15 @@ angular
return !event.allDay;
});

});
}

$scope.$on('calendar.refreshView', refreshView);

$scope.$watchGroup([
'vm.dayViewStart',
'vm.dayViewEnd',
'vm.dayViewSplit'
], refreshView);

vm.eventDragComplete = function(event, minuteChunksMoved) {
var minutesDiff = minuteChunksMoved * vm.dayViewSplit;
Expand Down
12 changes: 12 additions & 0 deletions test/unit/directives/mwlCalendarDay.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,23 @@ describe('mwlCalendarDay directive', function() {
vm.dayViewsplit = 30;
vm.events = [
{
$id: 0,
title: 'An event',
type: 'warning',
startsAt: moment(calendarDay).startOf('week').subtract(2, 'days').add(8, 'hours').toDate(),
endsAt: moment(calendarDay).startOf('week').add(1, 'week').add(9, 'hours').toDate(),
draggable: true,
resizable: true
}, {
$id: 1,
title: '<i class="glyphicon glyphicon-asterisk"></i> <span class="text-primary">Another event</span>, with a <i>html</i> title',
type: 'info',
startsAt: moment(calendarDay).subtract(1, 'day').toDate(),
endsAt: moment(calendarDay).add(5, 'days').toDate(),
draggable: true,
resizable: true
}, {
$id: 2,
title: 'This is a really long event title that occurs on every year',
type: 'important',
startsAt: moment(calendarDay).startOf('day').add(7, 'hours').toDate(),
Expand Down Expand Up @@ -138,4 +141,13 @@ describe('mwlCalendarDay directive', function() {
expect(scope.events[0].tempStartsAt).to.eql(new Date(2015, 3, 24, 8, 30));
});

it('should update the events when the day view split changes', function() {
scope.viewDate = moment(calendarDay).startOf('day').add(1, 'hour').toDate();
scope.$apply();
scope.$broadcast('calendar.refreshView');
scope.dayViewSplit = 15;
scope.$apply();
expect(MwlCalendarCtrl.nonAllDayEvents[0].height).to.equal(2040);
});

});

0 comments on commit 12d99a2

Please sign in to comment.