onActionBegin(args: ActionEventArgs): void {
let isEventChange: boolean = (args.requestType === 'eventChange');
if ((args.requestType === 'eventCreate' && (<Object[]>args.data).length > 0) || isEventChange) {
let eventData: { [key: string]: Object } = (isEventChange) ? args.data as { [key: string]: Object } :
args.data[0] as { [key: string]: Object };
let eventField: EventFieldsMapping = this.scheduleObj.eventFields;
let startDate: Date = eventData[eventField.startTime] as Date;
let endDate: Date = eventData[eventField.endTime] as Date;
args.cancel = !this.isValidateTime(startDate, endDate);
if (!args.cancel) {
args.cancel = !this.scheduleObj.isSlotAvailable(startDate, endDate);
}
}
}
isValidateTime(startDate: Date, endDate: Date): boolean {
return (((this.startDt <= startDate.getHours() && this.endDt > endDate.getHours()) || (this.endDt === endDate.getHours() && endDate.getMinutes() === 0)) || ((this.srtDt <= startDate.getHours() && this.enDt > endDate.getHours()) || (this.enDt === endDate.getHours() && endDate.getMinutes() === 0)));
}
onPopupOpen(args: PopupOpenEventArgs): void {
if (args.target && args.target.classList.contains('e-work-cells')) {
args.cancel = !args.target.classList.contains('custom');
}
}
onRenderCell(args: RenderCellEventArgs): void {
if (args.element.classList.contains('e-work-hours') || args.element.classList.contains('e-work-cells')) {
if ((args.date.getHours() >= this.startDt && args.date.getHours() < this.endDt) || (args.date.getHours() >= this.srtDt && args.date.getHours() < this.enDt)) {
args.element.classList.add('custom');
}
}
} |