diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-07-09 12:26:33 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-07-09 12:26:33 +0200 |
commit | 22653e21a239afa8f29cf2c93afe28d21246e7ba (patch) | |
tree | cacee44aabacafe6ce35ce82a4e62afa7cdaab1e /apps/files_sharing/js | |
parent | 63fdaacbfcc8dbccca6777d623b6baadbd0ed56b (diff) | |
download | nextcloud-server-22653e21a239afa8f29cf2c93afe28d21246e7ba.tar.gz nextcloud-server-22653e21a239afa8f29cf2c93afe28d21246e7ba.zip |
Propagate file action changes to the file lists
Whenever an app needs to register an event late, it does that on the
original file actions object.
Since the file actions that the file list work on is a merged list, not
the original one, the registration event needs to be propagated there as
well.
Diffstat (limited to 'apps/files_sharing/js')
-rw-r--r-- | apps/files_sharing/js/app.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/apps/files_sharing/js/app.js b/apps/files_sharing/js/app.js index 1fc13d00382..1a3bfac5b97 100644 --- a/apps/files_sharing/js/app.js +++ b/apps/files_sharing/js/app.js @@ -92,6 +92,21 @@ OCA.Sharing.App = { } }, + /** + * Destroy the app + */ + destroy: function() { + OCA.Files.fileActions.off('setDefault.app-sharing', this._onActionsUpdated); + OCA.Files.fileActions.off('registerAction.app-sharing', this._onActionsUpdated); + this.removeSharingIn(); + this.removeSharingOut(); + this.removeSharingLinks(); + this._inFileList = null; + this._outFileList = null; + this._linkFileList = null; + delete this._globalActionsInitialized; + }, + _createFileActions: function() { // inherit file actions from the files app var fileActions = new OCA.Files.FileActions(); @@ -100,6 +115,14 @@ OCA.Sharing.App = { fileActions.registerDefaultActions(); fileActions.merge(OCA.Files.fileActions); + if (!this._globalActionsInitialized) { + // in case actions are registered later + this._onActionsUpdated = _.bind(this._onActionsUpdated, this); + OCA.Files.fileActions.on('setDefault.app-sharing', this._onActionsUpdated); + OCA.Files.fileActions.on('registerAction.app-sharing', this._onActionsUpdated); + this._globalActionsInitialized = true; + } + // when the user clicks on a folder, redirect to the corresponding // folder in the files app instead of opening it directly fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) { @@ -110,6 +133,23 @@ OCA.Sharing.App = { return fileActions; }, + _onActionsUpdated: function(ev) { + _.each([this._inFileList, this._outFileList, this._linkFileList], function(list) { + if (!list) { + return; + } + + if (ev.action) { + list.fileActions.registerAction(ev.action); + } else if (ev.defaultAction) { + list.fileActions.setDefault( + ev.defaultAction.mime, + ev.defaultAction.name + ); + } + }); + }, + _extendFileList: function(fileList) { // remove size column from summary fileList.fileSummary.$el.find('.filesize').remove(); |