From d6e431a2211e96248e8d61a33d21896fe0678c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 25 Jan 2019 09:00:39 +0100 Subject: [PATCH] Open file editor through URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniel Calviño Sánchez Signed-off-by: Julius Härtl --- apps/files/js/filelist.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 0686968b98..d4f9c9c384 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -350,7 +350,8 @@ if (options.scrollTo) { this.$fileList.one('updated', function() { - self.scrollTo(options.scrollTo); + var open = true; + self.scrollTo(options.scrollTo, open); }); } @@ -2723,13 +2724,33 @@ this.$el.find('.mask').remove(); this.$table.removeClass('hidden'); }, - scrollTo:function(file) { + scrollTo:function(file, open) { if (!_.isArray(file)) { file = [file]; } if (file.length === 1) { _.defer(function() { this.showDetailsView(file[0]); + + if (open) { + var $tr = this.findFileEl(file[0]); + var filename = $tr.attr('data-file'); + this.fileActions.currentFile = $tr.find('td'); + var mime = this.fileActions.getCurrentMimeType(); + var type = this.fileActions.getCurrentType(); + var permissions = this.fileActions.getCurrentPermissions(); + var action = this.fileActions.get(mime, type, permissions)['Edit']; + if (action) { + // also set on global object for legacy apps + window.FileActions.currentFile = this.fileActions.currentFile; + action(filename, { + $file: $tr, + fileList: this, + fileActions: this.fileActions, + dir: $tr.attr('data-path') || this.getCurrentDirectory() + }); + } + } }.bind(this)); } this.highlightFiles(file, function($tr) {