craftercms / craftercms

Parent project for Crafter CMS. Issue tracking across all repositories and global builds.
GNU General Public License v3.0
294 stars 97 forks source link

[studio-ui] Add duplicate as a valid operation on right click of wcm-root-folder plugin for sidebar #1225

Closed russdanner closed 6 years ago

russdanner commented 7 years ago

the need/requirements

Today right click in pages, components and other sidebar options based on wcm-root-folder.js do not support duplicate operation. Add this option to the right click.

position in the right click

The order of options should be: Cut Copy Paste (if item on clipboard) Duplicate

existing duplicate on context nav

Today, you can invoke a duplicate from the context navbar (see wcm_content.js plugin) when you are looking at a page in preview or when you select it on the dashboard.

From wcm_content.js

var content = CStudioAuthoring.SelectedContent.getSelectedContent()[0];
                            option.onclick = function() {
                                YDom.get("duplicate-loading").style.display = "block";                      
                                CStudioAuthoring.Operations.duplicateContent(
                                        CStudioAuthoringContext.site,
                                        content.uri,
                                        duplicateContentCallback);
                            };

implementation notes

Common API contains an Operation for duplicate. The menu just calls the operation as shown above.

The operation takes care of creating the new content and automatically opening the form.

I believe the Operation takes care of all of the logic we need. The on success and on failure callbacks of the operation need only handle actions related to the wcm-root-folder tree itself:

applies to

2.5.x, 3.x

jvega190 commented 7 years ago

2.5.x https://github.com/craftercms/studio2-ui/pull/549 3.x https://github.com/craftercms/studio2-ui/pull/548

russdanner commented 6 years ago

VERIFIED