Problem/Motivation
In the related issue about missing contextual links, there is a fix that adds contextual links for editing and deleting events series and event instances. To build on this, it would be great to also have a contextual link to edit the event series from a event instance. In my use case, I am generally trying to discourage editing individual event instances. If there are changes that should be made to event instances, then the event series will need to be edited much of the time. Changes made in the other issue allow contextual links to be visible at all. Additional changes here should build on those changes to add a new custom contextual link.
Proposed resolution
Add a contextual link to edit the event series from an event instance.
Issue fork recurring_events-3575567
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mlncn commentedI feel this is a bit harder/weirder than it should be in Drupal but seems there is no way to alter the parameter for a contextual link (we need to get the eventseries ID from the eventinstance) and the only way to add an additional parameter is like this:
Add a
src/EventInstanceViewBuilder.phpwith:Untested but it should be something like that.
And then all it should take is the addition of an eventseries entry with the existing eventseries route to the eventinstance group in the contextual links yaml file added in #3575563: Entities should display contextual links
Comment #3
megakeegman commentedIn https://www.drupal.org/node/3575563, @chrisla noted their preference that the presence of this custom contextual link be controlled by some kind of module setting. In some use cases, while certain roles may be allowed to edit an event series, doing so is still heavily discouraged.
Comment #6
nickolajPatch adds a custom EventInstanceViewBuilder that passes the event series ID to the contextual links system, a contextual link YAML definition for "Edit event series" under the eventinstance group, a configurable setting (enabled by default) at Event Instance Settings to toggle the link visibility, and template updates to support contextual links rendering. Related to #3575563.
Comment #7
plopescThe idea behind this issue makes sense to me.
Added a few comments regarding the implementation approach that might make the code slightly more compact.
Some tests tests to support this new feature would be highly appreciated.
Regarding the ability to enable or disable the link from the settings from , I'm not sure if this is something that the module should take care of.
Comment #9
megakeegman commentedI opened a new MR since a rebase and force push were required, and I wasn't sure how rebasing would affect the existing comments on the MR. I haven't run the test yet, but it shouldn't pass yet as no events have been created. I am happy to continue on it later, but if you have tips on handling programmatic creation of an event series with instances (for testing purposes) that would be handy.
In MR 195, I did remove configuration settings, and I renamed the new contextual link (in the contextual links yml) so that it would not conflict with the contextual link that was recently added.
Comment #10
megakeegman commentedI also just noticed that my test failed in the pipeline because the route that I provided for the view does not exist: view.recurring_events_event_instances.events_listing
Will have to look into that to see what I did wrong.
UPDATE: probably just need to install the submodule for views to use this.
Comment #11
megakeegman commentedOkay we have moved on to new test errors. This one seems a bit more underlying: There was 1 error: