-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 #3434
base: main
Are you sure you want to change the base?
Duplicate #3434
Conversation
Well, I think I've made that change. I even tried to squash my commits, but I fear they are as tangled as ever. |
Not sure these failures are related to the this PR. |
Yeah, the tests failures seem to be happening in every PR.. it's very strange. I think we'll need to fix it before we can merge anything though 😦 |
Tests started failing between Rails v5.2.2.1 (passing) and v5.2.3.rc1 (failing) |
Tests fail from this change: rails/rails#35162 |
Add duplicated to the locale texts Using a translation string to create the title for the new object changes as suggested Fix spacing in en.yml
This is a very short PR.
It puts in place the basic features needed to implement a duplicate action.
The default duplicate action is very naive - it copies the item and opens the copy to be edited.
There is no attempt to copy any associations apart from
:belongs_to
, which is held on the model._A full implementation of a duplicate action will need a more sophisticated duplicate method - it will depend on the model and the implementor. Although the example below, using refinerycms-pages, adds some more steps, a true duplicator for refinerycms-pages needs attention paid to translations and other associations added by refinery extensions. I don't think it is ready to be submitted as a PR yet.
Each model will have different considerations - starting with whether it is appropriate to duplicate at all.
_
For an extension to implement the duplicate action it will need to
duplicate
method to extend the duplication to copy associations.To implement 'duplicate' in an extension
This is still a simple duplication.
Adding a route
Override the default duplicate action so page-parts are duplicated
add a link to the duplicate action in the admin/index
Note
The example duplicate action saves the page before sending it to be edited. Seems to work.
Finally, I tried to write a routing test but didn't manage to get it working. Help appreciated.