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

Commit

Permalink
feat(weekView): allow external events to be dropped on week column he…
Browse files Browse the repository at this point in the history
…aders

First part of #284
  • Loading branch information
Matt Lewis committed Feb 13, 2016
1 parent e112186 commit 1ea99a3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/directives/mwlCalendarWeek.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ angular
});
};

vm.eventDropped = function(event, date) {
var daysDiff = moment(date).diff(moment(event.startsAt), 'days');
vm.weekDragged(event, daysDiff);
};

vm.weekResized = function(event, edge, daysDiff) {

var start = moment(event.startsAt);
Expand Down
6 changes: 5 additions & 1 deletion src/less/theme.less
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
.cal-month-day {
height: @rowHeightMonth;
}
[class*="cal-cell"]:hover, .cell-focus, [class*="cal-cell"] .drop-active, .cal-cell.drop-active {
[class*="cal-cell"]:hover,
.cell-focus,
[class*="cal-cell"] .drop-active,
.cal-cell.drop-active,
.cal-week-box .cal-cell1.drop-active {
background-color: @dayHover;
}
.cal-year-box [class*="span"],
Expand Down
14 changes: 7 additions & 7 deletions src/templates/calendarMonthCell.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
on-drop="vm.handleEventDrop(dropData.event, day.date, dropData.draggedFromDate)"
class="cal-month-day {{ day.cssClass }}"
ng-class="{
'cal-day-outmonth': !day.inMonth,
'cal-day-inmonth': day.inMonth,
'cal-day-weekend': day.isWeekend,
'cal-day-past': day.isPast,
'cal-day-today': day.isToday,
'cal-day-future': day.isFuture
}">
'cal-day-outmonth': !day.inMonth,
'cal-day-inmonth': day.inMonth,
'cal-day-weekend': day.isWeekend,
'cal-day-past': day.isPast,
'cal-day-today': day.isToday,
'cal-day-future': day.isFuture
}">

<small
class="cal-events-num badge badge-important pull-left"
Expand Down
4 changes: 3 additions & 1 deletion src/templates/calendarWeekView.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
'cal-day-past': day.isPast,
'cal-day-today': day.isToday,
'cal-day-future': day.isFuture}"
mwl-element-dimensions="vm.dayColumnDimensions">
mwl-element-dimensions="vm.dayColumnDimensions"
mwl-droppable
on-drop="vm.eventDropped(dropData.event, day.date)">

<span ng-bind="day.weekDayLabel"></span>
<br>
Expand Down
7 changes: 7 additions & 0 deletions test/unit/directives/mwlCalendarWeek.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,11 @@ describe('mwlCalendarWeek directive', function() {
});
});

it('should allow events to be dropped on days', function() {
var event = {startsAt: moment().add(1, 'day').toDate()};
MwlCalendarCtrl.weekDragged = sinon.spy();
MwlCalendarCtrl.eventDropped(event, new Date());
expect(MwlCalendarCtrl.weekDragged).to.have.been.calledWith(event, -1);
});

});

0 comments on commit 1ea99a3

Please sign in to comment.