Closed (fixed)
Project:
Layout Paragraphs
Version:
2.0.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
2 Apr 2021 at 11:35 UTC
Updated:
6 Jan 2022 at 05:44 UTC
Jump to comment: Most recent

Comments
Comment #2
mrpauldriver commentedComment #3
mrpauldriver commentedComment #4
mrpauldriver commentedComment #5
emont88 commentedI would love this feature too. Not sure if I can offer much on the coding side but I'm certainly willing to help test.
Comment #6
justin2pin commentedThanks for this - I bet this feature would benefit a number of users out there. I wonder if we could implement this kind of thing as a separate module, though, that extends LP. Perhaps a simple form_alter to add the duplicate button, with the necessary submit hooks to make it happen?
I'd be happy to review a patch or answer any questions about the API that took this in that direction.
Comment #7
mrpauldriver commentedIt needs to be in there Justin. Not a submodule, just baked in. If just a form alter then fairly straightforward?
Sorry but I'm not a coder, so can't I provide a patch, but I'm most definitely a 'Road to Damascus' convert to Layout Paragraphs.
Brilliant module which takes Drupal forward a long way. I'm sure others will agree.
Comment #8
mrpauldriver commentedThe main question in my mind is whether this feature request should apply only to paragraphs, and not to layout paragraphs?
I suspect that layout paragraphs and all the recursive nonsense that would follow might be a step too far.
Comment #9
johnpitcairn commentedHow about if, instead of it being next to edit/delete, the add paragraph (+) popup included a duplicate this [paragraph type] option? That would allow the user to duplicate above or below in one step.
Comment #10
alemadlei@justin2pin if you provide me some quick guidelines about which files to update or what to modify and what to set, I could try coding this, as this is a feature recently requested to me.
Comment #11
johnpitcairn commentedNow that there is a 2.x branch that is a major refactor, I think we need a roadmap for what is still in-scope that could be committed as a patch to 1.x, vs a new feature that needs to be developed against 2.x. This has proved to be a major problem for other modules and I'd hate to see it perpetuate here. @justin2pin, where should our effort be focused?
Comment #12
justin2pin commentedI agree this would be a great feature to add to Layout Paragraphs... great seeing the work on this so far!
At this time, we are focussing entirely on the 2.0.x branch for new development. We expect all current features to be included in 2.0.x, and there will be a simple upgrade path (when ready, you'll just switch to the new version). The code is changing, but the data storage is staying the same.
We will also address major bugs for 1.0.x to make sure this module continues to work well for everyone as is.
All that said, I'm happy to review and commit RTBC issues for 1.0.x.
Comment #13
anybodyLet's switch this to 2.x! Really helpful and interesting feature, which could in large parts perhaps be reused from Paragraphs core or other paragraphs modules. Also it might in parts be related to the whole entity cloning topic #3218226: Cloning Entities containing Layout Paragraphs breaks structure?
Comment #15
justin2pin commented@Anybody - agreed this is better tagged 2x, but I don't think we should build this directly into LP. I'd rather either (a) create a submodule, or (b) just create a separate standalone module for handling this. The 2x branch provides APIs that should make this kind of thing pretty simple.
Comment #16
anybody@justin2pin, you're the maintainer, you decide :) My 2 cent is that it makes sense in the module itself. Directly or as submodule. It's a very typical feature, I guess, used by many inexperienced content editors / site admins. At least that is what we see in Wordpress Gutenberg / Elementor every day...
I'd even vote for direct inclusion, but as said above, you're the maintainer :)
I really appreciate your work and your commitment a lot! GREAT module!
Comment #17
justin2pin commentedHah thanks - will consider and keep this open in the meantime.
Comment #19
hudriI'm with @Anybody in this matter, I'd vote for adding this into the main module. Paragraphs itself also has the duplicate option in the main widget. Given the nature of Paragraphs vs. core layout builder, where every node starts completely empty, duplication is a very common operation.
I've added a public
duplicateComponent()in LayoutParagraphsLayout. The field widget is using this via a dedicate DuplicateController now, and Replicate could re-use this, because it has support from Paragraphs itself, triggering an event there. Quick Node Clone or Entity Clone are still out of luck.I've tried to keep this as simple as possible, no extra permissions, no placement logic, quite the same behavior as original Paragraphs itself.
If somebody has experience writing proper tests, I would appreciate any help. I'm quite in-experienced writing tests and getting it all done inside the Drupal infrastructure.
Comment #20
hudriComment #21
mrpauldriver commentedDrupal does not have a killer app when it comes to page builder systems and inferior CMS platforms are way ahead in this respect.
Layout paragraphs could change this, so much better if this feature was baked in.
If easier to manage as a sub module then fair enough, but most certainly not as more contrib.
Comment #22
justin2pin commented@hudri - Awesome work, thanks for this! Just pulled from your issue fork and it works perfectly. I'm going to commit a few suggested changes... let me know what you think. Also the icon is great too.
I agree this feature is important, but I still think we need to be able to turn it on/off. A few ways of doing that:
Thoughts?
Comment #23
justin2pin commented@hudri - My commits include rebasing the latest 2.0.x -- apologies for the messy diff. Comments / changes / feedback welcome.
Thanks again for the work on this -- let's figure out the best way to make this something admins can turn on / off.
Comment #24
johnpitcairn commentedA submodule or contrib for this feels like kicking the can down the road. It's core functionality, ask any editor.
What is the use case for restricting duplication by role? How might it be abused so per role permissions would help?
Per widget instance is intriguing, but I can't think of a use case for site builders where you'd want to restrict duplication based on the parent entity/field.
Per formatter instance I think would be just weird. Why?
I can however see a use case for it being a 3rd party setting on paragraph types, where duplication in the same parent could result in confusing outcomes for site visitors or hard decisions for editors.
Comment #25
anybodyis the only option that makes sense for me, as I'm with @John Potcairn, if you want a general setting for that. If not, use a separate permission in the layout paragraphs permissions submodule.
But I think it's not required.
What's needed is to ensure that only paragraphs (types) can be cloned, which the user is allowed to create from scratch. Because in the end it's a shortcut to (re)create a paragraph of a certain type and it should use the same permissions, otherwise it might be confusing and counter-productive.
From my perspective, you shouldn't make it more complicated for you as needed. :) I'd be fine to simply have it in general...
Comment #26
justin2pin commentedI've already seen a number of instances where LP is being used in ways I had not foreseen, planned, or intended that I feel strongly there needs to be some ability to restrict this feature. One simple example: we're using LP on a project right now where some editors have the ability to build pages, others have only the ability to edit individual paragraphs. I also worry that we will continue to identify additional features that are useful to some, but not necessarily to others, and may clutter the already somewhat complex interface. So... I think we just need a way for site-builders / developers to turn this off.
I think the simplest solution is adding a permission to the "Layout Paragraphs Permissions" module for controlling this. This will also provide a fairly straightforward example for using the API to limit access where needed, meaning developers can limit access based on other more complex criteria if they need to.
End result:
Comment #27
justin2pin commentedAlso: I think MR45 is pretty close now - we just needed automated tests.
Comment #28
justin2pin commentedJust added a simple test for duplicating a test component and duplicating a two-column section that contains two text components. Once this passes tests, I'll push to dev.
We can continue to discuss points from comments #23-#26, but I don't think that needs to block this from being added.
Thanks everybody.
Comment #30
justin2pin commentedComment #31
mrpauldriver commentedGreat. Thanks everyone for working on this.
Comment #32
anybodyWhao great work! We'll make a larger test run on beta6 / rc0 as soon as it's out and provide further feedback!
layout_paragraphs 2.x is definitely a wonderful Christmas present for Drupal! Druplicon will be happy under the Christmas tree ;)