Skip to content

Commit

Permalink
Resource object is passed when external event is dropped:
Browse files Browse the repository at this point in the history
drop: function(date, allDay, ev, ui, resource)

Weekend: false handles events in weekends better
  • Loading branch information
Jarno Kurlin committed Oct 9, 2012
1 parent cbc881d commit 99db65d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/common/DayEventRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ function DayEventRenderer() {
}
leftCol -= weekendSumColStart;

if (seg.start.getDay() == 6 || seg.start.getDay() == 0) leftCol++;

for(j=0; j<=rightCol; j++) {
weekendTestDate = addDays(cloneDate(t.visStart), j);

Expand All @@ -205,8 +207,8 @@ function DayEventRenderer() {
if(!weekends) {
leftCol = dateCell(seg.start).col;
rightCol = dateCell(addDays(cloneDate(seg.end),-1)).col;
if (seg.start.getDay() == 6 || seg.start.getDay() == 0) leftCol++;
}

}
else if (viewName == 'resourceDay') {
// hack for resourceDay view
Expand Down
15 changes: 14 additions & 1 deletion src/resource/ResourceEventRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ function ResourceEventRenderer() {
i, row,
j, level,
k, seg, currentResource, viewName = getViewName(),
l, segs=[];
l, segs=[],
weekends = opt('weekends'),
startDay, endDay;

if (viewName == 'resourceDay') {
visEventsEnds = $.map(events, function(event) {
Expand All @@ -92,6 +94,17 @@ function ResourceEventRenderer() {
}

for (l=0; l<seg.event.resource.length; l++) {
startDay = seg.event.start.getDay();
if (seg.event.end == null) seg.event.end = cloneDate(seg.event.start, true);
endDay = seg.event.end.getDay();
// skip if weekends is set to false and this event is on weekend
if(!weekends &&
(startDay == 6 || startDay == 0) &&
(endDay == 6 || endDay == 0) &&
(seg.event.start.getDate() == seg.event.end.getDate() || addDays(cloneDate(seg.event.start),1).getDate() == seg.event.end.getDate())
) continue;


if(currentResource == seg.event.resource[l]) {
segs.push(seg);
}
Expand Down
14 changes: 11 additions & 3 deletions src/resource/ResourceView.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,14 @@ function ResourceView(element, calendar, viewName) {


function dragStop(_dragElement, ev, ui) {
var cell = hoverListener.stop();
var cell = hoverListener.stop(),
resources = t.getResources,
newResource = resources[cell.row];

clearOverlays();
if (cell) {
var d = cellDate(cell);
trigger('drop', _dragElement, d, true, ev, ui);
trigger('drop', _dragElement, d, true, ev, ui, newResource);
}
}

Expand Down Expand Up @@ -503,7 +506,7 @@ function ResourceView(element, calendar, viewName) {


function dateCell(date) {
var col,year,month,day,cmpDate,cmpYear,cmpMonth,cmpDay;
var col,year,month,day,cmpDate,cmpYear,cmpMonth,cmpDay, weekends = opt('weekends');
if (viewName == 'resourceDay') {
col = timeOfDayCol(date);
}
Expand All @@ -523,6 +526,11 @@ function ResourceView(element, calendar, viewName) {
col = i;
break;
}
else if (cmpDate > date && !weekends) {
// No weekends in the calendar, this must be the right column!
col = i-1;
break;
}
};

if (typeof col == 'undefined') {
Expand Down

0 comments on commit 99db65d

Please sign in to comment.