Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2021-05-11 11:10:10 +0300
committerJulius Härtl <jus@bitgrid.net>2021-05-12 10:48:52 +0300
commit96515d7338006a99b853c899708d7f6667bd43fd (patch)
tree82dfa076456b1dd6d66fa1d2f29457538a399a5a
parentb2ad201644b087aa134236779869555e6dda6c69 (diff)
Allow apps to register a file action for multiselect
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r--apps/files/js/app.js3
-rw-r--r--apps/files/js/filelist.js33
2 files changed, 32 insertions, 4 deletions
diff --git a/apps/files/js/app.js b/apps/files/js/app.js
index 8015f395b74..1a7049832ca 100644
--- a/apps/files/js/app.js
+++ b/apps/files/js/app.js
@@ -97,17 +97,20 @@
name: 'copyMove',
displayName: t('files', 'Move or copy'),
iconClass: 'icon-external',
+ order: 10,
},
{
name: 'download',
displayName: t('files', 'Download'),
iconClass: 'icon-download',
+ order: 10,
},
OCA.Files.FileList.MultiSelectMenuActions.ToggleSelectionModeAction,
{
name: 'delete',
displayName: t('files', 'Delete'),
iconClass: 'icon-delete',
+ order: 99,
},
],
sorting: {
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 11d0bc4511d..b981785db40 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -330,9 +330,7 @@
this.multiSelectMenuItems[i] = this.multiSelectMenuItems[i](this);
}
}
- this.fileMultiSelectMenu = new OCA.Files.FileMultiSelectMenu(this.multiSelectMenuItems);
- this.fileMultiSelectMenu.render();
- this.$el.find('.selectedActions').append(this.fileMultiSelectMenu.$el);
+ this._updateMultiSelectFileActions()
}
if (options.sorting) {
@@ -516,7 +514,7 @@
multiSelectMenuClick: function (ev, action) {
var actionFunction = _.find(this.multiSelectMenuItems, function (item) {return item.name === action;}).action;
if (actionFunction) {
- actionFunction(ev);
+ actionFunction(this.getSelectedFiles());
return;
}
switch (action) {
@@ -1369,6 +1367,32 @@
},
/**
+ * Register action for multiple selected files
+ *
+ * @param {OCA.Files.FileAction} fileAction object
+ * The callback of FileAction will be called with an array of files that are currently selected
+ */
+ registerMultiSelectFileAction: function(fileAction) {
+ if (typeof this.multiSelectMenuItems === 'undefined') {
+ return;
+ }
+ this.multiSelectMenuItems.push(fileAction)
+ this._updateMultiSelectFileActions()
+ },
+
+ _updateMultiSelectFileActions: function() {
+ if (typeof this.multiSelectMenuItems === 'undefined') {
+ return;
+ }
+ this.fileMultiSelectMenu = new OCA.Files.FileMultiSelectMenu(this.multiSelectMenuItems.sort(function(a, b) {
+ return a.order > b.order
+ }));
+ this.fileMultiSelectMenu.render();
+ this.$el.find('.selectedActions .filesSelectMenu').remove();
+ this.$el.find('.selectedActions').append(this.fileMultiSelectMenu.$el);
+ },
+
+ /**
* Sets the files to be displayed in the list.
* This operation will re-render the list and update the summary.
* @param filesArray array of file data (map)
@@ -3785,6 +3809,7 @@
return t('files', 'Select file range');
},
iconClass: 'icon-fullscreen',
+ order: 15,
action: function() {
fileList._onClickToggleSelectionMode();
},