Created
August 1, 2019 09:10
-
-
Save barteksekula/fc5bcdbbd7a18f4f67e31704254a782d to your computer and use it in GitHub Desktop.
Prevent executing the same command twice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
"dojo/_base/declare", | |
"epi/_Module", | |
"dojo/when", | |
"epi-cms/contentediting/command/Publish" | |
], function ( | |
declare, | |
_Module, | |
when, | |
PublishCommand | |
) { | |
return declare([_Module], { | |
initialize: function () { | |
var originalExecute = PublishCommand.prototype._execute; | |
PublishCommand.prototype._execute = function () { | |
if (this.get("isRunning")) { | |
return; | |
} | |
this.set("isRunning", true); | |
when(originalExecute.apply(this, arguments)).then(function () { | |
this.set("isRunning", false); | |
}.bind(this)) | |
} | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<module clientResourceRelativePath="1.0.0"> | |
<clientModule initializer="my-addon.initializer"> | |
<moduleDependencies> | |
<add dependency="CMS" type="RunAfter" /> | |
</moduleDependencies> | |
</clientModule> | |
<dojo> | |
<paths> | |
<add name="my-addon" path="Scripts" /> | |
</paths> | |
</dojo> | |
</module> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment