summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-05-19 15:20:44 +0200
committerVincent Petry <pvince81@owncloud.com>2014-05-30 10:06:29 +0200
commit60bcdc550e95fbf0104bbc9c8028777016d73663 (patch)
treed6ca8475d7ea4cb8aa7e034add8902926171e612 /apps/files
parent279ede33af09c43e03f97458c7fa673ff2b7982a (diff)
downloadnextcloud-server-60bcdc550e95fbf0104bbc9c8028777016d73663.tar.gz
nextcloud-server-60bcdc550e95fbf0104bbc9c8028777016d73663.zip
Fixed file actions for sharing views
FileActions can now be clone to be use for separate file list views without having the side-effect of affecting the main file list view. Added "Open" action in sharing overview file lists to redirect to the regular file list when clicking on a folder.
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/js/app.js12
-rw-r--r--apps/files/js/fileactions.js34
-rw-r--r--apps/files/js/filelist.js11
3 files changed, 39 insertions, 18 deletions
diff --git a/apps/files/js/app.js b/apps/files/js/app.js
index 9155fb38cdb..6d8a9788d97 100644
--- a/apps/files/js/app.js
+++ b/apps/files/js/app.js
@@ -25,7 +25,7 @@
this.navigation = new OCA.Files.Navigation($('#app-navigation'));
// TODO: ideally these should be in a separate class / app (the embedded "all files" app)
- this.fileActions = OCA.Files.FileActions;
+ this.fileActions = OCA.Files.FileActions.clone();
this.files = OCA.Files.Files;
this.fileList = new OCA.Files.FileList(
@@ -36,7 +36,7 @@
}
);
this.files.initialize();
- this.fileActions.registerDefaultActions(this.fileList);
+ this.fileActions.registerDefaultActions();
this.fileList.setFileActions(this.fileActions);
// for backward compatibility, the global FileList will
@@ -58,6 +58,14 @@
},
/**
+ * Sets the currently active view
+ * @param viewId view id
+ */
+ setActiveView: function(viewId, options) {
+ this.navigation.setActiveItem(viewId, options);
+ },
+
+ /**
* Setup events based on URL changes
*/
_setupEvents: function() {
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index 9e4aeb2f338..1242fea7f99 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -31,6 +31,18 @@
this.actions[mime][name]['displayName'] = displayName;
this.icons[name] = icon;
},
+ /**
+ * Clones the current file actions handler including the already
+ * registered actions.
+ */
+ clone: function() {
+ var fileActions = _.extend({}, this);
+ // need to deep copy the actions as well
+ fileActions.actions = _.extend({}, this.actions);
+ fileActions.defaults = _.extend({}, this.defaults);
+ //fileActions.icons = _.extend({}, this.icons);
+ return fileActions;
+ },
clear: function() {
this.actions = {};
this.defaults = {};
@@ -217,29 +229,29 @@
/**
* Register the actions that are used by default for the files app.
*/
- registerDefaultActions: function(fileList) {
+ registerDefaultActions: function() {
// TODO: try to find a way to not make it depend on fileList,
// maybe get a handler or listener to trigger events on
this.register('all', 'Delete', OC.PERMISSION_DELETE, function () {
return OC.imagePath('core', 'actions/delete');
- }, function (filename) {
- fileList.do_delete(filename);
+ }, function (filename, context) {
+ context.fileList.do_delete(filename);
$('.tipsy').remove();
});
// t('files', 'Rename')
this.register('all', 'Rename', OC.PERMISSION_UPDATE, function () {
return OC.imagePath('core', 'actions/rename');
- }, function (filename) {
- fileList.rename(filename);
+ }, function (filename, context) {
+ context.fileList.rename(filename);
});
- this.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename) {
- var dir = fileList.getCurrentDirectory();
+ this.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) {
+ var dir = context.fileList.getCurrentDirectory();
if (dir !== '/') {
dir = dir + '/';
}
- fileList.changeDirectory(dir + filename);
+ context.fileList.changeDirectory(dir + filename);
});
this.setDefault('dir', 'Open');
@@ -252,14 +264,12 @@
this.register(downloadScope, 'Download', OC.PERMISSION_READ, function () {
return OC.imagePath('core', 'actions/download');
- }, function (filename) {
- var url = fileList.getDownloadUrl(filename, fileList.getCurrentDirectory());
+ }, function (filename, context) {
+ var url = context.fileList.getDownloadUrl(filename, context.fileList.getCurrentDirectory());
if (url) {
OC.redirect(url);
}
});
-
- fileList.$fileList.trigger(jQuery.Event("fileActionsReady"));
}
};
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 08f640f6bff..d969cb57c56 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -452,7 +452,7 @@
while (count > 0 && index < this.files.length) {
fileData = this.files[index];
- tr = this._renderRow(fileData, {updateSummary: false});
+ tr = this._renderRow(fileData, {updateSummary: false, silent: true});
this.$fileList.append(tr);
if (isAllSelected || this._selectedFiles[fileData.id]) {
tr.addClass('selected');
@@ -626,7 +626,8 @@
*
* @param fileData map of file attributes
* @param options map of attributes:
- * - "updateSummary" true to update the summary after adding (default), false otherwise
+ * - "updateSummary": true to update the summary after adding (default), false otherwise
+ * - "silent": true to prevent firing events like "fileActionsReady"
* @return new tr element (not appended to the table)
*/
add: function(fileData, options) {
@@ -729,7 +730,7 @@
}
// display actions
- this.fileActions.display(filenameTd, false, this);
+ this.fileActions.display(filenameTd, !options.silent, this);
if (fileData.isPreviewAvailable) {
// lazy load / newly inserted td ?
@@ -790,7 +791,9 @@
},
/**
- * Sets the file actions handler
+ * Sets the file actions handler.
+ *
+ * @param fileActions FileActions handler
*/
setFileActions: function(fileActions) {
this.fileActions = fileActions;