Show cool things you have done with our products


Post by sencha@honda.co.nz »

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") :)

Post by mats »

Use resource zones for both, indicate the type using Cls field. Simple :)

Post by sencha@honda.co.nz »

If I use resourceZones for both Availability and Interval we are going to face problems for a Task which goes across different blocks of availability.

Post by mats »

Define "problems"?

Post by sencha@honda.co.nz »

    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; 
    }
How could we know when it is the very first and the very last block of resouceZone per day?

With the code above we can't start a task before lunch and finish after lunch.

Post by sencha@honda.co.nz »

Basically we can have a Task starting before a lunch break and finishing after a lunch break.

We definitely can't have a Task finishing after home time.

Post by jakub »

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
Zrzut ekranu 2012-07-20 o 14.03.49.png (15.94 KiB) Viewed 10165 times
JavaScript/Angular/ExtJS consulting - kuba@virtualdesign.pl

Post by sencha@honda.co.nz »

Thanks for your reply Jakub.

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; 
    }
Now our scheduler is showing the availability and interval per resource.

Thanks.
Attachments
Availability and interval per resource
Availability and interval per resource
availability-and-interval-per-resource.png (11.17 KiB) Viewed 10139 times

Post by jakub »

Glad I was able to help. Now just a custom template and it'll be superb :)
JavaScript/Angular/ExtJS consulting - kuba@virtualdesign.pl

Post Reply