Skip to content

Conversation

@moritz-schuessler
Copy link

Added the option to change the parent calendar name if wanted.(#366)

Additional Changes

  • Optional Arguments in Object instead of Array (makes Future development easier)

Why

  • Some calendars don't have a Calendar Name or the names can't be changed by a user. This PR enables Users to change the Parent Calendar name, when they want the 'new' Events to be prefixed.

Comment on lines +39 to +43
colorId: "1",
calendarName: 'Parent Calendar Name 1'
}],
["icsUrl2", "targetCalendar2", {
calendarName: 'Parent Calendar Name 2'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use proper ical property names here:
colorId -> color
calendarName -> name

https://www.rfc-editor.org/rfc/rfc5545
https://www.rfc-editor.org/rfc/rfc7986

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also need to change 2x parentCal to name at line 460++

Comment on lines +217 to +225
var colorId = itm[1] && itm[1].colorId
var allEvents = component.getAllSubcomponents("vevent");
if (colorId != undefined)
allEvents.forEach(function(event){event.addPropertyWithValue("color", colorId);});

var calName = component.getFirstPropertyValue("x-wr-calname") || component.getFirstPropertyValue("name");
if (calName != null)
allEvents.forEach(function(event){event.addPropertyWithValue("parentCal", calName); });
var calName = (itm[1] && itm[1].calendarName) || component.getFirstPropertyValue("x-wr-calname") || component.getFirstPropertyValue("name");
if (calName != null) {
component.getAllSubcomponents("vevent").forEach(function(event){event.addPropertyWithValue("parentCal", calName); });
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In preparation of future changes, let's make this less 'hardcoded'.
I'd suggest

let overrides = itm[1];
let allEvents = component.getAllSubcomponents("vevent");
let calName = component.getFirstPropertyValue("x-wr-calname") || component.getFirstPropertyValue("name");
if (calName != null)
  allEvents.forEach(function(event){event.addPropertyWithValue("name", calName); });

if (overrides){
  Logger.log(`Applying ${Object.keys(overrides).length} override(s)`);
  allEvents.forEach(function(event){
    for(let overrideProp in overrides){
      event.updatePropertyWithValue(overrideProp, overrides[overrideProp]);
    }
  });
}

@moritz-schuessler
Copy link
Author

I will update and finish this PR once the new config change is merged into main

@jonas0b1011001 jonas0b1011001 linked an issue May 26, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow alternate calendar name to be prepended to title

2 participants