- Issue created by @yobottehg
- 🇮🇪Ireland lostcarpark
I have confirmed the Edit and Delete links aren't working on the view, and the header isn't working.
The header link is a problem, and causes issues for translation. See 🐛 SID 2776211 contains div element Needs review . I think the best thing would be to move the header out of the view and have the controller place it directly in the render array.
I'll have a look at the third problem. It sounds like it could be a bigger problem than just the view.
I agree more test cases would be desirable.
- 🇮🇪Ireland lostcarpark
@yobottehg have you tried to build a view that works for revisions of published nodes?
- 🇨🇭Switzerland yobottehg Basel
@lostcarpark
have you tried to build a view that works for revisions of published nodes?
Not yet but there is a working view for that in core with the content_moderation module and it's "moderated content" view.
You can find it in
core/modules/content_moderation/config/optional/views.view.moderated_content.yml
- 🇮🇪Ireland lostcarpark
Thanks, @yobottehg.
I'll take a look at that view. Hopefully, I can copy it to the new version of the Scheduled Publish view.
I'm still trying to figure out why the "delta" field is not available to the view. It seems to also be causing a problem on the edit form, even when I manually craft a URL with the correct delta value. Will continue to investigate.
- 🇮🇪Ireland lostcarpark
The problem seems to be that the
delta
field from the scheduled publish field table is not in the$data
array passed into thescheduled_publish_views_data_alter
hook.This is the code that should add the delta field to the view data:
if (isset($data[$field_table]['delta'])) { $data['scheduled_publish_dynamic']['delta'] = $data[$field_table]['delta']; $data['scheduled_publish_dynamic']['delta']['title'] = 'Scheduled publish dynamic (delta)'; $data['scheduled_publish_dynamic']['delta']['title short'] = 'SP dynamic (delta)'; }
I'm having trouble understanding why this is the case, but I'm still investigating.
- 🇮🇪Ireland lostcarpark
@yobottehg, I have set up a new issue for issue 3.
However, I'm not quite clear on how to schedule a new revision while keeping the current version published, as it's not functionality I've personally used. Could you update 🐛 Provided view config does not work as expected - Unpublished forward revision not shown Needs work and add steps to reproduce, please?
- 🇮🇪Ireland lostcarpark
If anyone can help review related issue 🐛 SID 2776211 contains div element Needs review , it would be appreciated.
- 🇮🇪Ireland lostcarpark
Some progress on the Edit and Delete links...
I've been the
$data
array passed intoscheduled_publish_views_data_alter
, and I noticed thefield_tags
field has a delta property, but the scheduled publish field doesn't. I realised that the Tags field is a multi-value field.So I created a multi-value scheduled publish field, and checked in the debugger, and the delta property was there.
I also checked the Scheduled Publish view when the scheduled publish field is a multi-value field. The view works fine in that case, and the Edit and Delete links work correctly.
I can see 3 ways forward:
- Change nothing, and just update the documentation to say the scheduled publish field should be a multi-value field.
- update the
buildForm
methods of theEditUpdateForm
andDeleteUpdateForm
classes detect when null is passed in, and substitute the correct value. - Make a change to the
scheduled_publish_views_data_alter
hook to put a fake delta field in the view if the delta property is not in the$data
array.
I don't think 1 is an acceptable solution, as I think many sites only need to schedule 1 state change in advance.
3 would be appealing, as it should mean the view would never show an invalid field. However, I'll have to see if it's feasible. 2 and 3 should both have the same result for non-technical users.
Thoughts and suggestions appreciated.
- Status changed to Needs work
over 1 year ago 11:40pm 15 September 2023 - Status changed to Needs review
about 1 year ago 4:04pm 13 October 2023 - 🇬🇧United Kingdom andy_w
It strikes me that I must have missed something, but it seems like extracting the other associated issues we are left with the fact that the edit / delete links do not currently work if the field is not a multi value element (i.e. it has no delta). Would an adequate solution to this be the assignment of a delta of 0, as this appears to allow the editing/deleting of the scheduled instance.
Apologies if I have misunderstood the ticket.
- 🇮🇪Ireland lostcarpark
That looks a nice, simple solution.
I would like to see some test coverage, however.
I'll look at moving to a MR and adding a test.