mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
extensions: support multiselection for content actions
This commit is contained in:
+3
-2
@@ -212,9 +212,10 @@
|
||||
"title": "APP.ACTIONS.DOWNLOAD",
|
||||
"icon": "get_app",
|
||||
"target": {
|
||||
"types": ["folder", "file"],
|
||||
"types": ["file", "folder"],
|
||||
"permissions": [],
|
||||
"action": "aca:actions/download"
|
||||
"action": "aca:actions/download",
|
||||
"multiple": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -33,5 +33,6 @@ export interface ContentActionExtension {
|
||||
types: Array<string>;
|
||||
permissions: Array<string>,
|
||||
action: string;
|
||||
multiple?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -237,12 +237,46 @@ export class ExtensionService {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (selection && selection.folder && types.includes('folder')) {
|
||||
return true;
|
||||
}
|
||||
if (selection && !selection.isEmpty) {
|
||||
|
||||
if (selection && selection.file && types.includes('file')) {
|
||||
return true;
|
||||
if (selection.nodes.length === 1) {
|
||||
if (selection.folder && types.includes('folder')) {
|
||||
return true;
|
||||
}
|
||||
if (selection.file && types.includes('file')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
if (types.length === 1) {
|
||||
if (types.includes('folder')) {
|
||||
if (action.target.multiple) {
|
||||
return selection.nodes.every(node => node.entry.isFolder);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (types.includes('file')) {
|
||||
if (action.target.multiple) {
|
||||
return selection.nodes.every(node => node.entry.isFile);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return types.some(type => {
|
||||
if (type === 'folder') {
|
||||
return action.target.multiple
|
||||
? selection.nodes.some(node => node.entry.isFolder)
|
||||
: selection.nodes.every(node => node.entry.isFolder);
|
||||
}
|
||||
if (type === 'file') {
|
||||
return action.target.multiple
|
||||
? selection.nodes.some(node => node.entry.isFile)
|
||||
: selection.nodes.every(node => node.entry.isFile);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user