Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow separate modal edit/delete/sort of Paragraph items #60

Closed
laryn opened this issue Apr 18, 2020 · 9 comments · Fixed by #94
Closed

Allow separate modal edit/delete/sort of Paragraph items #60

laryn opened this issue Apr 18, 2020 · 9 comments · Fixed by #94
Labels
enhancement New feature or request has pr Has a PR or branch for testing.
Milestone

Comments

@laryn
Copy link
Member

laryn commented Apr 18, 2020

I have been meaning to see if I could figure out how to allow editing of individual Paragraph items via contextual link rather than requiring the entire node to be loaded. (For example, if one item way down the page needs a minor tweak, it would be way simpler to be able to edit that one item rather than load the entire page, scroll down to find that paragraph with everything else around it, potentially have to expand that Paragraph item before being able to edit it...)

My idea included opening the edit window in a modal and refreshing the page when it was submitted, but that may not be necessary. It turns out there's an issue (and a patch) in the Drupal queue that aims for very similar functionality (minus the modal). And follow up issues could be the ability to delete/insert Paragraphs in this way, and maybe even reorder (e.g. Move up, Move down).

I've tried to implement that first patch in the issue-60 branch.

The main issue I'm finding seems to be that host entity details aren't being tracked. This causes the access check to fail and the save to fail (Unable to save a paragraph without a valid reference to a host entity.).

I've temporarily adjusted the access check to include a new permission rather than checking whether the user has access to update the host entity, and could override the save not to check the host entity as well (but then we'd lose Paragraph revisions on nodes when edited in this way).

@laryn
Copy link
Member Author

laryn commented Apr 20, 2020

This is the $paragraphs_item entity as loaded in paragraphs_form_edit:
Screen Shot 2020-04-20 at 4 23 23 PM

And here's what it looks like in Drupal 7:
Screen Shot 2020-04-21 at 4 33 35 PM

@laryn
Copy link
Member Author

laryn commented Apr 22, 2020

I've made some progress, I think. I would appreciate anyone with more code experience looking over the changes I'm attempting:

https://github.com/backdrop-contrib/paragraphs/tree/contextual_edit

Right now it seems to work for Nodes, and partially for Taxonomy Terms (ie. it allows edit and save but it duplicates the same Paragraph item every time you save it -- something's off on the delta somewhere).

Comments or feedback welcome!

@laryn
Copy link
Member Author

laryn commented Apr 22, 2020

I think this is functional now. Anyone care to test and/or glance over the code for a quick review?
Tested with Paragraph fields on a node, a taxonomy term, and a user.

When you add the Paragraph field to an entity, this box needs to be checked in order for contextual links to be added:

Screen Shot 2020-04-22 at 12 25 01 AM

@laryn laryn added enhancement New feature or request has pr Has a PR or branch for testing. labels Apr 22, 2020
@laryn laryn added this to the 1.x-1.2.0 milestone Sep 1, 2020
@laryn laryn linked a pull request Nov 20, 2020 that will close this issue
@laryn
Copy link
Member Author

laryn commented Jan 7, 2021

Playing around with an alternate implementation that uses dropbutton instead of contextual link, so there are two separate branches related to this issue:

@laryn laryn changed the title Allow contextual editing of separate Paragraph items Allow separate editing of Paragraph items Mar 18, 2021
@laryn laryn added this to To do in Separate editing - dropbuttons via automation Mar 18, 2021
@laryn laryn moved this from To do to In Progress in Separate editing - dropbuttons Mar 18, 2021
@olafgrabienski
Copy link
Member

I've started to play around with the Dropbutton branch, looks really good at first sight. I like this approach more than the Contextual links approach.

@olafgrabienski
Copy link
Member

olafgrabienski commented Mar 18, 2021

Editing a Paragraph using Dropbuttons, I've encountered a strange behavior:

Upon Edit of a Paragraph, the background color and the Account menu in the header section of the page change their appearance. Looks like the styles are coming from the admin theme. Not sure if it's intended but that's not my issue. The issue is that this appearance remains after saving the Paragraph. (When I reload the page, it changes back to the expected appearance.) See the screenshots below.

(1) View the page

backdrop-paragraphs-1-view

(2) Edit paragraph

backdrop-paragraphs-2-edit

(3) Edited and saved

backdrop-paragraphs-3-edited

@laryn
Copy link
Member Author

laryn commented Mar 18, 2021

@olafgrabienski I'm going to move that into a separate issue related to core bugs: #81

@laryn laryn changed the title Allow separate editing of Paragraph items Allow separate modal edit/delete/sort of Paragraph items Oct 15, 2021
@laryn laryn closed this as completed in #94 Oct 21, 2021
Separate editing - dropbuttons automation moved this from In Progress to Done Oct 21, 2021
@laryn
Copy link
Member Author

laryn commented Oct 21, 2021

I've merged this in for the next alpha pre-release. Open new issues around this feature as you test!

@laryn
Copy link
Member Author

laryn commented Apr 18, 2022

After two alphas and a beta, I think we're at a point where we can do a first formal release that includes this functionality (using dropbutton instead of contextual links). Big thanks to @olafgrabienski for helping me test and to those that did the heavy lifting (using contextual links) in the Drupal 7 thread with patches, testing and feedback, including: @ModulesUnraveled, @darthsteven, jonathanshaw, @iaminawe, Grayle, Nchase, @stevetweeddale, RAFA3L, delacosta456, @PascalMortier, 8bitplateau, Ludo.R, @StryKaizer, jeroen.b, @mirodietiker, @anotherjames, @Nebel54, @martijnhoutman, @vollepeer, @amoebanath, @rgpublic, vaccinemedia, screon, loominade, Alexandre360, reekris, and georgiana-albu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request has pr Has a PR or branch for testing.
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants