@syncfusion/ej2-schedule 30.2.7 → 31.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ej2-schedule.min.js +2 -2
- package/dist/ej2-schedule.umd.min.js +2 -2
- package/dist/ej2-schedule.umd.min.js.map +1 -1
- package/dist/es6/ej2-schedule.es2015.js +110 -36
- package/dist/es6/ej2-schedule.es2015.js.map +1 -1
- package/dist/es6/ej2-schedule.es5.js +110 -36
- package/dist/es6/ej2-schedule.es5.js.map +1 -1
- package/dist/global/ej2-schedule.min.js +2 -2
- package/dist/global/ej2-schedule.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/dist/ts/common/calendar-util.d.ts +92 -0
- package/dist/ts/common/calendar-util.ts +261 -0
- package/dist/ts/common/index.d.ts +4 -0
- package/dist/ts/common/index.ts +4 -0
- package/dist/ts/components.d.ts +5 -0
- package/dist/ts/components.ts +5 -0
- package/dist/ts/index.d.ts +6 -0
- package/dist/ts/index.ts +7 -0
- package/dist/ts/recurrence-editor/date-generator.d.ts +76 -0
- package/dist/ts/recurrence-editor/date-generator.ts +1699 -0
- package/dist/ts/recurrence-editor/index.d.ts +6 -0
- package/dist/ts/recurrence-editor/index.ts +6 -0
- package/dist/ts/recurrence-editor/recurrence-editor-model.d.ts +112 -0
- package/dist/ts/recurrence-editor/recurrence-editor.d.ts +245 -0
- package/dist/ts/recurrence-editor/recurrence-editor.ts +1257 -0
- package/dist/ts/schedule/actions/action-base.d.ts +44 -0
- package/dist/ts/schedule/actions/action-base.ts +493 -0
- package/dist/ts/schedule/actions/crud.d.ts +41 -0
- package/dist/ts/schedule/actions/crud.ts +784 -0
- package/dist/ts/schedule/actions/data.d.ts +63 -0
- package/dist/ts/schedule/actions/data.ts +128 -0
- package/dist/ts/schedule/actions/drag.d.ts +75 -0
- package/dist/ts/schedule/actions/drag.ts +1401 -0
- package/dist/ts/schedule/actions/keyboard.d.ts +100 -0
- package/dist/ts/schedule/actions/keyboard.ts +1435 -0
- package/dist/ts/schedule/actions/resize.d.ts +27 -0
- package/dist/ts/schedule/actions/resize.ts +602 -0
- package/dist/ts/schedule/actions/scroll.d.ts +69 -0
- package/dist/ts/schedule/actions/scroll.ts +105 -0
- package/dist/ts/schedule/actions/touch.d.ts +32 -0
- package/dist/ts/schedule/actions/touch.ts +314 -0
- package/dist/ts/schedule/actions/virtual-scroll.d.ts +55 -0
- package/dist/ts/schedule/actions/virtual-scroll.ts +596 -0
- package/dist/ts/schedule/actions/work-cells.d.ts +14 -0
- package/dist/ts/schedule/actions/work-cells.ts +151 -0
- package/dist/ts/schedule/base/constant.d.ts +102 -0
- package/dist/ts/schedule/base/constant.ts +103 -0
- package/dist/ts/schedule/base/css-constant.d.ts +475 -0
- package/dist/ts/schedule/base/css-constant.ts +475 -0
- package/dist/ts/schedule/base/interface.d.ts +673 -0
- package/dist/ts/schedule/base/interface.ts +738 -0
- package/dist/ts/schedule/base/resource.d.ts +59 -0
- package/dist/ts/schedule/base/resource.ts +1091 -0
- package/dist/ts/schedule/base/schedule-model.d.ts +930 -0
- package/dist/ts/schedule/base/schedule.d.ts +1967 -0
- package/dist/ts/schedule/base/schedule.ts +4221 -0
- package/dist/ts/schedule/base/type.d.ts +134 -0
- package/dist/ts/schedule/base/type.ts +142 -0
- package/dist/ts/schedule/base/util.d.ts +266 -0
- package/dist/ts/schedule/base/util.ts +492 -0
- package/dist/ts/schedule/event-renderer/agenda-base.d.ts +15 -0
- package/dist/ts/schedule/event-renderer/agenda-base.ts +423 -0
- package/dist/ts/schedule/event-renderer/event-base.d.ts +101 -0
- package/dist/ts/schedule/event-renderer/event-base.ts +1501 -0
- package/dist/ts/schedule/event-renderer/inline-edit.d.ts +23 -0
- package/dist/ts/schedule/event-renderer/inline-edit.ts +287 -0
- package/dist/ts/schedule/event-renderer/month.d.ts +60 -0
- package/dist/ts/schedule/event-renderer/month.ts +760 -0
- package/dist/ts/schedule/event-renderer/timeline-view.d.ts +51 -0
- package/dist/ts/schedule/event-renderer/timeline-view.ts +606 -0
- package/dist/ts/schedule/event-renderer/vertical-view.d.ts +57 -0
- package/dist/ts/schedule/event-renderer/vertical-view.ts +898 -0
- package/dist/ts/schedule/event-renderer/year.d.ts +27 -0
- package/dist/ts/schedule/event-renderer/year.ts +623 -0
- package/dist/ts/schedule/exports/calendar-export.d.ts +16 -0
- package/dist/ts/schedule/exports/calendar-export.ts +160 -0
- package/dist/ts/schedule/exports/calendar-import.d.ts +18 -0
- package/dist/ts/schedule/exports/calendar-import.ts +277 -0
- package/dist/ts/schedule/exports/excel-export.d.ts +14 -0
- package/dist/ts/schedule/exports/excel-export.ts +89 -0
- package/dist/ts/schedule/exports/index.d.ts +7 -0
- package/dist/ts/schedule/exports/index.ts +7 -0
- package/dist/ts/schedule/exports/print.d.ts +20 -0
- package/dist/ts/schedule/exports/print.ts +233 -0
- package/dist/ts/schedule/index.d.ts +26 -0
- package/dist/ts/schedule/index.ts +26 -0
- package/dist/ts/schedule/models/event-settings-model.d.ts +165 -0
- package/dist/ts/schedule/models/event-settings.d.ts +149 -0
- package/dist/ts/schedule/models/event-settings.ts +187 -0
- package/dist/ts/schedule/models/field-options-model.d.ts +37 -0
- package/dist/ts/schedule/models/field-options.d.ts +31 -0
- package/dist/ts/schedule/models/field-options.ts +41 -0
- package/dist/ts/schedule/models/fields-model.d.ts +129 -0
- package/dist/ts/schedule/models/fields.d.ts +117 -0
- package/dist/ts/schedule/models/fields.ts +149 -0
- package/dist/ts/schedule/models/group-model.d.ts +69 -0
- package/dist/ts/schedule/models/group.d.ts +60 -0
- package/dist/ts/schedule/models/group.ts +75 -0
- package/dist/ts/schedule/models/header-rows-model.d.ts +33 -0
- package/dist/ts/schedule/models/header-rows.d.ts +30 -0
- package/dist/ts/schedule/models/header-rows.ts +35 -0
- package/dist/ts/schedule/models/models.d.ts +14 -0
- package/dist/ts/schedule/models/models.ts +15 -0
- package/dist/ts/schedule/models/quick-info-templates-model.d.ts +52 -0
- package/dist/ts/schedule/models/quick-info-templates.d.ts +47 -0
- package/dist/ts/schedule/models/quick-info-templates.ts +56 -0
- package/dist/ts/schedule/models/resources-model.d.ts +122 -0
- package/dist/ts/schedule/models/resources.d.ts +106 -0
- package/dist/ts/schedule/models/resources.ts +138 -0
- package/dist/ts/schedule/models/time-scale-model.d.ts +57 -0
- package/dist/ts/schedule/models/time-scale.d.ts +50 -0
- package/dist/ts/schedule/models/time-scale.ts +61 -0
- package/dist/ts/schedule/models/toolbar-model.d.ts +196 -0
- package/dist/ts/schedule/models/toolbar.d.ts +176 -0
- package/dist/ts/schedule/models/toolbar.ts +196 -0
- package/dist/ts/schedule/models/views-model.d.ts +370 -0
- package/dist/ts/schedule/models/views.d.ts +335 -0
- package/dist/ts/schedule/models/views.ts +408 -0
- package/dist/ts/schedule/models/work-hours-model.d.ts +29 -0
- package/dist/ts/schedule/models/work-hours.d.ts +24 -0
- package/dist/ts/schedule/models/work-hours.ts +31 -0
- package/dist/ts/schedule/popups/event-tooltip.d.ts +16 -0
- package/dist/ts/schedule/popups/event-tooltip.ts +203 -0
- package/dist/ts/schedule/popups/event-window.d.ts +118 -0
- package/dist/ts/schedule/popups/event-window.ts +2055 -0
- package/dist/ts/schedule/popups/form-validator.d.ts +16 -0
- package/dist/ts/schedule/popups/form-validator.ts +110 -0
- package/dist/ts/schedule/popups/quick-popups.d.ts +78 -0
- package/dist/ts/schedule/popups/quick-popups.ts +1470 -0
- package/dist/ts/schedule/renderer/agenda.d.ts +45 -0
- package/dist/ts/schedule/renderer/agenda.ts +497 -0
- package/dist/ts/schedule/renderer/day.d.ts +20 -0
- package/dist/ts/schedule/renderer/day.ts +28 -0
- package/dist/ts/schedule/renderer/header-renderer.d.ts +48 -0
- package/dist/ts/schedule/renderer/header-renderer.ts +736 -0
- package/dist/ts/schedule/renderer/month-agenda.d.ts +29 -0
- package/dist/ts/schedule/renderer/month-agenda.ts +184 -0
- package/dist/ts/schedule/renderer/month.d.ts +61 -0
- package/dist/ts/schedule/renderer/month.ts +766 -0
- package/dist/ts/schedule/renderer/renderer.d.ts +13 -0
- package/dist/ts/schedule/renderer/renderer.ts +165 -0
- package/dist/ts/schedule/renderer/timeline-header-row.d.ts +15 -0
- package/dist/ts/schedule/renderer/timeline-header-row.ts +132 -0
- package/dist/ts/schedule/renderer/timeline-month.d.ts +29 -0
- package/dist/ts/schedule/renderer/timeline-month.ts +184 -0
- package/dist/ts/schedule/renderer/timeline-view.d.ts +31 -0
- package/dist/ts/schedule/renderer/timeline-view.ts +308 -0
- package/dist/ts/schedule/renderer/timeline-year.d.ts +22 -0
- package/dist/ts/schedule/renderer/timeline-year.ts +450 -0
- package/dist/ts/schedule/renderer/vertical-view.d.ts +63 -0
- package/dist/ts/schedule/renderer/vertical-view.ts +911 -0
- package/dist/ts/schedule/renderer/view-base.d.ts +83 -0
- package/dist/ts/schedule/renderer/view-base.ts +709 -0
- package/dist/ts/schedule/renderer/week.d.ts +22 -0
- package/dist/ts/schedule/renderer/week.ts +35 -0
- package/dist/ts/schedule/renderer/work-week.d.ts +22 -0
- package/dist/ts/schedule/renderer/work-week.ts +36 -0
- package/dist/ts/schedule/renderer/year.d.ts +46 -0
- package/dist/ts/schedule/renderer/year.ts +470 -0
- package/dist/ts/schedule/timezone/timezone.d.ts +16 -0
- package/dist/ts/schedule/timezone/timezone.ts +313 -0
- package/package.json +56 -21
- package/src/schedule/actions/action-base.js +3 -0
- package/src/schedule/actions/drag.js +11 -4
- package/src/schedule/actions/keyboard.js +1 -1
- package/src/schedule/actions/resize.js +8 -5
- package/src/schedule/base/css-constant.d.ts +2 -0
- package/src/schedule/base/css-constant.js +2 -0
- package/src/schedule/base/schedule.js +15 -1
- package/src/schedule/event-renderer/agenda-base.d.ts +1 -1
- package/src/schedule/event-renderer/agenda-base.js +5 -4
- package/src/schedule/event-renderer/inline-edit.js +11 -6
- package/src/schedule/event-renderer/month.js +5 -3
- package/src/schedule/event-renderer/vertical-view.js +3 -0
- package/src/schedule/event-renderer/year.d.ts +2 -0
- package/src/schedule/event-renderer/year.js +28 -4
- package/src/schedule/popups/event-tooltip.js +4 -0
- package/src/schedule/popups/event-window.js +2 -2
- package/src/schedule/popups/quick-popups.js +5 -1
- package/src/schedule/renderer/agenda.js +3 -2
- package/src/schedule/renderer/vertical-view.js +1 -1
- package/src/schedule/renderer/year.js +3 -2
- package/styles/bds-lite.css +11 -8
- package/styles/bds.css +11 -8
- package/styles/bootstrap-dark-lite.css +12 -9
- package/styles/bootstrap-dark.css +12 -9
- package/styles/bootstrap-lite.css +12 -9
- package/styles/bootstrap.css +12 -9
- package/styles/bootstrap4-lite.css +11 -8
- package/styles/bootstrap4.css +11 -8
- package/styles/bootstrap5-dark-lite.css +11 -8
- package/styles/bootstrap5-dark.css +11 -8
- package/styles/bootstrap5-lite.css +11 -8
- package/styles/bootstrap5.3-lite.css +11 -8
- package/styles/bootstrap5.3.css +11 -8
- package/styles/bootstrap5.css +11 -8
- package/styles/fabric-dark-lite.css +12 -9
- package/styles/fabric-dark.css +12 -9
- package/styles/fabric-lite.css +12 -9
- package/styles/fabric.css +12 -9
- package/styles/fluent-dark-lite.css +13 -10
- package/styles/fluent-dark.css +13 -10
- package/styles/fluent-lite.css +13 -10
- package/styles/fluent.css +13 -10
- package/styles/fluent2-lite.css +11 -8
- package/styles/fluent2.css +11 -8
- package/styles/highcontrast-light-lite.css +12 -9
- package/styles/highcontrast-light.css +12 -9
- package/styles/highcontrast-lite.css +12 -9
- package/styles/highcontrast.css +12 -9
- package/styles/material-dark-lite.css +12 -9
- package/styles/material-dark.css +12 -9
- package/styles/material-lite.css +12 -9
- package/styles/material.css +12 -9
- package/styles/material3-dark-lite.css +11 -8
- package/styles/material3-dark.css +11 -8
- package/styles/material3-lite.css +11 -8
- package/styles/material3.css +11 -8
- package/styles/recurrence-editor/_bds-definition.scss +1 -0
- package/styles/recurrence-editor/_bootstrap-dark-definition.scss +1 -0
- package/styles/recurrence-editor/_bootstrap-definition.scss +1 -0
- package/styles/recurrence-editor/_bootstrap4-definition.scss +1 -0
- package/styles/recurrence-editor/_bootstrap5-definition.scss +1 -0
- package/styles/recurrence-editor/_bootstrap5.3-definition.scss +1 -0
- package/styles/recurrence-editor/_fabric-dark-definition.scss +1 -0
- package/styles/recurrence-editor/_fabric-definition.scss +1 -0
- package/styles/recurrence-editor/_fluent-definition.scss +1 -0
- package/styles/recurrence-editor/_fluent2-definition.scss +1 -0
- package/styles/recurrence-editor/_fusionnew-definition.scss +1 -0
- package/styles/recurrence-editor/_highcontrast-definition.scss +1 -0
- package/styles/recurrence-editor/_highcontrast-light-definition.scss +1 -0
- package/styles/recurrence-editor/_layout.scss +5 -1
- package/styles/recurrence-editor/_material-dark-definition.scss +1 -0
- package/styles/recurrence-editor/_material-definition.scss +1 -0
- package/styles/recurrence-editor/_material3-definition.scss +1 -0
- package/styles/recurrence-editor/_tailwind-definition.scss +1 -0
- package/styles/recurrence-editor/_tailwind3-definition.scss +1 -0
- package/styles/recurrence-editor/bds.css +3 -0
- package/styles/recurrence-editor/bootstrap-dark.css +4 -1
- package/styles/recurrence-editor/bootstrap.css +4 -1
- package/styles/recurrence-editor/bootstrap4.css +3 -0
- package/styles/recurrence-editor/bootstrap5-dark.css +3 -0
- package/styles/recurrence-editor/bootstrap5.3.css +3 -0
- package/styles/recurrence-editor/bootstrap5.css +3 -0
- package/styles/recurrence-editor/fabric-dark.css +4 -1
- package/styles/recurrence-editor/fabric.css +4 -1
- package/styles/recurrence-editor/fluent-dark.css +4 -1
- package/styles/recurrence-editor/fluent.css +4 -1
- package/styles/recurrence-editor/fluent2.css +3 -0
- package/styles/recurrence-editor/highcontrast-light.css +4 -1
- package/styles/recurrence-editor/highcontrast.css +4 -1
- package/styles/recurrence-editor/material-dark.css +4 -1
- package/styles/recurrence-editor/material.css +4 -1
- package/styles/recurrence-editor/material3-dark.css +3 -0
- package/styles/recurrence-editor/material3.css +3 -0
- package/styles/recurrence-editor/tailwind-dark.css +3 -0
- package/styles/recurrence-editor/tailwind.css +3 -0
- package/styles/recurrence-editor/tailwind3.css +3 -0
- package/styles/schedule/_bds-definition.scss +2 -0
- package/styles/schedule/_bootstrap-dark-definition.scss +2 -0
- package/styles/schedule/_bootstrap-definition.scss +2 -0
- package/styles/schedule/_bootstrap4-definition.scss +2 -0
- package/styles/schedule/_bootstrap5-definition.scss +2 -0
- package/styles/schedule/_bootstrap5.3-definition.scss +2 -0
- package/styles/schedule/_fabric-dark-definition.scss +2 -0
- package/styles/schedule/_fabric-definition.scss +2 -0
- package/styles/schedule/_fluent-definition.scss +3 -1
- package/styles/schedule/_fluent2-definition.scss +2 -0
- package/styles/schedule/_fusionnew-definition.scss +2 -0
- package/styles/schedule/_highcontrast-definition.scss +2 -0
- package/styles/schedule/_highcontrast-light-definition.scss +2 -0
- package/styles/schedule/_layout.scss +12 -11
- package/styles/schedule/_material-dark-definition.scss +2 -0
- package/styles/schedule/_material-definition.scss +2 -0
- package/styles/schedule/_material3-definition.scss +2 -0
- package/styles/schedule/_tailwind-definition.scss +2 -0
- package/styles/schedule/_tailwind3-definition.scss +2 -0
- package/styles/schedule/bds.css +8 -8
- package/styles/schedule/bootstrap-dark.css +8 -8
- package/styles/schedule/bootstrap.css +8 -8
- package/styles/schedule/bootstrap4.css +8 -8
- package/styles/schedule/bootstrap5-dark.css +8 -8
- package/styles/schedule/bootstrap5.3.css +8 -8
- package/styles/schedule/bootstrap5.css +8 -8
- package/styles/schedule/fabric-dark.css +8 -8
- package/styles/schedule/fabric.css +8 -8
- package/styles/schedule/fluent-dark.css +9 -9
- package/styles/schedule/fluent.css +9 -9
- package/styles/schedule/fluent2.css +8 -8
- package/styles/schedule/highcontrast-light.css +8 -8
- package/styles/schedule/highcontrast.css +8 -8
- package/styles/schedule/material-dark.css +8 -8
- package/styles/schedule/material.css +8 -8
- package/styles/schedule/material3-dark.css +8 -8
- package/styles/schedule/material3.css +8 -8
- package/styles/schedule/tailwind-dark.css +8 -8
- package/styles/schedule/tailwind.css +8 -8
- package/styles/schedule/tailwind3.css +8 -8
- package/styles/tailwind-dark-lite.css +11 -8
- package/styles/tailwind-dark.css +11 -8
- package/styles/tailwind-lite.css +11 -8
- package/styles/tailwind.css +11 -8
- package/styles/tailwind3-lite.css +11 -8
- package/styles/tailwind3.css +11 -8
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Schedule } from '../base/schedule';
|
|
2
|
+
/**
|
|
3
|
+
* ICalendar Export Module
|
|
4
|
+
*/
|
|
5
|
+
export declare class ICalendarExport {
|
|
6
|
+
private parent;
|
|
7
|
+
constructor(parent: Schedule);
|
|
8
|
+
initializeCalendarExport(fileName: string, customData: Record<string, any>[]): void;
|
|
9
|
+
getCalendarString(fileName?: string, customData?: Record<string, any>[]): string;
|
|
10
|
+
private customFieldFilter;
|
|
11
|
+
private convertDateToString;
|
|
12
|
+
private download;
|
|
13
|
+
private filterEvents;
|
|
14
|
+
protected getModuleName(): string;
|
|
15
|
+
destroy(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { extend } from '@syncfusion/ej2-base';
|
|
3
|
+
import { EventFieldsMapping } from '../base/interface';
|
|
4
|
+
import { getDateFromRecurrenceDateString, getRecurrenceStringFromDate } from '../../recurrence-editor/date-generator';
|
|
5
|
+
import { Schedule } from '../base/schedule';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ICalendar Export Module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export class ICalendarExport {
|
|
12
|
+
private parent: Schedule;
|
|
13
|
+
constructor(parent: Schedule) {
|
|
14
|
+
this.parent = parent;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public initializeCalendarExport(fileName: string, customData: Record<string, any>[]): void {
|
|
18
|
+
const icsString: string = this.getCalendarString(fileName, customData);
|
|
19
|
+
this.download(icsString, fileName);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public getCalendarString(fileName?: string, customData?: Record<string, any>[]): string {
|
|
23
|
+
let eventsData: Record<string, any>[] = (customData) ? customData :
|
|
24
|
+
extend([], this.parent.eventsData, null, true) as Record<string, any>[];
|
|
25
|
+
eventsData = this.parent.eventBase.sortByTime(eventsData);
|
|
26
|
+
const SEPARATOR: string = (navigator.appVersion.indexOf('Win') !== -1) ? '\r\n' : '\n';
|
|
27
|
+
const iCalendarEvents: string[] = [];
|
|
28
|
+
const filterCollection: Record<string, any>[] = [];
|
|
29
|
+
const timeZone: string = this.parent.timezone || this.parent.tzModule.getLocalTimezoneName();
|
|
30
|
+
const fields: EventFieldsMapping = this.parent.eventFields;
|
|
31
|
+
eventsData.forEach((eventObj: Record<string, any>) => {
|
|
32
|
+
let uId: string = eventObj[fields.id] || eventObj.Guid || this.parent.eventBase.generateGuid();
|
|
33
|
+
const editedExDate: string[] = [];
|
|
34
|
+
if (eventObj[fields.recurrenceID]) {
|
|
35
|
+
const filter: Record<string, any>[] =
|
|
36
|
+
this.filterEvents(filterCollection, fields.id, eventObj[fields.recurrenceID] as number);
|
|
37
|
+
uId = filter.length > 0 ? filter[0].UID as string : uId;
|
|
38
|
+
}
|
|
39
|
+
if (!eventObj[fields.recurrenceID] && eventObj[fields.recurrenceRule] && eventObj[fields.recurrenceException]) {
|
|
40
|
+
const exDate: string[] = ((eventObj[fields.recurrenceException]) as string).split(',');
|
|
41
|
+
const editedObj: Record<string, any>[] =
|
|
42
|
+
this.filterEvents(eventsData, fields.recurrenceID, eventObj[fields.id] as number);
|
|
43
|
+
editedObj.forEach((edited: Record<string, any>) => {
|
|
44
|
+
editedExDate.push(getRecurrenceStringFromDate(edited[fields.startTime] as Date));
|
|
45
|
+
});
|
|
46
|
+
const exceptionDateList: string[] = exDate.filter((value: string) => editedExDate.indexOf(value) === -1);
|
|
47
|
+
eventObj[fields.recurrenceException] = (exceptionDateList.length > 0) ? (exceptionDateList.join(',') + ',') : '';
|
|
48
|
+
}
|
|
49
|
+
const startZone: string = (eventObj[fields.startTimezone] || timeZone) as string;
|
|
50
|
+
const endZone: string = (eventObj[fields.endTimezone] || timeZone) as string;
|
|
51
|
+
const readonly: boolean = (eventObj[fields.isReadonly]) ? (eventObj[fields.isReadonly]) : false;
|
|
52
|
+
const calendarEvent: string[] = [
|
|
53
|
+
'BEGIN:VEVENT',
|
|
54
|
+
'LOCATION:' + (eventObj[fields.location] || ''),
|
|
55
|
+
'SUMMARY:' + (eventObj[fields.subject] || ''),
|
|
56
|
+
'UID:' + uId,
|
|
57
|
+
'DESCRIPTION:' + (eventObj[fields.description] || ''),
|
|
58
|
+
'ISREADONLY:' + readonly,
|
|
59
|
+
'END:VEVENT'
|
|
60
|
+
];
|
|
61
|
+
if (eventObj[fields.isAllDay]) {
|
|
62
|
+
calendarEvent.splice(4, 0, 'DTEND;VALUE=DATE:' + this.convertDateToString(eventObj[fields.endTime] as Date, true));
|
|
63
|
+
calendarEvent.splice(4, 0, 'DTSTART;VALUE=DATE:' + this.convertDateToString(eventObj[fields.startTime] as Date, true));
|
|
64
|
+
} else if (!eventObj[fields.isAllDay] && !eventObj[fields.recurrenceRule]) {
|
|
65
|
+
calendarEvent.splice(4, 0, 'DTEND:' + this.convertDateToString(eventObj[fields.endTime] as Date));
|
|
66
|
+
calendarEvent.splice(4, 0, 'DTSTART:' + this.convertDateToString(eventObj[fields.startTime] as Date));
|
|
67
|
+
} else {
|
|
68
|
+
calendarEvent.splice(4, 0, 'DTEND;TZID="' + endZone + '":' + this.convertDateToString(eventObj[fields.endTime] as Date));
|
|
69
|
+
calendarEvent.splice(4, 0, 'DTSTART;TZID="' + startZone + '":'
|
|
70
|
+
+ this.convertDateToString(eventObj[fields.startTime] as Date));
|
|
71
|
+
}
|
|
72
|
+
if (eventObj[fields.recurrenceRule]) {
|
|
73
|
+
calendarEvent.splice(4, 0, 'RRULE:' + eventObj[fields.recurrenceRule]);
|
|
74
|
+
}
|
|
75
|
+
if (eventObj[fields.recurrenceException]) {
|
|
76
|
+
const exDate: string[] = (eventObj[fields.recurrenceException] as string).split(',');
|
|
77
|
+
for (let i: number = 0; i < exDate.length - 1; i++) {
|
|
78
|
+
calendarEvent.splice(5, 0, 'EXDATE:' +
|
|
79
|
+
this.convertDateToString(
|
|
80
|
+
getDateFromRecurrenceDateString(exDate[parseInt(i.toString(), 10)]), eventObj[fields.isAllDay] as boolean));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (eventObj[fields.recurrenceID]) {
|
|
84
|
+
calendarEvent.splice(4, 0, 'RECURRENCE-ID;TZID="' + startZone + '":'
|
|
85
|
+
+ this.convertDateToString(eventObj[fields.startTime] as Date, eventObj[fields.isAllDay] as boolean));
|
|
86
|
+
}
|
|
87
|
+
const customFields: string[] = this.customFieldFilter(eventObj, fields);
|
|
88
|
+
if (customFields.length > 0) {
|
|
89
|
+
customFields.forEach((customField: string) =>
|
|
90
|
+
calendarEvent.splice(4, 0, customField + ':' + (eventObj[`${customField}`] || ''))
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
const app: Record<string, any> = <Record<string, any>>extend({}, eventObj);
|
|
94
|
+
app.UID = uId;
|
|
95
|
+
filterCollection.push(app);
|
|
96
|
+
iCalendarEvents.push(calendarEvent.join(SEPARATOR));
|
|
97
|
+
|
|
98
|
+
});
|
|
99
|
+
const iCalendar: string = [
|
|
100
|
+
'BEGIN:VCALENDAR',
|
|
101
|
+
'PRODID:-//Syncfusion Inc//Scheduler//EN',
|
|
102
|
+
'VERSION:2.0',
|
|
103
|
+
'CALSCALE:GREGORIAN',
|
|
104
|
+
'METHOD:PUBLISH',
|
|
105
|
+
'X-WR-CALNAME:' + (fileName || 'Calendar'),
|
|
106
|
+
'X-WR-TIMEZONE:' + timeZone
|
|
107
|
+
].join(SEPARATOR);
|
|
108
|
+
const icsString: string = iCalendar + SEPARATOR + iCalendarEvents.join(SEPARATOR) + SEPARATOR + 'END:VCALENDAR';
|
|
109
|
+
return icsString;
|
|
110
|
+
}
|
|
111
|
+
private customFieldFilter(eventObj: Record<string, any>, fields: EventFieldsMapping): string[] {
|
|
112
|
+
const defaultFields: string[] = Object.keys(fields).map((key: string) => (fields as Record<string, any>)[`${key}`]) as string[];
|
|
113
|
+
const eventFields: string[] = Object.keys(eventObj);
|
|
114
|
+
return eventFields.filter((value: string) => (defaultFields.indexOf(value) === -1) && (value !== 'Guid'));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private convertDateToString(eventDate: Date, allDay?: boolean): string {
|
|
118
|
+
const year: string = ('0000' + (eventDate.getFullYear().toString())).slice(-4);
|
|
119
|
+
const month: string = ('00' + ((eventDate.getMonth() + 1).toString())).slice(-2);
|
|
120
|
+
const date: string = ('00' + ((eventDate.getDate()).toString())).slice(-2);
|
|
121
|
+
const hours: string = ('00' + (eventDate.getHours().toString())).slice(-2);
|
|
122
|
+
const minutes: string = ('00' + (eventDate.getMinutes().toString())).slice(-2);
|
|
123
|
+
const seconds: string = ('00' + (eventDate.getSeconds().toString())).slice(-2);
|
|
124
|
+
const timeString: string = (allDay) ? year + month + date : year + month + date + 'T' + hours + minutes + seconds;
|
|
125
|
+
return timeString;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private download(icsString: string, fileName: string): void {
|
|
129
|
+
const buffer: Blob = new Blob([icsString], { type: 'data:text/calendar;charset=utf8' });
|
|
130
|
+
fileName = (fileName || 'Calendar') + '.ics';
|
|
131
|
+
if (navigator.msSaveBlob) {
|
|
132
|
+
navigator.msSaveBlob(buffer, fileName);
|
|
133
|
+
} else {
|
|
134
|
+
const downloadLink: HTMLAnchorElement = document.createElementNS('http://www.w3.org/1999/xhtml', 'a') as HTMLAnchorElement;
|
|
135
|
+
downloadLink.download = fileName;
|
|
136
|
+
downloadLink.href = URL.createObjectURL(buffer);
|
|
137
|
+
const event: MouseEvent = document.createEvent('MouseEvent');
|
|
138
|
+
event.initEvent('click', true, true);
|
|
139
|
+
downloadLink.dispatchEvent(event);
|
|
140
|
+
setTimeout((): void => {
|
|
141
|
+
URL.revokeObjectURL(downloadLink.href);
|
|
142
|
+
downloadLink.href = undefined;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
private filterEvents(data: Record<string, any>[], field: string, value: number): Record<string, any>[] {
|
|
148
|
+
return data.filter((e: Record<string, any>) => e[`${field}`] === value);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
protected getModuleName(): string {
|
|
152
|
+
return 'iCalendarExport';
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public destroy(): void {
|
|
156
|
+
if (!this.parent || this.parent && this.parent.isDestroyed) { return; }
|
|
157
|
+
this.parent = null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Schedule } from '../base/schedule';
|
|
2
|
+
/**
|
|
3
|
+
* ICalendar Import Module
|
|
4
|
+
*/
|
|
5
|
+
export declare class ICalendarImport {
|
|
6
|
+
private parent;
|
|
7
|
+
private allDay;
|
|
8
|
+
constructor(parent: Schedule);
|
|
9
|
+
initializeCalendarImport(fileContent: Blob | string): void;
|
|
10
|
+
private iCalendarParser;
|
|
11
|
+
private updateEventData;
|
|
12
|
+
private processOccurrence;
|
|
13
|
+
private getExcludeDateString;
|
|
14
|
+
private getFormattedString;
|
|
15
|
+
private dateParsing;
|
|
16
|
+
protected getModuleName(): string;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { isNullOrUndefined, extend } from '@syncfusion/ej2-base';
|
|
3
|
+
import { Schedule } from '../base/schedule';
|
|
4
|
+
import { EventFieldsMapping } from '../base/interface';
|
|
5
|
+
import { getRecurrenceStringFromDate } from '../../recurrence-editor/date-generator';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ICalendar Import Module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export class ICalendarImport {
|
|
12
|
+
private parent: Schedule;
|
|
13
|
+
private allDay: boolean = false;
|
|
14
|
+
constructor(parent: Schedule) {
|
|
15
|
+
this.parent = parent;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public initializeCalendarImport(fileContent: Blob | string): void {
|
|
19
|
+
if (fileContent && fileContent instanceof Blob) {
|
|
20
|
+
const fileReader: FileReader = new FileReader();
|
|
21
|
+
fileReader.onload = () => {
|
|
22
|
+
const iCalString: string = fileReader.result as string;
|
|
23
|
+
this.iCalendarParser(iCalString);
|
|
24
|
+
};
|
|
25
|
+
fileReader.readAsText(fileContent as Blob, 'UTF-8');
|
|
26
|
+
} else if (fileContent && typeof fileContent === 'string') {
|
|
27
|
+
this.iCalendarParser(fileContent);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private iCalendarParser(iCalString: string): void {
|
|
32
|
+
let iCalData: Record<string, any> = {
|
|
33
|
+
isEvent: false,
|
|
34
|
+
curEvent: null,
|
|
35
|
+
id: this.parent.eventBase.getEventMaxID(),
|
|
36
|
+
count: 0,
|
|
37
|
+
events: [],
|
|
38
|
+
key: null
|
|
39
|
+
};
|
|
40
|
+
const iStringLength: number = iCalString.length;
|
|
41
|
+
let lastPosition: number = iCalString.search(/[^ \t]/);
|
|
42
|
+
let position: number = lastPosition;
|
|
43
|
+
let iString: string;
|
|
44
|
+
let newlineOffset: number;
|
|
45
|
+
do {
|
|
46
|
+
position = iCalString.indexOf('\n', lastPosition) + 1;
|
|
47
|
+
if (position === 0) {
|
|
48
|
+
position = iStringLength;
|
|
49
|
+
newlineOffset = 0;
|
|
50
|
+
} else if (position > 1 && iCalString[position - 2] === '\r') {
|
|
51
|
+
newlineOffset = 2;
|
|
52
|
+
} else {
|
|
53
|
+
newlineOffset = 1;
|
|
54
|
+
}
|
|
55
|
+
const firstChar: string = iCalString.charAt(lastPosition);
|
|
56
|
+
if (firstChar === ' ' || firstChar === '\n' || firstChar === '\t') {
|
|
57
|
+
iString += iCalString.slice(lastPosition + 1, position - newlineOffset);
|
|
58
|
+
} else {
|
|
59
|
+
if (iString) {
|
|
60
|
+
iCalData = this.updateEventData(iString, iCalData);
|
|
61
|
+
}
|
|
62
|
+
iString = iCalString.slice(lastPosition, position - newlineOffset);
|
|
63
|
+
}
|
|
64
|
+
lastPosition = position;
|
|
65
|
+
} while (position !== iStringLength);
|
|
66
|
+
iString = iString.trim();
|
|
67
|
+
if (iString.length) {
|
|
68
|
+
iCalData = this.updateEventData(iString, iCalData);
|
|
69
|
+
}
|
|
70
|
+
const app: Record<string, any>[] = <Record<string, any>[]>extend([], iCalData.events, null, true);
|
|
71
|
+
this.parent.addEvent(this.processOccurrence(app, iCalData.id));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private updateEventData(iString: string, iCalData: Record<string, any>): Record<string, any> {
|
|
75
|
+
const fields: EventFieldsMapping = this.parent.eventFields;
|
|
76
|
+
const SEPARATOR: string = '\r\n';
|
|
77
|
+
const id: number | string = iCalData.id;
|
|
78
|
+
const events: Array<Record<string, any>> = iCalData.events;
|
|
79
|
+
let isEvent: boolean = iCalData.isEvent;
|
|
80
|
+
let count: number = iCalData.count;
|
|
81
|
+
let curEvent: Record<string, any> = iCalData.curEvent;
|
|
82
|
+
let key: string = iCalData.key;
|
|
83
|
+
if (!isEvent && iString === 'BEGIN:VEVENT') {
|
|
84
|
+
isEvent = true;
|
|
85
|
+
curEvent = {};
|
|
86
|
+
}
|
|
87
|
+
if (isEvent && iString === 'END:VEVENT') {
|
|
88
|
+
isEvent = false;
|
|
89
|
+
events.push(curEvent);
|
|
90
|
+
curEvent = null;
|
|
91
|
+
}
|
|
92
|
+
if (isEvent) {
|
|
93
|
+
const index: number = iString.indexOf(':');
|
|
94
|
+
let type: string = iString.substring(0, index).replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
|
95
|
+
let value: string = iString.substring(index + 1, iString.length).replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
|
96
|
+
if (iString.indexOf('SUMMARY') !== -1) {
|
|
97
|
+
type = 'SUMMARY';
|
|
98
|
+
}
|
|
99
|
+
if (iString.indexOf('DTSTART') !== -1) {
|
|
100
|
+
curEvent[fields.startTime] = this.dateParsing(iString);
|
|
101
|
+
curEvent[fields.isAllDay] = this.allDay;
|
|
102
|
+
this.allDay = false;
|
|
103
|
+
} else if (iString.indexOf('DTEND') !== -1) {
|
|
104
|
+
curEvent[fields.endTime] = this.dateParsing(iString);
|
|
105
|
+
} else if (iString.indexOf('EXDATE') !== -1) {
|
|
106
|
+
value = getRecurrenceStringFromDate(this.dateParsing(iString));
|
|
107
|
+
curEvent[fields.recurrenceException] = isNullOrUndefined(curEvent[fields.recurrenceException]) ?
|
|
108
|
+
value : curEvent[fields.recurrenceException] + ',' + value;
|
|
109
|
+
} else if (iString.indexOf('RECURRENCE-ID') !== -1) {
|
|
110
|
+
value = getRecurrenceStringFromDate(this.dateParsing(iString));
|
|
111
|
+
curEvent[fields.recurrenceException] = value;
|
|
112
|
+
curEvent[fields.recurrenceID] = value;
|
|
113
|
+
} else {
|
|
114
|
+
key = type || key;
|
|
115
|
+
switch (key) {
|
|
116
|
+
case 'BEGIN':
|
|
117
|
+
break;
|
|
118
|
+
case 'UID':
|
|
119
|
+
curEvent[`${type}`] = value;
|
|
120
|
+
if (typeof (id) == 'number') {
|
|
121
|
+
curEvent[fields.id] = parseInt(value, 10);
|
|
122
|
+
if (isNaN(curEvent[fields.id])) {
|
|
123
|
+
curEvent[fields.id] = id + count;
|
|
124
|
+
count++;
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
curEvent[fields.id] = value;
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
case 'SUMMARY':
|
|
131
|
+
curEvent[fields.subject] = this.getFormattedString(value);
|
|
132
|
+
break;
|
|
133
|
+
case 'LOCATION':
|
|
134
|
+
curEvent[fields.location] = this.getFormattedString(value);
|
|
135
|
+
break;
|
|
136
|
+
case 'DESCRIPTION':
|
|
137
|
+
if (curEvent[fields.description]) {
|
|
138
|
+
curEvent[fields.description] = this.getFormattedString(curEvent[fields.description] + SEPARATOR + value);
|
|
139
|
+
} else {
|
|
140
|
+
curEvent[fields.description] = this.getFormattedString(value);
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
case 'ISREADONLY':
|
|
144
|
+
curEvent[fields.isReadonly] = (value.indexOf('true') > -1);
|
|
145
|
+
break;
|
|
146
|
+
case 'RRULE':
|
|
147
|
+
curEvent[fields.recurrenceRule] = value;
|
|
148
|
+
break;
|
|
149
|
+
default:
|
|
150
|
+
if (this.parent.resourceCollection.length > 0) {
|
|
151
|
+
const resData: Record<string, any>[] =
|
|
152
|
+
this.parent.resourceCollection.filter((data: Record<string, any>) => data.field === type);
|
|
153
|
+
curEvent[`${type}`] = (resData.length > 0 && (typeof (resData[0].dataSource[0][resData[0].idField]) == 'number')) ? parseInt(value, 10) : value;
|
|
154
|
+
} else {
|
|
155
|
+
curEvent[`${type}`] = value;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return { isEvent, curEvent, id, count, events, key };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
private processOccurrence(app: Record<string, any>[], maxId: number | string): Record<string, any>[] {
|
|
164
|
+
const appoint: Record<string, any>[] = [];
|
|
165
|
+
const uId: string = 'UID';
|
|
166
|
+
const fields: EventFieldsMapping = this.parent.eventFields;
|
|
167
|
+
const appointmentIds: number[] = [];
|
|
168
|
+
this.parent.eventsData.forEach((eventObj: Record<string, any>) => {
|
|
169
|
+
appointmentIds.push(eventObj[fields.id]);
|
|
170
|
+
});
|
|
171
|
+
app.forEach((eventObj: Record<string, any>) => {
|
|
172
|
+
let parentObj: Record<string, any>;
|
|
173
|
+
let id: number | string;
|
|
174
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
175
|
+
if (!eventObj.hasOwnProperty(fields.recurrenceID)) {
|
|
176
|
+
parentObj = eventObj;
|
|
177
|
+
id = eventObj[fields.id] as string;
|
|
178
|
+
}
|
|
179
|
+
if (appointmentIds.indexOf(eventObj[fields.id]) < 0) {
|
|
180
|
+
const data: Record<string, any>[] = app.filter((data: Record<string, any>) => data.UID === eventObj[`${uId}`]);
|
|
181
|
+
if (data.length > 1 && isNullOrUndefined(eventObj[fields.recurrenceID])) {
|
|
182
|
+
id = typeof (maxId) === 'number' ? maxId++ : id;
|
|
183
|
+
for (let i: number = 0; i < data.length; i++) {
|
|
184
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
185
|
+
if (data[parseInt(i.toString(), 10)].hasOwnProperty(fields.recurrenceID)) {
|
|
186
|
+
const exdate: string = data[parseInt(i.toString(), 10)][fields.recurrenceID] as string;
|
|
187
|
+
data[parseInt(i.toString(), 10)][fields.id] = typeof (maxId) === 'number' ? maxId++ : this.parent.eventBase.generateGuid();
|
|
188
|
+
data[parseInt(i.toString(), 10)][fields.recurrenceID] = id;
|
|
189
|
+
data[parseInt(i.toString(), 10)][fields.recurrenceException] = null;
|
|
190
|
+
parentObj[fields.recurrenceException] =
|
|
191
|
+
this.getExcludeDateString(parentObj[fields.recurrenceException], exdate);
|
|
192
|
+
delete data[parseInt(i.toString(), 10)][`${uId}`];
|
|
193
|
+
appoint.push(data[parseInt(i.toString(), 10)]);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
delete parentObj[`${uId}`];
|
|
197
|
+
parentObj[fields.id] = id;
|
|
198
|
+
appoint.push(parentObj);
|
|
199
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
200
|
+
} else if (!eventObj.hasOwnProperty(fields.recurrenceID)) {
|
|
201
|
+
delete eventObj[`${uId}`];
|
|
202
|
+
eventObj[fields.id] = typeof (maxId) === 'number' ? maxId++ : id;
|
|
203
|
+
appoint.push(eventObj);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
return appoint;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
private getExcludeDateString(parentException: string, occurrenceException: string): string {
|
|
211
|
+
if (isNullOrUndefined(parentException)) {
|
|
212
|
+
return occurrenceException;
|
|
213
|
+
} else if (isNullOrUndefined(occurrenceException)) {
|
|
214
|
+
return parentException;
|
|
215
|
+
}
|
|
216
|
+
const parentExDate: string[] = parentException.split(',').map((x: string) => x.split('T')[0]);
|
|
217
|
+
const childExDate: string[] = occurrenceException.split(',').map((x: string) => x.split('T')[0]);
|
|
218
|
+
const exDate: string[] = parentExDate.filter((x: string) => childExDate.indexOf(x) > -1);
|
|
219
|
+
if (exDate.length > 0) {
|
|
220
|
+
return parentException;
|
|
221
|
+
}
|
|
222
|
+
return parentException + ',' + occurrenceException;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private getFormattedString(value: string): string {
|
|
226
|
+
value = value || '';
|
|
227
|
+
// eslint-disable-next-line no-useless-escape
|
|
228
|
+
return (value.replace(/\\\,/g, ',').replace(/\\\;/g, ';').replace(/\\[nN]/g, '\n').replace(/\\\\/g, '\\'));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
private dateParsing(element: string): Date {
|
|
232
|
+
const split: string[] = element.split(':');
|
|
233
|
+
const value: string = split[split.length - 1];
|
|
234
|
+
let newDate: Date = new Date(this.getFormattedString(value));
|
|
235
|
+
if (element && (element.indexOf('VALUE=DATE') > -1 || element.indexOf('RECURRENCE-ID;TZID') > -1)) {
|
|
236
|
+
const data: string[] = /^(\d{4})(\d{2})(\d{2})$/.exec(value);
|
|
237
|
+
if (data !== null) {
|
|
238
|
+
newDate = new Date(parseInt(data[1], 10), parseInt(data[2], 10) - 1, parseInt(data[3], 10));
|
|
239
|
+
}
|
|
240
|
+
if (element.indexOf('DTSTART') > -1) {
|
|
241
|
+
this.allDay = true;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
const data: string[] = /^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})(Z)?$/.exec(value);
|
|
245
|
+
if (data !== null) {
|
|
246
|
+
if (data[7] === 'Z') {
|
|
247
|
+
newDate = new Date(Date.UTC(
|
|
248
|
+
parseInt(data[1], 10),
|
|
249
|
+
parseInt(data[2], 10) - 1,
|
|
250
|
+
parseInt(data[3], 10),
|
|
251
|
+
parseInt(data[4], 10),
|
|
252
|
+
parseInt(data[5], 10),
|
|
253
|
+
parseInt(data[6], 10)
|
|
254
|
+
));
|
|
255
|
+
} else {
|
|
256
|
+
newDate = new Date(
|
|
257
|
+
parseInt(data[1], 10),
|
|
258
|
+
parseInt(data[2], 10) - 1,
|
|
259
|
+
parseInt(data[3], 10),
|
|
260
|
+
parseInt(data[4], 10),
|
|
261
|
+
parseInt(data[5], 10),
|
|
262
|
+
parseInt(data[6], 10)
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return newDate;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
protected getModuleName(): string {
|
|
270
|
+
return 'iCalendarImport';
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
public destroy(): void {
|
|
274
|
+
if (!this.parent || this.parent && this.parent.isDestroyed) { return; }
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Schedule } from '../base/schedule';
|
|
2
|
+
import { ExportOptions } from '../base/interface';
|
|
3
|
+
/**
|
|
4
|
+
* Excel Export Module
|
|
5
|
+
*/
|
|
6
|
+
export declare class ExcelExport {
|
|
7
|
+
private parent;
|
|
8
|
+
constructor(parent: Schedule);
|
|
9
|
+
initializeExcelExport(excelExportOptions?: ExportOptions): void;
|
|
10
|
+
private processWorkbook;
|
|
11
|
+
private getExportColumns;
|
|
12
|
+
protected getModuleName(): string;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { Workbook, Worksheet, Worksheets, Column } from '@syncfusion/ej2-excel-export';
|
|
3
|
+
import { Schedule } from '../base/schedule';
|
|
4
|
+
import { ExcelFormat } from '../base/type';
|
|
5
|
+
import { ExcelExportEventArgs, ExportFieldInfo, ExportOptions } from '../base/interface';
|
|
6
|
+
import { extend, isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
7
|
+
import * as events from '../base/constant';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Excel Export Module
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export class ExcelExport {
|
|
14
|
+
private parent: Schedule;
|
|
15
|
+
|
|
16
|
+
constructor(parent: Schedule) {
|
|
17
|
+
this.parent = parent;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public initializeExcelExport(excelExportOptions: ExportOptions = {}): void {
|
|
21
|
+
const exportColumns: ExportFieldInfo[] = this.getExportColumns(excelExportOptions);
|
|
22
|
+
const exportName: string = excelExportOptions.fileName || 'Schedule';
|
|
23
|
+
const exportType: ExcelFormat = excelExportOptions.exportType || 'xlsx';
|
|
24
|
+
const isIncludeOccurrences: boolean = excelExportOptions.includeOccurrences || false;
|
|
25
|
+
let separator: string;
|
|
26
|
+
if (!isNullOrUndefined(excelExportOptions.separator) && excelExportOptions.separator !== ',') {
|
|
27
|
+
separator = excelExportOptions.separator;
|
|
28
|
+
}
|
|
29
|
+
let eventCollection: Record<string, any>[];
|
|
30
|
+
if (excelExportOptions.customData) {
|
|
31
|
+
eventCollection = !isIncludeOccurrences ? excelExportOptions.customData :
|
|
32
|
+
this.parent.eventBase.getProcessedEvents(excelExportOptions.customData);
|
|
33
|
+
} else {
|
|
34
|
+
eventCollection = !isIncludeOccurrences ? this.parent.eventsData : this.parent.eventsProcessed;
|
|
35
|
+
}
|
|
36
|
+
this.processWorkbook(exportColumns, exportName, exportType, eventCollection, separator);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private processWorkbook(fields: ExportFieldInfo[], name: string, type: ExcelFormat, eventCollection: Record<string, any>[],
|
|
40
|
+
separator: string): void {
|
|
41
|
+
const columns: Column[] = [];
|
|
42
|
+
const rows: Record<string, any>[] = [];
|
|
43
|
+
const columnHeader: Record<string, any>[] = [];
|
|
44
|
+
fields.forEach((field: ExportFieldInfo, i: number) => { columns.push({ index: i + 1, width: (field.name === 'Id' ? 50 : 150) }); });
|
|
45
|
+
const style: Record<string, any> = { fontSize: 12, borders: { color: '#E0E0E0' }, bold: true };
|
|
46
|
+
fields.forEach((field: ExportFieldInfo, i: number) => { columnHeader.push({ index: i + 1, value: field.text, style: style }); });
|
|
47
|
+
rows.push({ index: 1, cells: columnHeader });
|
|
48
|
+
eventCollection.forEach((event: Record<string, any>, i: number) => {
|
|
49
|
+
const columnData: Record<string, any>[] = [];
|
|
50
|
+
fields.forEach((field: ExportFieldInfo, n: number) => {
|
|
51
|
+
let columnRule: Record<string, any> = { index: n + 1, value: event[field.name] || '' };
|
|
52
|
+
if (field.name === this.parent.eventFields.startTime || field.name === this.parent.eventFields.endTime) {
|
|
53
|
+
const styleRule: Record<string, any> = { fontSize: 12, numberFormat: 'm/d/yyyy h:mm a' };
|
|
54
|
+
columnRule = extend({}, columnRule, { style: styleRule }, true) as Record<string, any>;
|
|
55
|
+
}
|
|
56
|
+
columnData.push(columnRule);
|
|
57
|
+
});
|
|
58
|
+
rows.push({ index: i + 2, cells: columnData });
|
|
59
|
+
});
|
|
60
|
+
const workSheet: Worksheets = [{ columns: columns, rows: rows } as Worksheet];
|
|
61
|
+
const args: ExcelExportEventArgs = { cancel: false, worksheets: workSheet };
|
|
62
|
+
this.parent.trigger(events.excelExport, args, (args: ExcelExportEventArgs) => {
|
|
63
|
+
if (args.cancel) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const book: Workbook = new Workbook({ worksheets: args.worksheets }, type, this.parent.locale, undefined, separator);
|
|
67
|
+
book.save(name + '.' + type);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private getExportColumns(exportOptions: ExportOptions): ExportFieldInfo[] {
|
|
72
|
+
const exportColumns: ExportFieldInfo[] = exportOptions.fieldsInfo || [];
|
|
73
|
+
if (exportColumns.length === 0) {
|
|
74
|
+
const fields: string[] = exportOptions.fields || Object.keys(this.parent.eventFields).map((field: string) =>
|
|
75
|
+
(<Record<string, any>>this.parent.eventFields)[`${field}`]) as string[];
|
|
76
|
+
fields.forEach((field: string) => { exportColumns.push({ name: field, text: field }); });
|
|
77
|
+
}
|
|
78
|
+
return exportColumns;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
protected getModuleName(): string {
|
|
82
|
+
return 'excelExport';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public destroy(): void {
|
|
86
|
+
this.parent = null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Schedule } from '../base/schedule';
|
|
2
|
+
import { ScheduleModel } from '../base/schedule-model';
|
|
3
|
+
/**
|
|
4
|
+
* Print Module
|
|
5
|
+
*/
|
|
6
|
+
export declare class Print {
|
|
7
|
+
private parent;
|
|
8
|
+
private printInstance;
|
|
9
|
+
private printWindow;
|
|
10
|
+
constructor(parent: Schedule);
|
|
11
|
+
print(printOptions?: ScheduleModel): void;
|
|
12
|
+
private printScheduler;
|
|
13
|
+
private printSchedulerWithModel;
|
|
14
|
+
private getPrintScheduleModel;
|
|
15
|
+
private contentReady;
|
|
16
|
+
private closePrintWindow;
|
|
17
|
+
private printCleanup;
|
|
18
|
+
protected getModuleName(): string;
|
|
19
|
+
destroy(): void;
|
|
20
|
+
}
|