Skip to content

Commit fc338f1

Browse files
phillipazul
authored andcommitted
Modify do_action so default ctrl-click opens tab
Modify do_action to use an ID number Use item in do_action instead of currentFile Limit launching direct actions to one time Use full file item instead of attr-only Signed-off-by: phillip <phillipsmyth@codethink.co.uk>
1 parent 62403d0 commit fc338f1

File tree

1 file changed

+34
-15
lines changed

1 file changed

+34
-15
lines changed

apps/files/js/filelist.js

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@
432432
this.setupUploadEvents(this._uploader);
433433
}
434434
}
435-
435+
this.triedActionOnce = false;
436436

437437
OC.Plugins.attach('OCA.Files.FileList', this);
438438

@@ -874,7 +874,7 @@
874874
if ($tr.hasClass('dragging')) {
875875
return;
876876
}
877-
if (this._allowSelection && (event.ctrlKey || event.shiftKey)) {
877+
if (this._allowSelection && (event.shiftKey)) {
878878
event.preventDefault();
879879
if (event.shiftKey) {
880880
this._selectRange($tr);
@@ -883,6 +883,7 @@
883883
}
884884
this._lastChecked = $tr;
885885
this.updateSelectionSummary();
886+
} else if (this._allowSelection && (event.ctrlKey)) {
886887
} else {
887888
// clicked directly on the name
888889
if (!this._detailsView || $(event.target).is('.nametext, .name, .thumbnail') || $(event.target).closest('.nametext').length) {
@@ -892,18 +893,10 @@
892893
event.preventDefault();
893894
} else if (!renaming) {
894895
this.fileActions.currentFile = $tr.find('td');
895-
var mime = this.fileActions.getCurrentMimeType();
896-
var type = this.fileActions.getCurrentType();
897-
var permissions = this.fileActions.getCurrentPermissions();
898-
var action = this.fileActions.getDefault(mime,type, permissions);
899-
if (action) {
896+
var item = this.$fileList.children().filterAttr('data-id', '' + $tr.attr('data-id'));
897+
898+
if(this.openAction($tr.attr('data-id'))) {
900899
event.preventDefault();
901-
action(filename, {
902-
$file: $tr,
903-
fileList: this,
904-
fileActions: this.fileActions,
905-
dir: $tr.attr('data-path') || this.getCurrentDirectory()
906-
});
907900
}
908901
// deselect row
909902
$(event.target).closest('a').blur();
@@ -933,6 +926,28 @@
933926
}
934927
},
935928

929+
openAction: function(id) {
930+
var item = this.$fileList.children().filterAttr('data-id', '' + id);
931+
var filename = item.attr('data-file');
932+
// also set on global object for legacy apps
933+
window.FileActions.currentFile = item.find('td');
934+
this.fileActions.currentFile = item.find('td');
935+
var mime = this.fileActions.getCurrentMimeType();
936+
var type = this.fileActions.getCurrentType();
937+
var permissions = this.fileActions.getCurrentPermissions();
938+
var action = this.fileActions.getDefault(mime,type, permissions);
939+
if (action) {
940+
action(filename, {
941+
$file: item,
942+
fileList: this,
943+
fileActions: this.fileActions,
944+
dir: item.attr('data-path') || this.getCurrentDirectory()
945+
});
946+
return true;
947+
}
948+
return false;
949+
},
950+
936951
/**
937952
* Event handler for when clicking on a file's checkbox
938953
*/
@@ -1322,7 +1337,11 @@
13221337
}
13231338
}, 0);
13241339
}
1325-
1340+
if(!this.triedActionOnce) {
1341+
var urlParams = OC.Util.History.parseUrlQuery();
1342+
this.openAction(urlParams.editfile);
1343+
this.triedActionOnce = true;
1344+
}
13261345
return newTrs;
13271346
},
13281347

@@ -1532,7 +1551,7 @@
15321551
linkUrl = this.linkTo(path + '/' + name);
15331552
}
15341553
else {
1535-
linkUrl = this.getDownloadUrl(name, path, type === 'dir');
1554+
linkUrl = this.linkTo(path) + "&editfile="+fileData.id;
15361555
}
15371556
var linkElem = $('<a></a>').attr({
15381557
"class": "name",

0 commit comments

Comments
 (0)