Extension Point: Document Library
Description:
In many extension projects you want to customize the Document Library in Alfresco Share. And quite often this involves adding new actions that can be applied to the content in the library. These actions are referred to as “DocLib” actions, and unlike a lot of other functionality in Content Services, they do not use web scripts to implement their business logic, at least not directly, instead they hook into custom, or out-of-the-box, client-side JavaScript code.
Each action has a 16x16 icon, one or more text labels, and configuration to hook them into the Share application. Most actions by their nature do something, and it’s likely that they will make a call back to the repository to perform their work, which may require a custom repository Action or a custom repository web script.
This tutorial will demonstrate how to add a DocLib action that can be used to send documents as attachments in an email. The “Send-as-Email” action will be available for documents in Browse view and Details view. The implementation of this action will make use of a form to collect the email data, such as where to send the email, subject, etc. The email will be sent by a custom repository Action that is invoked by an out-of-the-box JavaScript function.
The tutorial will also show how a web script can be called from a DocLib action in a an easy way. And finally we will look at how to create an action that displays an external Web page.
Implementation Steps:
Adding a new DocLib action to the Document Library involves the following steps:
- Configure the action so it is known to Share (typically in a Surf Extension Module)
- Configure where the action should be visible (typically in a Surf Extension Module)
- (Optionally) Configure a form for the action if it requires input from the end-user, such as asking for email address, email subject, etc (typically in a Surf Extension Module)
- Add a custom icon
- (Optionally) Add an evaluator if the action should be visible based on a condition, such as previously executed or not
- (Optionally) Add a status indicator, can for example be used to show if an action has been applied to a content item
- Implement custom client side JavaScript code that should be called when action is invoked, or use one of the out-of-the-box JavaScript functions (e.g. onActionFormDialog - displays a form and then calls a Repo Action, onActionSimpleRepoAction - calls a Repo Action)
- (Optionally) Implement any repository Action or repository web script that should be invoked by the action
As we can see, implementing a DocLib action can involve quite a few steps and take some time. However, it can also be very simple as we will see with our DocLib action example that navigates to the Google search home page.
Related Information:
This tutorial assumes that you are familiar with the Document Library in Share.
Source Code: Go to code
This tutorial assumes you have created a new SDK All-In-One project. To try out the Send-As-Email DocLib action in this tutorial you will need to install a local SMTP server such as Fake SMTP.
This tutorial will demonstrate the following:
- How to create a DocLib action that uses the out-of-the-box onActionFormDialog JavaScript function to collect data from the user via a form and then call a repository action with this data (Send-As-Email).
- How to create a DocLib action that invokes a custom JavaScript function and displays a message (Show-Custom-Message)
- How to create a DocLib action that invokes a custom repository web script (Call-Web-Script)
- How to create a DocLib action that navigates to an external web page (Go-To-Google)