cancel
Showing results for 
Search instead for 
Did you mean: 

How to call existing Alfresco.doclib.Actions from custom doc action?

why-pengo
Champ in-the-making
Champ in-the-making
Hi,

I've created a custom document action to wrap the onActionCancelEditing
document action with a warning message, like this:


YAHOO.Bubbling.fire("registerAction", {
    actionName: "sgiOnActionCancelEditing",
    fn: function sgi_onActionCancelEditing(record)
    {
        var displayName = record.displayName;

        var rv = confirm("WARNING! You are about to delete this working copy and any edits you may have made!");
        if (rv === true) {
            Alfresco.doclib.Actions.prototype.onActionCancelEditing(record);
        }
    }
});


Also did the share-config-custom.xml change:


            <!– Cancel editing (cancel checkout) –>
            <action id="document-cancel-editing"
                    type="javascript"
                    label="actions.document.cancel-editing">
                <param name="function">sgiOnActionCancelEditing</param>
                <permissions>
                   <permission allow="true">CancelCheckOut</permission>
                </permissions>
                <evaluator>evaluator.doclib.action.isWorkingCopy</evaluator>
                <evaluator>evaluator.doclib.action.editableByCurrentUser</evaluator>
            </action>

and:

    <config evaluator="string-compare" condition="DocLibCustom" replace="true">
        <dependencies>
            <!– js src="components/sgi-object-finder/sgi-cancelEdit-min.js" / –>
            <js src="components/sgi-object-finder/sgi-cancelEdit.js" />
        </dependencies>
    </config>

I now have the popup warning and can step through the javascript in Firebug, but
my call to Alfresco.doclib.Actions.prototype.onActionCancelEditing(); does not cancel
the edit. How do I call this method?

Thanks for any help,

-jon
1 REPLY 1

why-pengo
Champ in-the-making
Champ in-the-making
Replaced my javascript with this and now it is working:


YAHOO.Bubbling.fire("registerAction", {
actionName: "sgiOnActionCancelEditing",
fn: function sgi_onActionCancelEditing(asset)
{
var rv = confirm("WARNING! You are about to delete this working copy and any edits you may have made!");
if (rv === true) {
var displayName = asset.displayName,
nodeRef = new Alfresco.util.NodeRef(asset.nodeRef);
this.modules.actions.genericAction(
{
success:
{
callback:
{
fn: function DocumentActions_oACE_success(data)
{
var oldNodeRef = this.recordData.jsNode.nodeRef.nodeRef,
newNodeRef = data.json.results[0].nodeRef;
this.recordData.jsNode.setNodeRef(newNodeRef);
window.location = this.getActionUrls(this.recordData).documentDetailsUrl + "#editCancelled";
if (oldNodeRef == newNodeRef)
{
window.location.reload();
}
},
scope: this
}
},
failure:
{
message: this.msg("message.edit-cancel.failure", displayName)
},
webscript:
{
method: Alfresco.util.Ajax.POST,
name: "cancel-checkout/node/{nodeRef}",
params:
{
nodeRef: nodeRef.uri
}
}
});
}
}
});