Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

autoSave before page duplicate


Reply


5 Posts   1784 Views

Avatar
xmedeko

Community Member, 94 Posts

9 July 2007 at 1:41pm

Edited: 10/07/2007 8:22am

Hi,

when I make a change in a page in CMS and then duplicate this page (right mouse click in the tree -> Duplicate), then the page is duplicated first and then original one is saved. The original is saved, because the selection in the page tree is changed. The new page does not contain the last change, so the pages differ.

I wanted just to add autoSave(true) in the

CMSMain_left.js -> TreeContextMenu -> 'Duplicate this page' : function()

, but it didn't work, so I made two changes. First, in the CMSMain_left.js:

'Duplicate this page' : function(treeNode) {
autoSave(true, treeNode.duplicatePage.bind(treeNode));
},

and the second in the LeftAndMain_left.js:

TreeNodeAPI.prototype = {
duplicatePage : function() {
new Ajax.Request(baseHref() + 'admin/duplicate/' + this.getIdx() + '?ajax=1', {
method : 'get',
onSuccess : Ajax.Evaluator,
onFailure : function(response) {
errorMessage('Error: ', response);
}
});
},

Now, the page is first saved, and then duplicated.

Avatar
Sigurd

Forum Moderator, 628 Posts

12 July 2007 at 8:52am

one of the GSOCers wish to add this to the GSOC branch? [attribute ondra] :)

Avatar
elijahlofgren

Google Summer of Code Hacker, 222 Posts

12 July 2007 at 10:56am

I've tentatively put this on my list: [url=http://support.silverstripe.com/gsoc/ticket/41]Ticket #41 Apply xmedeko's "autoSave before page duplicate" fixes to gsoc branch[/url] but if anyone else would like to do this, feel free to reassign to yourself. ;)

Thanks for this xmedeko,

Elijah

Avatar
Markus

Google Summer of Code Hacker, 152 Posts

12 July 2007 at 9:05pm

Edited: 12/07/2007 9:14pm

I tried to apply the patch, but it doesn't seem to work with the GSoC branch.. maybe I missed something or it works only with the latest build..

I'm working on something else at the moment, will look at that later..

I added the patched files to the ticket, but I didn't commit them yet.

Avatar
elijahlofgren

Google Summer of Code Hacker, 222 Posts

13 July 2007 at 8:07am

Edited: 13/07/2007 8:25am

I've applied these changes to the gsoc branch: [url=http://www.elijahlofgren.com/silverstripe/patches/Apply-xmedekos-autoSave-before-page-duplicate-fixes-cms-gsoc-r38532.patch]Apply-xmedekos-autoSave-before-page-duplicate-fixes-cms-gsoc-r38532.patch[/url]

------------------------------------------------------------------------
r38532 | elofgren | 2007-07-12 15:02:36 -0500 (Thu, 12 Jul 2007) | 1 line

When 'Duplicate this page' is clicked, first silently (without confirmation) save the page, then duplicate it so the new page is identical to the other page. Closes gsoc Ticket #41: Apply xmedeko's "autoSave before page duplicate" fixes to gsoc branch. Adapted from code posted here: http://www.silverstripe.com/contributions/flat/2073 Thanks Ondra\!
------------------------------------------------------------------------

Thanks to Ondra for finding a solution and to everyone who looked into this,

Elijah