diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-12-22 12:31:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-22 12:31:55 +0100 |
commit | e37fa60784f94abb6715704ffcbd479c05938e3a (patch) | |
tree | 7c3b22cc9dc5aa87c0319fcea497aca0b4bcd4df /apps/files/js/fileactions.js | |
parent | e40d6f6d8c54df43c302eaec7496080b42a49619 (diff) | |
parent | c059fbd409b088f65922354149f6d2fd9b5d01b3 (diff) | |
download | nextcloud-server-e37fa60784f94abb6715704ffcbd479c05938e3a.tar.gz nextcloud-server-e37fa60784f94abb6715704ffcbd479c05938e3a.zip |
Merge pull request #7591 from nextcloud/trigger-events-before-and-after-a-file-action-is-executed
Trigger events before and after a file action is executed
Diffstat (limited to 'apps/files/js/fileactions.js')
-rw-r--r-- | apps/files/js/fileactions.js | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 6c031ab06d5..2fb7dfba29f 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -47,14 +47,6 @@ */ $el: null, - /** - * List of handlers to be notified whenever a register() or - * setDefault() was called. - * - * @member {Function[]} - */ - _updateListeners: {}, - _fileActionTriggerTemplate: null, /** @@ -142,7 +134,22 @@ var mime = action.mime; var name = action.name; var actionSpec = { - action: action.actionHandler, + action: function(fileName, context) { + // Actions registered in one FileAction may be executed on a + // different one (for example, due to the "merge" function), + // so the listeners have to be updated on the FileActions + // from the context instead of on the one in which it was + // originally registered. + if (context && context.fileActions) { + context.fileActions._notifyUpdateListeners('beforeTriggerAction', {action: actionSpec, fileName: fileName, context: context}); + } + + action.actionHandler(fileName, context); + + if (context && context.fileActions) { + context.fileActions._notifyUpdateListeners('afterTriggerAction', {action: actionSpec, fileName: fileName, context: context}); + } + }, name: name, displayName: action.displayName, mime: mime, @@ -174,7 +181,6 @@ this.defaults = {}; this.icons = {}; this.currentFile = null; - this._updateListeners = []; }, /** * Sets the default action for a given mime type. |