Skip to content

Commit

Permalink
feat(ics.js): Extend API to add events from CalendarEvent instances
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiodrg committed Mar 29, 2022
1 parent 43693c0 commit 3fc3794
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
16 changes: 16 additions & 0 deletions src/js/lib/ics.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,22 @@ var ics = function(uidDomain, prodId) {
return calendarEvent;
},

/**
* Add event to the calendar from an instance of {@link CalendarEvent}
* @param {CalendarEvent} event
*/
'addCalendarEvent': function(event) {
return this.addEvent(
event.title,
event.description,
event.location == null ? "" : event.location,
event.start.toString(),
event.end.toString(),
event.recurRule,
event.status
);
},

/**
* Download calendar using the saveAs function from filesave.js
* @param {string} filename Filename
Expand Down
2 changes: 1 addition & 1 deletion src/js/utils/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function createEventDropdown(event, style) {
// add click action for the ICS download button
$dropdown.querySelector(".donwloadSingleIcs").addEventListener("click", (e) => {
const cal = ics("sigtools"); //create ics instance
cal.addEvent(event.title, event.description, event.location, event.start, event.end, event.recurRule);
cal.addCalendarEvent(event);
cal.download();
});

Expand Down
9 changes: 1 addition & 8 deletions src/js/utils/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,7 @@ function createEventsModal(events, from, to) {
continue;

// Add event to ICS
cal.addEvent(
event.title,
event.description,
event.location || "",
event.start.toString(),
event.end.toString(),
event.recurRule,
);
cal.addCalendarEvent(event);
}

// Downloads the .ics file
Expand Down

0 comments on commit 3fc3794

Please sign in to comment.