Support Forum
It is not possible to solve because we've used resourceZones to solve "availability" which defines the start and end time for the day. Now we have to solve "intervals". The only thing left to use is Sch.plugin.Zones which does not relate to resource (only relates to time). Intervals can be "coffee break" and "lunch" (or like we have here in New Zealand "morning tea" and "afternoon tea")
isResourceAvailable : function(resource, start, end) {
var availability = this.getAvailabilityForResource(resource);
if (!availability || availability.length === 0) return true;
for (var i = 0, l = availability.length; i < l; i++) {
// Check if there is an availability block completely encapsulating the passed start/end timespan
if (Sch.util.Date.timeSpanContains(availability[i].getStartDate(), availability[i].getEndDate(), start, end)) {
return true;
}
}
return false;
}
With the code above we can't start a task before lunch and finish after lunch.
Not sure if I understand you correctly. The resourceZones right now stores availability per resource right ? So from what I understand, home time is everything that exceeds the availability defined there. The additional availabilities at the begginging/end of the day can be solved with this just the same way. Now you want to add a second class of availability - Lunch, and during the lunch resource cannot have any tasks assigned but is available ? Am I still correct ? If you don't want the availability during the lunch time to be greyed-out just like when the resource is not available, you can for example use classes as Mats suggested, and modify your isResourceAvailable function in the following way :
isResourceAvailable : function(resource, start, end) {
var availability = this.getEventsForResource(resource);
if (!availability || availability.length === 0) return true;
for (var i = 0, l = availability.length; i < l; i++) {
// Check if availability is not of `lunch` class
if (availability[i].get('Cls', 'lunch')){
return false;
} else if (Sch.util.Date.timeSpanContains(availability[i].getStartDate(), availability[i].getEndDate(), start, end)) {
return true;
}
}
return false;
}
- Attachments
-
- Zrzut ekranu 2012-07-20 o 14.03.49.png (15.94 KiB) Viewed 10191 times
JavaScript/Angular/ExtJS consulting - kuba@virtualdesign.pl
Thanks for your reply Jakub.
Your code help me to understand the "availability.get('Cls')" part.
This is how we resolved the issue:
Now our scheduler is showing the availability and interval per resource.
Thanks.
Your code help me to understand the "availability.get('Cls')" part.
This is how we resolved the issue:
isResourceAvailable : function(resource, start, end) {
var availability = this.getAvailabilityForResource(resource);
if (!availability || availability.length === 0) return true;
var startTime = 0, finishTime = 0;
for (var i = 0, l = availability.length; i < l; i++) {
if ( availability[i].get('Cls').indexOf('start-time') > 0 ) {
startTime = availability[i].getStartDate();
} else if ( availability[i].get('Cls').indexOf('finish-time') > 0 ) {
finishTime = availability[i].getEndDate();
}
}
// Check if there is an availability block completely encapsulating the passed start/end timespan
if (Sch.util.Date.timeSpanContains(startTime, finishTime, start, end)) {
return true;
}
return false;
}
Thanks.
- Attachments
-
- Availability and interval per resource
- availability-and-interval-per-resource.png (11.17 KiB) Viewed 10165 times
Glad I was able to help. Now just a custom template and it'll be superb
JavaScript/Angular/ExtJS consulting - kuba@virtualdesign.pl