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

Commit

Permalink
Make endsAt optional on events. Closes #88
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Lewis committed Jun 3, 2015
1 parent 05e1f90 commit b48ea25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/less/day.less
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
position: absolute;
width: 150px;
overflow: hidden;
padding: 2px 3px !important;

a {
font-size: 12px;
text-overflow: ellipsis;
}

}
Expand Down
16 changes: 10 additions & 6 deletions src/services/calendarHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ angular
function eventIsInPeriod(event, periodStart, periodEnd) {

var eventStart = moment(event.startsAt);
var eventEnd = moment(event.endsAt);
var eventEnd = moment(event.endsAt || event.startsAt);
periodStart = moment(periodStart);
periodEnd = moment(periodEnd);

Expand Down Expand Up @@ -160,7 +160,7 @@ angular
var eventsSorted = filterEventsInPeriod(events, startOfWeek, endOfWeek).map(function(event) {

var eventStart = moment(event.startsAt).startOf('day');
var eventEnd = moment(event.endsAt).startOf('day');
var eventEnd = moment(event.endsAt || event.startsAt).startOf('day');
var weekViewStart = moment(startOfWeek).startOf('day');
var weekViewEnd = moment(endOfWeek).startOf('day');
var offset, span;
Expand Down Expand Up @@ -211,14 +211,18 @@ angular
event.top = (moment(event.startsAt).startOf('minute').diff(calendarStart.startOf('minute'), 'minutes') * hourHeightMultiplier) - 2;
}

if (moment(event.endsAt).isAfter(calendarEnd)) {
if (moment(event.endsAt || event.startsAt).isAfter(calendarEnd)) {
event.height = calendarHeight - event.top;
} else {
var diffStart = event.startsAt;
if (moment(event.startsAt).isBefore(calendarStart)) {
diffStart = calendarStart.toDate();
}
event.height = moment(event.endsAt).diff(diffStart, 'minutes') * hourHeightMultiplier;
if (!event.endsAt) {
event.height = 30;
} else {
event.height = moment(event.endsAt || event.startsAt).diff(diffStart, 'minutes') * hourHeightMultiplier;
}
}

if (event.top - event.height > calendarHeight) {
Expand All @@ -237,8 +241,8 @@ angular
var canFitInThisBucket = true;

bucket.forEach(function(bucketItem) {
if (eventIsInPeriod(event, bucketItem.startsAt, bucketItem.endsAt) ||
eventIsInPeriod(bucketItem, event.startsAt, event.endsAt)) {
if (eventIsInPeriod(event, bucketItem.startsAt, bucketItem.endsAt || bucketItem.startsAt) ||
eventIsInPeriod(bucketItem, event.startsAt, event.endsAt || event.startsAt)) {
canFitInThisBucket = false;
}
});
Expand Down

0 comments on commit b48ea25

Please sign in to comment.