]> source.dussan.org Git - nextcloud-server.git/commitdiff
Improved FileActions with context
authorVincent Petry <pvince81@owncloud.com>
Mon, 19 May 2014 11:18:44 +0000 (13:18 +0200)
committerVincent Petry <pvince81@owncloud.com>
Fri, 30 May 2014 08:06:29 +0000 (10:06 +0200)
A context hash is now passed to file action handlers which makes it
possible to have file list specific file actions.

apps/files/js/fileactions.js
apps/files/js/filelist.js

index 085195e961d6012b676c613f4e6d5f902dbc283d..9e4aeb2f338dfefaef9e3011550d709734dd1a39 100644 (file)
                 * @param parent "td" element of the file for which to display actions
                 * @param triggerEvent if true, triggers the fileActionsReady on the file
                 * list afterwards (false by default)
+                * @param fileList OCA.Files.FileList instance on which the action is
+                * done, defaults to OCA.Files.App.fileList
                 */
-               display: function (parent, triggerEvent) {
+               display: function (parent, triggerEvent, fileList) {
+                       if (!fileList) {
+                               console.warn('FileActions.display() MUST be called with a OCA.Files.FileList instance');
+                       }
                        this.currentFile = parent;
                        var self = this;
                        var actions = this.getActions(this.getCurrentMimeType(), this.getCurrentType(), this.getCurrentPermissions());
                                self.currentFile = event.data.elem;
                                var file = self.getCurrentFile();
 
-                               event.data.actionFunc(file);
+                               event.data.actionFunc(file, {
+                                       $file: $(this).closest('tr'),
+                                       fileList: fileList || OCA.Files.App.fileList,
+                                       fileActions: self
+                               });
                        };
 
                        var addAction = function (name, action, displayName) {
index 7887bdcda55b84639c47f0b04718b04e1976727d..08f640f6bffe089c7b4ecc8f969a771ac9df23f4 100644 (file)
                                        var action = this.fileActions.getDefault(mime,type, permissions);
                                        if (action) {
                                                event.preventDefault();
-                                               action(filename);
+                                               action(filename, {
+                                                       $file: $tr,
+                                                       fileList: this,
+                                                       fileActions: this.fileActions
+                                               });
                                        }
                                }
                        }
                        }
 
                        // display actions
-                       this.fileActions.display(filenameTd, false);
+                       this.fileActions.display(filenameTd, false, this);
 
                        if (fileData.isPreviewAvailable) {
                                // lazy load / newly inserted td ?