Scheduling Filters
Revision as of 23:41, 4 December 2024 by Admin (talk | contribs) (Created page with "Similar to data loaders and special dates, Scheduling Filters are javascript definitions that allow us to define custom event and resource filters. The below example provided example is for a Job filter. The fingerprint of the javascript object is as follows: * name - must be a unique, camelCase name of the filter * label - will be displayed in the list of filters * items - a javascript function that must return a list of objects with a name and a label attributes * ma...")
Similar to data loaders and special dates, Scheduling Filters are javascript definitions that allow us to define custom event and resource filters.
The below example provided example is for a Job filter. The fingerprint of the javascript object is as follows:
- name - must be a unique, camelCase name of the filter
- label - will be displayed in the list of filters
- items - a javascript function that must return a list of objects with a name and a label attributes
- matchesItems - a javascript function that must return true/false. This function is called by the scheduler in order to filter out events based on the selected/applied filters. The function has two parameters:
- event - the current event which can be a shift or a request
- filterItems - an array of the names of any applied filters
Global Variables
- events - an array of scheduling events
@return - custom defined object with the below fingerprint
{
name: "job",
label: "Job",
items: function () {
const jobOptions = [...new Map(events.map(item => {
return [item.extendedProps?.b3s__Job__c, item];
})).values()]
.filter(e => !!e.extendedProps?.b3s__Job__c)
.map(event => {
return {
name: event.extendedProps?.b3s__Job__c,
label: event.extendedProps?.b3s__Job__r?.Name,
color: '#000000'
}
});
return [
... jobOptions
]
},
matchesItems: function (event, filterItems = []) {
return filterItems.some(filterItem => {
return event.extendedProps?.b3s__Job__c === filterItem;
});
}
}
When creating the scheduling filters, the metadata record also allows you to enter an Order number. We will display filters in ascending order based on this field.
Global Variables
You have access to the following global variables inside of a schedule filter:
- events - all events loaded
- screenEvents - those events that are actually visible (not filtered)
- colorSchema - an object with color keys - reserved for future use