Provided view config does not work as expected - Edit and Delete links broken.

Created on 31 August 2023, over 1 year ago
Updated 14 October 2023, about 1 year ago

Hello,

the provided view config has some issues and is perhaps outdated a bit?

Maintainer note: There are three separate issues here. If just rerolling the view would fix them all, it would make sense to bundle them together, but I think there's more to it than that, so I'm only looking at the first one other this issue, and will look at 2 and 3 under separate issues.

  1. When installed, the delta computed field is broken and therefore the edit and delete links do not work on the view.
  2. The exported text format for the header link is not a standard text format. See https://www.drupal.org/project/scheduled_publish/issues/3212359 🐛 Schedule Publish view referencing incorrect text_format. Active .
    This issue is being fixed under 🐛 SID 2776211 contains div element Needs review
  3. If the scheduled publish field content is on a unpublished forward revision draft of an already published entity it is not displayed on the view.
    This issue is being looked at under 🐛 Provided view config does not work as expected - Unpublished forward revision not shown Needs work

Perhaps the view should be exported again so that the delta field is working and some more test cases could be added to cover the unpublished forward revisions?

📌 Task
Status

Needs review

Version

3.0

Component

Code

Created by

🇨🇭Switzerland yobottehg Basel

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • 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 the scheduled_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 into scheduled_publish_views_data_alter, and I noticed the field_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:

    1. Change nothing, and just update the documentation to say the scheduled publish field should be a multi-value field.
    2. update the buildForm methods of the EditUpdateForm and DeleteUpdateForm classes detect when null is passed in, and substitute the correct value.
    3. 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
  • Status changed to Needs review about 1 year ago
  • 🇬🇧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.

Production build 0.71.5 2024