Implements the document menu actions for the Document List component.
NodeEntry): booleanNodeEntry - Item to receive an actionboolean - True if the action can be executed on this item, false otherwisestring): ContentActionHandlerstring - Identifier of the actionContentActionHandler - The handler for the actionstring, handler: ContentActionHandler): booleanstring - Identifier of the actionContentActionHandler - Handler for the actionboolean - False if the key was an empty/null string, true otherwiseThis service implements the built-in actions that can be applied to a document shown in a Document List component: delete, download, copy and move (see the Content Action component for further details and examples of these menu items). However, you can also use the service to add extra actions or replace the built-in ones with your own implementation.
In the example below, a custom handler called my-handler is registered with the service.
This action will invoke the myDocumentActionHandler function each time it is selected
from the Document List menu.
import { DocumentActionsService } from '@alfresco/adf-content-services';
class MyView {
constructor(documentActions: DocumentActionsService) {
documentActions.setHandler(
'my-handler',
this.myDocumentActionHandler.bind(this)
);
}
myDocumentActionHandler(obj: any) {
window.alert('my custom action handler');
}
}
The action can then be used from the component in the usual way:
<adf-document-list ...>
<content-actions>
<content-action
target="document"
title="My action"
handler="my-handler">
</content-action>
</content-actions>
</adf-document-list>
You can also override a built-in handler (eg, 'download') with your own function:
export class MyView {
constructor(documentActions: DocumentActionsService) {
documentActions.setHandler(
'download',
this.customDownloadBehavior.bind(this)
);
}
customDownloadBehavior(obj: any) {
window.alert('my custom download behavior');
}
}
You will probably want to set up all your custom actions at the application root level or with a custom application service.
© 2023 Alfresco Software, Inc. All Rights Reserved.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.