Ver Fonte

fully solve #6097, solve #6173

Adam Shaw há 4 anos atrás
pai
commit
826af40594

+ 3 - 1
CHANGELOG.md

@@ -2,8 +2,10 @@
 v5.5.2
 ------
 
+- feature: icalendar events receive URL (#6173)
+- feature: icalendar events receive location, organizer, description in extendedProps (#6097)
 - fix: icalendar recurring events ignoring count rule (#6190)
-- fix: icalendar recurring timed-events with wrong times (#6139)
+- fix: icalendar recurring timed-events with wrong times (#6139, #6106)
 - fix: removed accidental ical.js dependency in common's package.json (#6171)
 - fix: for gcal events, restore extendedProperties (#5083)
 - fix: for gcal events, make attachments available (#5024)

+ 3 - 2
packages/__tests__/src/icalendar/data/alldayEvent.ts

@@ -9,9 +9,10 @@ DTSTART;VALUE=DATE:20190415
 DTSTAMP:20201006T124223Z
 UID:1234578
 CREATED:20190408T110429Z
-DESCRIPTION:
+DESCRIPTION:this is the description
+URL:https://fullcalendar.io/
 LAST-MODIFIED:20190409T110738Z
-LOCATION:
+LOCATION:this is the location
 SEQUENCE:0
 STATUS:CONFIRMED
 SUMMARY:First conference

+ 3 - 2
packages/__tests__/src/icalendar/data/recurringWeekly.ts

@@ -12,9 +12,10 @@ DTSTAMP:20201006T124223Z
 ORGANIZER;CN=Testy McTestface:mailto:[email protected]
 UID:12345678
 CREATED:20181210T150458Z
-DESCRIPTION:
+DESCRIPTION:this is the description
+URL:https://fullcalendar.io/
 LAST-MODIFIED:20190508T170523Z
-LOCATION:
+LOCATION:this is the location
 SEQUENCE:0
 STATUS:CONFIRMED
 SUMMARY:Weekly Monday meeting

+ 13 - 1
packages/__tests__/src/icalendar/day-view.ts

@@ -38,6 +38,12 @@ describe('addICalEventSource with day view', () => {
     loadICalendarWith(recurringWeekly, () => {
       setTimeout(() => {
         assertEventCount(1)
+        const event = currentCalendar.getEvents()[0]
+        // test non-date props
+        expect(event.title).toBe('Weekly Monday meeting')
+        expect(event.url).toBe('https://fullcalendar.io/')
+        expect(event.extendedProps.description).toBe('this is the description')
+        expect(event.extendedProps.location).toBe('this is the location')
         done()
       }, 100)
     })
@@ -47,7 +53,13 @@ describe('addICalEventSource with day view', () => {
     loadICalendarWith(alldayEvent, () => {
       setTimeout(() => {
         assertEventCount(1)
-        currentCalendar.getEvents().forEach((event) => expect(event.allDay).toBeTruthy())
+        const events = currentCalendar.getEvents()
+        events.forEach((event) => expect(event.allDay).toBeTruthy())
+        // test non-date props
+        expect(events[0].title).toBe('First conference')
+        expect(events[0].url).toBe('https://fullcalendar.io/')
+        expect(events[0].extendedProps.description).toBe('this is the description')
+        expect(events[0].extendedProps.location).toBe('this is the location')
         done()
       })
     })

+ 6 - 1
packages/icalendar/src/main.ts

@@ -197,7 +197,7 @@ function expandRecurringEvent(iCalEvent: ICAL.Event, range: DateRange): EventInp
 function buildNonDateProps(iCalEvent: ICAL.Event): EventInput {
   return {
     title: iCalEvent.summary,
-    url: iCalEvent.url,
+    url: extractEventUrl(iCalEvent),
     extendedProps: {
       location: iCalEvent.location,
       organizer: iCalEvent.organizer,
@@ -206,6 +206,11 @@ function buildNonDateProps(iCalEvent: ICAL.Event): EventInput {
   }
 }
 
+function extractEventUrl(iCalEvent: ICAL.Event): string {
+  let urlProp = iCalEvent.component.getFirstProperty('url')
+  return urlProp ? urlProp.getFirstValue() : ''
+}
+
 function specifiesEnd(iCalEvent: ICAL.Event) {
   return Boolean(iCalEvent.component.getFirstProperty('dtend')) ||
     Boolean(iCalEvent.component.getFirstProperty('duration'))