6

I am trying to catch the FinishActivity in the UI/UX when a user selects the option from a Page or Component.

Using the standard method of adding the extended command in the relevant config file I am able to add the interface and catch the isAvailable method using the scripts shown below.

Tridion.Extensions.CheckTitleOnFinishActivitySE = function Commands$CheckTitleOnFinishActivitySE() {
    Tridion.OO.enableInterface(this, "Tridion.Cme.Commands.CheckTitleOnFinishActivitySE");
    this.addInterface("Tridion.Web.UI.Editors.SiteEdit.Commands.FACommand", ["CheckTitleOnFinishActivitySE", $const.AllowedActions.FinishActivity]);
};
Tridion.Extensions.CheckTitleOnFinishActivitySE.prototype._isAvailable = function (selection) {
    var response = Tridion.Web.UI.Editors.SiteEdit.Commands.FinishActivity.prototype._isAvailable(selection);
};

However, when I attempt to reuse the exisitng isEnabled function:

Tridion.Extensions.CheckTitleOnFinishActivitySE.prototype.isEnabled = function (selection) {
    var response = Tridion.Web.UI.Editors.SiteEdit.Commands.FinishActivity.prototype._isEnabled(selection);
};

or even copying the existing code from the siteedit function itself (which I'd obviously rather not do)

Tridion.Extensions.CheckTitleOnFinishActivitySE.prototype.isEnabled = function (selection) {
    return (selection && selection.getProperty && selection.getProperty("isSEPage")) && 
        this.callBase("Tridion.Cme.Command", "_isEnabled", [selection]);
};

I receieve the following error:

Can't execute the command "FinishActivity" on [tcm:8-349-131200]. Reason: not enabled.

I can force the state to enabled by using just return true from the isEnabled function but I'd rather inherit/reuse the existing check to cater for current and future scenarios...

I can confirm the _isAvailable is caught and returns true and that the required function to extend is isEnabled and not _isEnabled (adding the latter alone or in addition to isEnabled has no effect)

Any advice would be splendid!

Thanks in advance.

Update - debug addition

So, I added the following into my extended isEnabled to track the difference between the response on the selection object in my isEnabled 'v' the default isEnabled:

The 'workflow.js' shows the value if the isSEPage property as true - but when checked directly in my function it's false. It reads consistent then that when called from my isEnabled into the original it then returns false also. I don't understand what could happen to the selection or that I'd be dealing with a different selection object/context?

Updated extended isEnabled with debug scripts:

Tridion.Extensions.CheckTitleOnFinishActivitySE.prototype.isEnabled = function (selection) {

    $log.message('myfile.js::FinishActivity.prototype._isEnabled::selection.getProperty("isSEPage") = ' + selection.getProperty("isSEPage"));

    $log.message('myfile.js::FinishActivity.prototype.isEnabled ==> checking calling original...');
    var response = Tridion.Web.UI.Editors.SiteEdit.Commands.FinishActivity.prototype._isEnabled(selection);
    $log.message('myfile.js::FinishActivity.prototype.isEnabled ==> ' + response);


    $log.message('myfile.js::FinishActivity.prototype.isEnabled ==> checking using copied code from original...');
    return (selection && selection.getProperty && selection.getProperty("isSEPage")) &&
        this.callBase("Tridion.Cme.Command", "_isEnabled", [selection]);


};

Output (workflow.js represents the original workflow value for the same evaluation)

workflow.js:FinishActivity.prototype._isEnabled::selection.getProperty("isSEPage") = true myfile.js::FinishActivity.prototype._isEnabled::selection.getProperty("isSEPage") = undefined myfile.js::FinishActivity.prototype.isEnabled ==> checking calling original... workflow.js:FinishActivity.prototype._isEnabled::selection.getProperty("isSEPage") = undefined myfile.js::FinishActivity.prototype.isEnabled ==> undefined myfile.js::FinishActivity.prototype.isEnabled ==> checking using copied code from original... Can't execute the command "CheckTitleOnFinishActivitySE" on [tcm:8-349-131200]. Reason: not enabled.

More debug

I see that in the original CME workflow script there is no isEnabled function at all?

I added the following to the extended isEnabled scipt:

Tridion.Extensions.CheckTitleOnFinishActivitySE.prototype.isEnabled = function (selection) {

    $log.message('myfile.js::FinishActivity.prototype._isEnabled::selection.getProperty("isSEPage") = ' + selection.getProperty("isSEPage"));
    $log.message('Tridion.Web.UI.Editors.SiteEdit.Commands.FinishActivity.prototype._isEnabled(selection) = ' + Tridion.Web.UI.Editors.SiteEdit.Commands.FinishActivity.prototype._isEnabled(selection));

$log.message('this.callBase("Tridion.Cme.Command", "_isEnabled", [selection]) = ' + this.callBase("Tridion.Cme.Command", "_isEnabled", [selection]));

resulting in:

myfile.js::FinishActivity.prototype._isEnabled::selection.getProperty("isSEPage") = undefined Editor_v6.1.0.55920.269_.aspx:7175 workflow.js:FinishActivity.prototype._isEnabled::selection.getProperty("isSEPage") = undefined Editor_v6.1.0.55920.269_.aspx:7175 Tridion.Web.UI.Editors.SiteEdit.Commands.FinishActivity.prototype._isEnabled(selection) = undefined Editor_v6.1.0.55920.269_.aspx:7175 this.callBase("Tridion.Cme.Command", "_isEnabled", [selection]) = false

Although the original (SiteEdit) is still being executed prior to my script and returns

workflow.js::FinishActivity.prototype._isEnabled::selection.getProperty("isSEPage") = true

I'm wondering if the Tridion SiteEdit isEnabled is being checked on selection of the option to FinishActivity and my extension is being executed when the FinishActivity action itself is instantiated. I'm looking further but if anyone sees anything in the iterim that would be great!

Thanks

4

1 回答 1

1

OK! So the Tridion SiteEdit instance of isEnabled is executed when the user selects the icon to trigger the ShowActivityStartedPopup Command.

My isEnabled is triggered when the FininshActivity option is selected by the user.

Can anyone see a quicker way I could have gotten to this conclusion... or if this conclusion is not correct...

Thanks

于 2012-12-17T16:12:33.883 回答