|
|
|
|
@ -142,6 +142,7 @@
|
|
|
|
|
name: name,
|
|
|
|
|
displayName: action.displayName,
|
|
|
|
|
mime: mime,
|
|
|
|
|
filename: action.filename,
|
|
|
|
|
order: action.order || 0,
|
|
|
|
|
icon: action.icon,
|
|
|
|
|
iconClass: action.iconClass,
|
|
|
|
|
@ -191,11 +192,12 @@
|
|
|
|
|
* @param {string} mime mime type
|
|
|
|
|
* @param {string} type "dir" or "file"
|
|
|
|
|
* @param {int} permissions permissions
|
|
|
|
|
* @param {string} filename filename
|
|
|
|
|
*
|
|
|
|
|
* @return {Object.<string,OCA.Files.FileActions~actionHandler>} map of action name to action spec
|
|
|
|
|
*/
|
|
|
|
|
get: function (mime, type, permissions) {
|
|
|
|
|
var actions = this.getActions(mime, type, permissions);
|
|
|
|
|
get: function(mime, type, permissions, filename) {
|
|
|
|
|
var actions = this.getActions(mime, type, permissions, filename);
|
|
|
|
|
var filteredActions = {};
|
|
|
|
|
$.each(actions, function (name, action) {
|
|
|
|
|
filteredActions[name] = action.action;
|
|
|
|
|
@ -209,10 +211,11 @@
|
|
|
|
|
* @param {string} mime mime type
|
|
|
|
|
* @param {string} type "dir" or "file"
|
|
|
|
|
* @param {int} permissions permissions
|
|
|
|
|
* @param {string} filename filename
|
|
|
|
|
*
|
|
|
|
|
* @return {Array.<OCA.Files.FileAction>} array of action specs
|
|
|
|
|
*/
|
|
|
|
|
getActions: function (mime, type, permissions) {
|
|
|
|
|
getActions: function(mime, type, permissions, filename) {
|
|
|
|
|
var actions = {};
|
|
|
|
|
if (this.actions.all) {
|
|
|
|
|
actions = $.extend(actions, this.actions.all);
|
|
|
|
|
@ -231,15 +234,29 @@
|
|
|
|
|
actions = $.extend(actions, this.actions[mime]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var filteredActions = {};
|
|
|
|
|
$.each(actions, function (name, action) {
|
|
|
|
|
if ((action.permissions === OC.PERMISSION_NONE) || (action.permissions & permissions)) {
|
|
|
|
|
var self = this;
|
|
|
|
|
$.each(actions, function(name, action) {
|
|
|
|
|
if (self.allowedPermissions(action.permissions, permissions) &&
|
|
|
|
|
self.allowedFilename(action.filename, filename)) {
|
|
|
|
|
filteredActions[name] = action;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return filteredActions;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allowedPermissions: function(actionPermissions, permissions) {
|
|
|
|
|
return (actionPermissions === OC.PERMISSION_NONE || (actionPermissions & permissions));
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
allowedFilename: function(actionFilename, filename) {
|
|
|
|
|
return (!filename || filename === '' || !actionFilename
|
|
|
|
|
|| actionFilename === '' || actionFilename === filename);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the default file action handler for the given conditions
|
|
|
|
|
*
|
|
|
|
|
@ -470,7 +487,8 @@
|
|
|
|
|
var actions = this.get(
|
|
|
|
|
fileInfoModel.get('mimetype'),
|
|
|
|
|
fileInfoModel.isDirectory() ? 'dir' : 'file',
|
|
|
|
|
fileInfoModel.get('permissions')
|
|
|
|
|
fileInfoModel.get('permissions'),
|
|
|
|
|
fileInfoModel.get('name')
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (actionName) {
|
|
|
|
|
@ -528,7 +546,8 @@
|
|
|
|
|
var actions = this.getActions(
|
|
|
|
|
this.getCurrentMimeType(),
|
|
|
|
|
this.getCurrentType(),
|
|
|
|
|
this.getCurrentPermissions()
|
|
|
|
|
this.getCurrentPermissions(),
|
|
|
|
|
this.getCurrentFile()
|
|
|
|
|
);
|
|
|
|
|
var nameLinks;
|
|
|
|
|
if ($tr.data('renaming')) {
|
|
|
|
|
@ -673,11 +692,11 @@
|
|
|
|
|
if (type === OC.dialogs.FILEPICKER_TYPE_COPY) {
|
|
|
|
|
context.fileList.copy(filename, targetPath, false, context.dir);
|
|
|
|
|
}
|
|
|
|
|
if (type === OC.dialogs.FILEPICKER_TYPE_MOVE) {
|
|
|
|
|
context.fileList.move(filename, targetPath, false, context.dir);
|
|
|
|
|
}
|
|
|
|
|
context.fileList.dirInfo.dirLastCopiedTo = targetPath;
|
|
|
|
|
}, false, "httpd/unix-directory", true, actions, dialogDir);
|
|
|
|
|
if (type === OC.dialogs.FILEPICKER_TYPE_MOVE) {
|
|
|
|
|
context.fileList.move(filename, targetPath, false, context.dir);
|
|
|
|
|
}
|
|
|
|
|
context.fileList.dirInfo.dirLastCopiedTo = targetPath;
|
|
|
|
|
}, false, "httpd/unix-directory", true, actions, dialogDir);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@ -777,6 +796,7 @@
|
|
|
|
|
* display name string for the action, or function that returns the display name.
|
|
|
|
|
* Defaults to the name given in name property
|
|
|
|
|
* @property {String} mime mime type
|
|
|
|
|
* @property {String} filename filename
|
|
|
|
|
* @property {int} permissions permissions
|
|
|
|
|
* @property {(Function|String)} icon icon path to the icon or function that returns it (deprecated, use iconClass instead)
|
|
|
|
|
* @property {(String|OCA.Files.FileActions~iconClassFunction)} iconClass class name of the icon (recommended for theming)
|
|
|
|
|
|