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

Commit

Permalink
fix: dont modify the events array
Browse files Browse the repository at this point in the history
Closes #491
  • Loading branch information
Matt Lewis committed Nov 13, 2016
1 parent d5f8f61 commit 8b39c31
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/directives/mwlCalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ angular
var previousDate = moment(vm.viewDate);
var previousView = vm.view;

function eventIsValid(event) {
function checkEventIsValid(event) {
if (!event.startsAt) {
$log.warn(LOG_PREFIX, 'Event is missing the startsAt field', event);
} else if (!angular.isDate(event.startsAt)) {
Expand All @@ -55,8 +55,6 @@ angular
$log.warn(LOG_PREFIX, 'Event cannot start after it finishes', event);
}
}

return true;
}

function refreshCalendar() {
Expand All @@ -65,9 +63,9 @@ angular
vm.viewTitle = calendarTitle[vm.view](vm.viewDate);
}

vm.events = vm.events.filter(eventIsValid).map(function(event, index) {
vm.events.forEach(function(event, index) {
checkEventIsValid(event);
event.calendarEventId = index;
return event;
});

//if on-timespan-click="calendarDay = calendarDate" is set then don't update the view as nothing needs to change
Expand Down

0 comments on commit 8b39c31

Please sign in to comment.