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

Commit

Permalink
fix(MonthAndYearViews): Check openRowIndex is explicitly null so that…
Browse files Browse the repository at this point in the history
… the condition evaluates proper
  • Loading branch information
Matt Lewis committed Dec 2, 2015
1 parent 2460c0d commit 67ae22a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/directives/mwlCalendarMonth.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ angular

var vm = this;
vm.calendarConfig = calendarConfig;
vm.openRowIndex = null;

$scope.$on('calendar.refreshView', function() {

Expand All @@ -21,7 +22,7 @@ angular
}

//Auto open the calendar to the current day if set
if (vm.cellIsOpen && !vm.openRowIndex) {
if (vm.cellIsOpen && vm.openRowIndex === null) {
vm.openDayIndex = null;
vm.view.forEach(function(day) {
if (day.inMonth && moment(vm.currentDay).startOf('day').isSame(day.date)) {
Expand Down
3 changes: 2 additions & 1 deletion src/directives/mwlCalendarYear.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ angular
.controller('MwlCalendarYearCtrl', function($scope, moment, calendarHelper) {

var vm = this;
vm.openMonthIndex = null;

$scope.$on('calendar.refreshView', function() {
vm.view = calendarHelper.getYearView(vm.events, vm.currentDay, vm.cellModifier);

//Auto open the calendar to the current day if set
if (vm.cellIsOpen && !vm.openMonthIndex) {
if (vm.cellIsOpen && vm.openMonthIndex === null) {
vm.openMonthIndex = null;
vm.view.forEach(function(month) {
if (moment(vm.currentDay).startOf('month').isSame(month.date)) {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/directives/mwlCalendarMonth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ describe('mwlCalendarMonth directive', function() {
});

it('should disable the slidebox if the click event is prevented', function() {
expect(MwlCalendarCtrl.openRowIndex).to.be.undefined;
expect(MwlCalendarCtrl.openRowIndex).to.be.null;
expect(MwlCalendarCtrl.openDayIndex).to.be.undefined;
MwlCalendarCtrl.view = [{date: moment(calendarDay), inMonth: true}];
MwlCalendarCtrl.dayClicked(MwlCalendarCtrl.view[0], false, {defaultPrevented: true});
expect(MwlCalendarCtrl.openRowIndex).to.be.undefined;
expect(MwlCalendarCtrl.openRowIndex).to.be.null;
expect(MwlCalendarCtrl.openDayIndex).to.be.undefined;
});

Expand Down
4 changes: 2 additions & 2 deletions test/unit/directives/mwlCalendarYear.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ describe('mwlCalendarYear directive', function() {

it('should disable the slidebox if the click event is prevented', function() {
expect(MwlCalendarCtrl.openRowIndex).to.be.undefined;
expect(MwlCalendarCtrl.openMonthIndex).to.be.undefined;
expect(MwlCalendarCtrl.openMonthIndex).to.be.null;
MwlCalendarCtrl.view = [{date: moment(calendarDay), inMonth: true}];
MwlCalendarCtrl.monthClicked(MwlCalendarCtrl.view[0], false, {defaultPrevented: true});
expect(MwlCalendarCtrl.openRowIndex).to.be.undefined;
expect(MwlCalendarCtrl.openMonthIndex).to.be.undefined;
expect(MwlCalendarCtrl.openMonthIndex).to.be.null;
});

it('should call the callback function when you finish dropping an event', function() {
Expand Down

0 comments on commit 67ae22a

Please sign in to comment.