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

Commit

Permalink
fix(weekView): use correct date for onTimespanClick callback
Browse files Browse the repository at this point in the history
BREAKING CHANGE: if using a custom week view template, the getClickedDate function has been removed

Closes #454
  • Loading branch information
Matt Lewis committed Oct 9, 2016
1 parent 580a967 commit e05882e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
7 changes: 3 additions & 4 deletions src/directives/mwlCalendarHourList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

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

});
});

Expand Down Expand Up @@ -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 = {
Expand Down
28 changes: 14 additions & 14 deletions src/templates/calendarHourList.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>

Expand Down

0 comments on commit e05882e

Please sign in to comment.