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

fix(dayView): fix drag and select when using the week view with times

Closes #536
  • Loading branch information...
Matt Lewis
Matt Lewis committed Mar 4, 2017
1 parent f0573b6 commit a4b621369233e383b18dd1488dbaba107bbcd151
@@ -5,7 +5,7 @@ var calendarUtils = require('calendar-utils');

angular
.module('mwl.calendar')
.controller('MwlCalendarHourListCtrl', function($scope, moment, calendarHelper, calendarConfig) {
.controller('MwlCalendarHourListCtrl', function($scope, moment, calendarHelper) {
var vm = this;

function updateDays() {
@@ -14,7 +14,7 @@ angular
var dayStart = (vm.dayViewStart || '00:00').split(':');
var dayEnd = (vm.dayViewEnd || '23:59').split(':');
vm.hourGrid = calendarUtils.getDayViewHourGrid({
viewDate: calendarConfig.showTimesOnWeekView ? moment(vm.viewDate).startOf('week').toDate() : moment(vm.viewDate).toDate(),
viewDate: vm.view === 'week' ? moment(vm.viewDate).startOf('week').toDate() : moment(vm.viewDate).toDate(),
hourSegments: 60 / vm.dayViewSplit,
dayStart: {
hour: dayStart[0],
@@ -32,7 +32,7 @@ angular
segment.date = moment(segment.date);
segment.nextSegmentDate = segment.date.clone().add(vm.dayViewSplit, 'minutes');

if (calendarConfig.showTimesOnWeekView) {
if (vm.view === 'week') {

segment.days = [];

@@ -134,7 +134,8 @@ angular
onEventTimesChanged: '=',
customTemplateUrls: '=?',
cellModifier: '=',
templateScope: '='
templateScope: '=',
view: '@'
},
bindToController: true
};
@@ -39,7 +39,8 @@
view-date="vm.viewDate"
custom-template-urls="vm.customTemplateUrls"
template-scope="vm.templateScope"
cell-modifier="vm.cellModifier">
cell-modifier="vm.cellModifier"
view="day">
</mwl-calendar-hour-list>

<div
@@ -41,6 +41,7 @@
custom-template-urls="vm.customTemplateUrls"
cell-modifier="vm.cellModifier"
template-scope="vm.templateScope"
view="week"
ng-if="vm.showTimes">
</mwl-calendar-hour-list>

@@ -20,6 +20,7 @@ describe('mwlCalendarHourList directive', function() {
'on-event-times-changed="eventDropped(calendarEvent, calendarDate, calendarNewEventStart, calendarNewEventEnd)" ' +
'cell-modifier="cellModifier"' +
'day-width="dayWidth"' +
'view="{{ view }}"' +
'></mwl-calendar-hour-list>';

function prepareScope(vm) {
@@ -28,6 +29,7 @@ describe('mwlCalendarHourList directive', function() {
vm.dayViewEnd = '22:59';
vm.dayViewsplit = 30;
vm.cellModifier = sinon.stub();
vm.view = 'day';

showModal = sinon.spy();

@@ -163,7 +165,7 @@ describe('mwlCalendarHourList directive', function() {
});

it('should allow the week view with times day segments CSS classes to be customised', function() {
calendarConfig.showTimesOnWeekView = true;
scope.view = 'week';
scope.dayWidth = 50;
sinon.stub(moment, 'locale').returns('another locale');
scope.cellModifier = function(args) {
@@ -172,7 +174,6 @@ describe('mwlCalendarHourList directive', function() {
scope.$apply();
scope.$broadcast('calendar.refreshView');
scope.$apply();
calendarConfig.showTimesOnWeekView = false;
moment.locale.restore();
expect(element[0].querySelector('.cal-day-hour-part-spacer.foo')).to.be.ok;
});

0 comments on commit a4b6213

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