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

fix(MonthAndYearViews): Check openRowIndex is explicitly null so that…

… the condition evaluates proper
  • Loading branch information...
Matt Lewis
Matt Lewis committed Dec 2, 2015
1 parent 2460c0d commit 67ae22a7ee00ca4ea98ab50e1ceb4909d4c52916
@@ -8,6 +8,7 @@ angular

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

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

@@ -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)) {
@@ -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)) {
@@ -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;
});

@@ -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() {

0 comments on commit 67ae22a

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