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

fix(dayView): support updating the day view chunk and split options o…

…n the fly

Closes #358
  • Loading branch information...
Matt Lewis
Matt Lewis committed Jun 26, 2016
1 parent a6d2bdb commit 12d99a2bc1d92cfb71e7c10ab03f7e365659bb08
Showing with 22 additions and 2 deletions.
  1. +10 −2 src/directives/mwlCalendarDay.js
  2. +12 −0 test/unit/directives/mwlCalendarDay.spec.js
@@ -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,
@@ -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;
@@ -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(),
@@ -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.
You can’t perform that action at this time.