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",
|
"title": "APP.ACTIONS.DOWNLOAD",
|
||||||
"icon": "get_app",
|
"icon": "get_app",
|
||||||
"target": {
|
"target": {
|
||||||
"types": ["folder", "file"],
|
"types": ["file", "folder"],
|
||||||
"permissions": [],
|
"permissions": [],
|
||||||
"action": "aca:actions/download"
|
"action": "aca:actions/download",
|
||||||
|
"multiple": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,5 +33,6 @@ export interface ContentActionExtension {
|
|||||||
types: Array<string>;
|
types: Array<string>;
|
||||||
permissions: Array<string>,
|
permissions: Array<string>,
|
||||||
action: string;
|
action: string;
|
||||||
|
multiple?: boolean;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,12 +237,46 @@ export class ExtensionService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selection && selection.folder && types.includes('folder')) {
|
if (selection && !selection.isEmpty) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selection && selection.file && types.includes('file')) {
|
if (selection.nodes.length === 1) {
|
||||||
return true;
|
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;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user