|
| 1 | +import { Component, ViewChild } from '@angular/core'; |
| 2 | +import { EventSettingsModel, ScheduleComponent, EJ2Instance } from '@syncfusion/ej2-angular-schedule'; |
| 3 | +import { TextBoxComponent } from '@syncfusion/ej2-angular-inputs'; |
| 4 | +import { closest, isNullOrUndefined } from '@syncfusion/ej2-base'; |
| 5 | +import { hospitalData } from './data'; |
| 6 | +@Component({ |
| 7 | + selector: 'app-root', |
| 8 | + templateUrl: './app.component.html', |
| 9 | + styleUrls: ['./app.component.css'] |
| 10 | +}) |
| 11 | +export class AppComponent { |
| 12 | + title = 'myangularproject'; |
| 13 | + @ViewChild('schedule') scheduleObj !: ScheduleComponent; |
| 14 | + public eventSettings: EventSettingsModel = { |
| 15 | + dataSource: hospitalData |
| 16 | + }; |
| 17 | + |
| 18 | + public onCloseClick(){ |
| 19 | + this.scheduleObj.closeQuickInfoPopup(); |
| 20 | + } |
| 21 | + |
| 22 | + public onBtnClk(e:Event, option:string){ |
| 23 | + let quickPopup: HTMLElement = closest(e.target as HTMLElement, '.e-quick-popup-wrapper') as HTMLElement; |
| 24 | + if(option === 'Add'){ |
| 25 | + let subject = ((quickPopup.querySelector('#subject') as EJ2Instance).ej2_instances[0] as TextBoxComponent).value; |
| 26 | + let addObj: Record<string, any> = { |
| 27 | + Id: this.scheduleObj.getEventMaxID(), |
| 28 | + Subject: isNullOrUndefined(subject) ? 'Add title' : subject, |
| 29 | + StartTime: new Date(this.scheduleObj.activeCellsData.startTime), |
| 30 | + EndTime: new Date(this.scheduleObj.activeCellsData.endTime), |
| 31 | + IsAllDay: this.scheduleObj.activeCellsData.isAllDay |
| 32 | + }; |
| 33 | + this.scheduleObj.addEvent(addObj); |
| 34 | + } else{ |
| 35 | + let eventDetails: Record<string, any> = this.scheduleObj.activeEventData.event as Record<string, any>; |
| 36 | + if(option === 'Edit'){ |
| 37 | + eventDetails['Subject'] = ((quickPopup.querySelector('#subject') as EJ2Instance).ej2_instances[0] as TextBoxComponent).value; |
| 38 | + this.scheduleObj.saveEvent(eventDetails); |
| 39 | + } else { |
| 40 | + this.scheduleObj.deleteEvent(eventDetails['Id']); |
| 41 | + } |
| 42 | + } |
| 43 | + this.onCloseClick(); |
| 44 | + } |
| 45 | +} |
0 commit comments