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

Commit

Permalink
fix(dayView): fix drag and select when using the week view with times
Browse files Browse the repository at this point in the history
Closes #536
  • Loading branch information
Matt Lewis committed Mar 4, 2017
1 parent f0573b6 commit a4b6213
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/directives/mwlCalendarHourList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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],
Expand All @@ -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 = [];

Expand Down Expand Up @@ -134,7 +134,8 @@ angular
onEventTimesChanged: '=',
customTemplateUrls: '=?',
cellModifier: '=',
templateScope: '='
templateScope: '=',
view: '@'
},
bindToController: true
};
Expand Down
3 changes: 2 additions & 1 deletion src/templates/calendarDayView.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/templates/calendarWeekView.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
5 changes: 3 additions & 2 deletions test/unit/directives/mwlCalendarHourList.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();

Expand Down Expand Up @@ -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) {
Expand All @@ -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;
});
Expand Down

0 comments on commit a4b6213

Please sign in to comment.