From 7b0b6866498a0339c81117080cb2eabd131ef4fc Mon Sep 17 00:00:00 2001 From: Andrii Rublov Date: Fri, 5 Apr 2024 15:19:36 +0200 Subject: [PATCH] calendar/issue/4128 : Feature: added between calendars patterns on events --- src/models/calendar.js | 4 +++- src/parser.js | 22 ++++++++++++++++++++++ src/propset/calendarPropSet.js | 7 +++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/models/calendar.js b/src/models/calendar.js index 93d2ee6a..08684954 100644 --- a/src/models/calendar.js +++ b/src/models/calendar.js @@ -66,6 +66,7 @@ export class Calendar extends davCollectionPublishable(davCollectionShareable(Da super._exposeProperty('order', NS.APPLE, 'calendar-order', true); super._exposeProperty('timezone', NS.IETF_CALDAV, 'calendar-timezone', true); super._exposeProperty('components', NS.IETF_CALDAV, 'supported-calendar-component-set'); + super._exposeProperty('pattern', NS.NEXTCLOUD, 'calendar-pattern', true); } /** @@ -293,7 +294,8 @@ export class Calendar extends davCollectionPublishable(davCollectionShareable(Da [NS.OWNCLOUD, 'calendar-enabled'], [NS.NEXTCLOUD, 'owner-displayname'], [NS.NEXTCLOUD, 'trash-bin-retention-duration'], - [NS.NEXTCLOUD, 'deleted-at'] + [NS.NEXTCLOUD, 'deleted-at'], + [NS.NEXTCLOUD, 'calendar-pattern'] ]); } diff --git a/src/parser.js b/src/parser.js index 37521651..1caab6f7 100644 --- a/src/parser.js +++ b/src/parser.js @@ -195,6 +195,7 @@ export default class Parser { this.registerParser('{http://owncloud.org/ns}read-only', Parser.bool); this.registerParser('{http://nextcloud.com/ns}owner-displayname', Parser.text); this.registerParser('{http://nextcloud.com/ns}deleted-at', Parser.iso8601DateTime); + this.registerParser('{http://nextcloud.com/ns}calendar-pattern', Parser.text); this.registerParser('{http://nextcloud.com/ns}calendar-uri', Parser.text); this.registerParser('{http://nextcloud.com/ns}has-photo', Parser.bool); this.registerParser('{http://nextcloud.com/ns}trash-bin-retention-duration', Parser.decInt); @@ -548,6 +549,27 @@ export default class Parser { return text; } + /** + * Parses a {http://apple.com/ns/ical/}calendar-color Node + * strips the alpha value of RGB values + * + * @param {Document} document + * @param {Node} node + * @param {XPathNSResolver} resolver + * @returns {String} + */ + static pattern(document, node, resolver) { + const text = Parser.text(document, node, resolver); + // some stupid clients store an alpha value in the rgb hash (like #rrggbbaa) *cough cough* Apple Calendar *cough cough* + // but some browsers can't parse that *cough cough* Safari 9 *cough cough* + // Safari 10 seems to support this though + // if (text.length === 9) { + // return text.slice(0, 7); + // } + + return text; + } + /** * Parses a {http://calendarserver.org/ns/}allowed-sharing-modes Node * diff --git a/src/propset/calendarPropSet.js b/src/propset/calendarPropSet.js index 5aaabfe4..890a6c53 100644 --- a/src/propset/calendarPropSet.js +++ b/src/propset/calendarPropSet.js @@ -55,6 +55,13 @@ export default function calendarPropSet(props) { }); break; + case '{http://nextcloud.com/ns}calendar-pattern': + xmlified.push({ + name: [NS.NEXTCLOUD, 'calendar-pattern'], + value: value + }); + break; + case '{http://calendarserver.org/ns/}source': xmlified.push({ name: [NS.CALENDARSERVER, 'source'],