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

fix(weekView): use correct date for onTimespanClick callback

BREAKING CHANGE: if using a custom week view template, the getClickedDate function has been removed

Closes #454
  • Loading branch information...
Matt Lewis
Matt Lewis committed Oct 9, 2016
1 parent 580a967 commit e05882e099c545d937570c4e40c1254ada58382e
Showing with 17 additions and 18 deletions.
  1. +3 −4 src/directives/mwlCalendarHourList.js
  2. +14 −14 src/templates/calendarHourList.html
@@ -30,6 +30,7 @@ angular
hour.segments.forEach(function(segment) {

segment.date = moment(segment.date);
segment.nextSegmentDate = segment.date.clone().add(vm.dayViewSplit, 'minutes');

if (calendarConfig.showTimesOnWeekView) {

@@ -39,13 +40,15 @@ angular
var day = {
date: moment(segment.date).add(i, 'days')
};
day.nextSegmentDate = day.date.clone().add(vm.dayViewSplit, 'minutes');
vm.cellModifier({calendarCell: day});
segment.days.push(day);
}

} else {
vm.cellModifier({calendarCell: segment});
}

});
});

@@ -83,10 +86,6 @@ angular
});
};

vm.getClickedDate = function(baseDate, minutes, days) {
return moment(baseDate).clone().startOf('hour').add(minutes, 'minutes').add(days || 0, 'days').toDate();
};

vm.onDragSelectStart = function(date, dayIndex) {
if (!vm.dateRangeSelect) {
vm.dateRangeSelect = {
@@ -6,15 +6,15 @@
class="cal-day-hour-part"
ng-repeat="segment in hour.segments track by $index"
ng-class="[{ 'cal-day-hour-part-selected': vm.dateRangeSelect &&
vm.dateRangeSelect.startDate <= vm.getClickedDate(segment.date, vm.dayViewSplit * $index) &&
vm.getClickedDate(segment.date, vm.dayViewSplit * $index) < vm.dateRangeSelect.endDate }, segment.cssClass]"
ng-click="vm.onTimespanClick({calendarDate: vm.getClickedDate(segment.date, vm.dayViewSplit * $index)})"
vm.dateRangeSelect.startDate <= segment.date &&
segment.date < vm.dateRangeSelect.endDate }, segment.cssClass]"
ng-click="vm.onTimespanClick({calendarDate: segment.date})"
mwl-droppable
on-drop="vm.eventDropped(dropData.event, vm.getClickedDate(segment.date, vm.dayViewSplit * $index))"
on-drop="vm.eventDropped(dropData.event, segment.date)"
mwl-drag-select="!!vm.onDateRangeSelect"
on-drag-select-start="vm.onDragSelectStart(vm.getClickedDate(segment.date, vm.dayViewSplit * $index))"
on-drag-select-move="vm.onDragSelectMove(vm.getClickedDate(segment.date, vm.dayViewSplit * ($index + 1)))"
on-drag-select-end="vm.onDragSelectEnd(vm.getClickedDate(segment.date, vm.dayViewSplit * ($index + 1)))"
on-drag-select-start="vm.onDragSelectStart(segment.date)"
on-drag-select-move="vm.onDragSelectMove(segment.nextSegmentDate)"
on-drag-select-end="vm.onDragSelectEnd(segment.nextSegmentDate)"
ng-if="!vm.dayWidth">
<div class="cal-day-hour-part-time">
<strong ng-bind="segment.date | calendarDate:'hour':true" ng-show="segment.isStart"></strong>
@@ -34,15 +34,15 @@
ng-repeat="day in segment.days track by $index"
ng-style="{width: vm.dayWidth + 'px'}"
ng-class="[{ 'cal-day-hour-part-selected': vm.dateRangeSelect &&
vm.dateRangeSelect.startDate <= vm.getClickedDate(segment.date, vm.dayViewSplit * $parent.$index, $index) &&
vm.getClickedDate(segment.date, vm.dayViewSplit * $parent.$index, $index) < vm.dateRangeSelect.endDate }, day.cssClass]"
ng-click="vm.onTimespanClick({calendarDate: vm.getClickedDate(segment.date, vm.dayViewSplit * $parent.$index, $index)})"
vm.dateRangeSelect.startDate <= day.date &&
day.date < vm.dateRangeSelect.endDate }, day.cssClass]"
ng-click="vm.onTimespanClick({calendarDate: day.date})"
mwl-droppable
on-drop="vm.eventDropped(dropData.event, vm.getClickedDate(segment.date, vm.dayViewSplit * $parent.$index, $index))"
on-drop="vm.eventDropped(dropData.event, day.date)"
mwl-drag-select="!!vm.onDateRangeSelect"
on-drag-select-start="vm.onDragSelectStart(vm.getClickedDate(segment.date, vm.dayViewSplit * $parent.$index, $index), $index)"
on-drag-select-move="vm.onDragSelectMove(vm.getClickedDate(segment.date, vm.dayViewSplit * ($parent.$index + 1), vm.dateRangeSelect.dayIndex))"
on-drag-select-end="vm.onDragSelectEnd(vm.getClickedDate(segment.date, vm.dayViewSplit * ($parent.$index + 1), vm.dateRangeSelect.dayIndex))">
on-drag-select-start="vm.onDragSelectStart(day.date)"
on-drag-select-move="vm.onDragSelectMove(day.nextSegmentDate)"
on-drag-select-end="vm.onDragSelectEnd(day.nextSegmentDate)">
</div>
</div>

0 comments on commit e05882e

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