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

Duplicate Block #15

Closed
theskyfloor opened this issue May 18, 2016 · 13 comments
Closed

Duplicate Block #15

theskyfloor opened this issue May 18, 2016 · 13 comments
Assignees
Milestone

Comments

@theskyfloor
Copy link

It would be a great piece of functionality if it was possible to duplicate an existing and already built block when adding content... with all of the sub fields in tact (although they don't necessarily have to be filled out, for my use case at least)

@benjamminf benjamminf self-assigned this May 18, 2016
@benjamminf benjamminf added this to the 1.2.0 milestone May 19, 2016
@benjamminf
Copy link
Contributor

I've got the basics down under the feature/duplicate-block branch. So far it seems to work fine with some of the native Craft fields. Yet to see what happens when duplicating blocks with Matrix and other third-party fields, but it's looking promising.

@theskyfloor
Copy link
Author

I am testing it out! Where is the UI for duplicating a block? Or is there some other way to test it? I am happy to give it a whirl

@benjamminf
Copy link
Contributor

benjamminf commented Jun 19, 2016

Yeah it's a development branch so the Javascript needs building. I've attached the compiled versions here (just replace the main.js and main.js.map files in the neo/resources/ directory), or if you run an npm install then webpack on the repository's root directory you can build it yourself.

Currently duplicating blocks won't duplicate their children, and it doesn't adhere to any max block rules either.

I should point out the feature/duplicate-block branch also contains all the changes for the upcoming 1.2.2 release. This release dramatically improves performance, but it's still in a trial period just in case some bugs passed through testing.

@benjamminf
Copy link
Contributor

I've reworked my solution for duplicate blocks, and now it's essentially guaranteed to work with any field type. So look forward to this in 1.3.0 👍

@benjamminf
Copy link
Contributor

Accidentally closed it... my bad.

@theskyfloor
Copy link
Author

Cool! Want any testing? I tested the last version and definitely ran into some bugs... but figured you would find them too : )

@benjamminf
Copy link
Contributor

I'd be happy for you to test :) Here's a copy of the latest changes. I hadn't had a chance to really test the older version you were testing, but I could imagine it would've had quite a few bugs. The newer version renders the duplicated block server-side, instead of trying to rebuild one on the client (which no doubt would be problematic for certain fields). I'm happy for you to report any bugs you find here. Thanks for helping out!

@theskyfloor
Copy link
Author

Nice it works much better and actually preserves data which it wasn't before!

The only bug I am noticing off the bat is that if I duplicate a top level block it is then moved into a child of the parent instead of creating another parent block - as a side effect of that behavior the sub blocks aren't being duplicated either.

screen shot 2016-06-21 at 9 42 19 am

@benjamminf
Copy link
Contributor

benjamminf commented Jun 22, 2016

Ah yeah, that was a silly mistake. I've fixed it now. Here are the updated JS files. Child blocks not being duplicated is still something I'm working on.

benjamminf added a commit that referenced this issue Jun 22, 2016
@benjamminf
Copy link
Contributor

Child blocks now duplicate with blocks. Here's the updated compiled JS if you want to test it.

@theskyfloor
Copy link
Author

Testing it now

@theskyfloor
Copy link
Author

Great! Works much better than it had been. Still not duplicating in a specific circumstance - attached image because it gets confusing trying to verbally describe what is and isn't happening with all the child blocks... haha. Sorry if I am being annoying!

screen shot 2016-06-22 at 10 08 56 am

@benjamminf
Copy link
Contributor

Ah I see, so it's not working with Matrix fields. Seems a little strange... I'm looking into it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants