diff --git a/src/ical.js.d.ts b/src/ical.js.d.ts index c392add..a87e499 100644 --- a/src/ical.js.d.ts +++ b/src/ical.js.d.ts @@ -11,6 +11,10 @@ declare module 'ical.js' { getFirstProperty(name?: string): Property; getAllProperties(name?: string): Array; + + updatePropertyWithValue(name: string, value: string | number | object): Property; + + addSubcomponent(component: Component): Component; } class Event { @@ -22,6 +26,8 @@ declare module 'ical.js' { location: string; attendees: Array; + component: Component; + constructor(component?: Component | null, options?: {strictExceptions: boolean, exepctions: Array}); } diff --git a/src/pim-types.tsx b/src/pim-types.tsx index 8a53777..c252469 100644 --- a/src/pim-types.tsx +++ b/src/pim-types.tsx @@ -3,6 +3,10 @@ import * as ICAL from 'ical.js'; export class EventType extends ICAL.Event { color: string; + static fromVCalendar(comp: ICAL.Component) { + return new EventType(comp.getFirstSubcomponent('vevent')); + } + get title() { return this.summary; } @@ -15,8 +19,12 @@ export class EventType extends ICAL.Event { return this.endDate.toJSDate(); } - static fromVCalendar(comp: ICAL.Component) { - return new EventType(comp.getFirstSubcomponent('vevent')); + toIcal() { + let comp = new ICAL.Component(['vcalendar', [], []]); + comp.updatePropertyWithValue('prodid', '-//iCal.js EteSync Web'); + + comp.addSubcomponent(this.component); + return comp.toString(); } }