How launch actions/handler from share (MenuItem or widget)?

cancel
Showing results for 
Search instead for 
Did you mean: 
perenono
Partner

How launch actions/handler from share (MenuItem or widget)?

Hi,

     i have a set of action/handler create on 3.x version and i would like use this. But with alfresco 5.x 'run action wizard' not exist. I have see many post but always talk about run by rules. In my case is it not good, user need to launch from button/menu but i don't see code or just call to run action.

Have you an idea?

best regards

Noel

11 Replies
afaust
Master

Re: How launch actions/handler from share (MenuItem or widget)?

You can simply configure Share-tier actions for each of your Repository-tier actions via the share-config-custom.xml. That is what the default functions "onActionSimpleRepoAction" and "onActionFormDialog" are for. The former is used for non-parameterised actions while the latter allows you to show a (to be configured) form for your action so users can input parameter values.

See "Adding new actions to the DocumentLibrary" for details....

perenono
Partner

Re: How launch actions/handler from share (MenuItem or widget)?

Hi Axel,

   thanks i have make this and it's ok for action in doclibaction. But if i would like integrate to headerMenu i have no possibility?

best regards

Noel

afaust
Master

Re: How launch actions/handler from share (MenuItem or widget)?

Of course you can - that would then require configuring the necessary Aikau widgets and maybe some custom logic coding. Have you worked through the Aikau tutorials and learned about the Aikau basics? With the CrudService you should be able to call most GET/POST-based endpoints, and you could simply setup a MenuItem to publish an event to the CrudService to call the generic action form processor endpoint.

perenono
Partner

Re: How launch actions/handler from share (MenuItem or widget)?

Hi, thanks Axel

    i have read and test tutorial,   it's a little more clear. But how i can determinate url to launch action?

best regards

Noel

afaust
Master

Re: How launch actions/handler from share (MenuItem or widget)?

That's where you need to have a bit of understanding about the Alfresco web script or ReST endpoints. E.g. for calling an action from a Share document library action, with a form, the web script URI /alfresco/s/api/action/[actionName]/formprocessor (/alfresco/wcs/... for SSO-enabled web scripts) is typically called with a POST request containing the form inputs (parameters) for the action. For a "simple" action without a form, the URI /alfresco/s/api/actionQueue may be used. You'd need to make yourself familiar with the structure of the request body that they expect and provide your Aikau payload in a way that your parameters get passed on correctly.

Also note that from within Share, you typically do not call /alfresco/s/, but instead use the Share proxy URI

perenono
Partner

Re: How launch actions/handler from share (MenuItem or widget)?

Hi Axel,

    with you information i have succes to call in postman my action :

http://localhost:8080/alfresco/s/api/actionQueue  in POST with body :

{
actionDefinitionName:'ldap-user-import-action',
actionedUponNode:'workspace://SpacesStore/acc36eb8-2aa3-42cf-803e-36ec67702118'
}

   but i cannot send from AlfMenuItem and i don't find documentation to indicate how send body and use HTTP POST.

    i have try like this :

                       id: "HEADER_ACTION_inline-editable_BUTTON",
                       name: "alfresco/header/AlfMenuItem",
                       config:
                       {
                          id: "HEADER_ACTION_inline-editable_BUTTON",
                          label: "header.item.inline-editable",
                          iconClass: "global-usage",
                          targetUrl: "share/proxy/alfresco/api/actionQueue?actionDefinitionName=set-browseable-flag-action"

                       }
                    },
  my call is refused.
Have you an example please?
best regards
afaust
Master

Re: How launch actions/handler from share (MenuItem or widget)?

Instead of using targetUrl, you need to work with publishTopic + publishPayload to notify the CrudService (which you will need to include in the page's services) to send the appropriate POST request.

perenono
Partner

Re: How launch actions/handler from share (MenuItem or widget)?

Hi Axel,

    i have try many code, i don't see why when i clicked on menuItem, browser not launch call to server  (is it in overload of share-header.get.js).

    As you can see, for the moment i have just use crudservice code of aiku tutorial to validate call from my menu :

model.jsonModel.services.push("alfresco/services/CrudService");

var headerMenu = widgetUtils.findObject(model.jsonModel, "id", "HEADER_APP_MENU_BAR");

logger.log("search HEADER_APP_MENU_BAR");
if (headerMenu != null) {
    logger.log("find HEADER_APP_MENU_BAR");
    headerMenu.config.widgets.push({
        id: "HEADER_ACTION_LINK",
        name: "alfresco/menus/AlfMenuBarPopup",
        config: {
            id: "HEADER_ACTION_LINK",
            label: "header.menu.actions.label",
            widgets :[
                   {
                       id: "HEADER_ACTION_inline-editable_BUTTON",
                       name: "alfresco/header/AlfMenuItem",
                       config:
                       {
                               label: "header.item.inline-editable",
                            widgets: [
                                        {
                                           name: "alfresco/renderers/PublishAction",
                                           config: {
                                              iconClass: "delete-16",
                                              propertyToRender: "title",
                                              altText: "Delete {0}",
                                              publishTopic: "ALF_CRUD_DELETE",
                                              publishPayloadType: "PROCESS",
                                              publishPayload: {
                                                 requiresConfirmation: true,
                                                 url: "slingshot/datalists/list/node/{nodeRef}",
                                                 confirmationTitle: "Delete Data List",
                                                 confirmationPrompt: "Are you sure you want to delete '{title}'?",
                                                 successMessage: "Successfully deleted '{title}'"
                                              },
                                              publishPayloadModifiers: ["processCurrentItemTokens", "convertNodeRefToUrl"]
                                           }
                                        }
                                     ]

Have you an idea of my error?

thanks

Best regards

Noel

afaust
Master

Re: How launch actions/handler from share (MenuItem or widget)?

You do not need to include a "PublishAction" widget for this. The menu item itself is already capable of publishing (via the _AlfMenuItemMixin). In your constellation, the menu item does not know what to do (it is unaware of the PublishAction) and thus it's no wonder nothing is happening. Just move the publishXXX configuration values inside the config of the menu item and remote the PublishAction, and you should have a state that submits the DELETE request.

What I am wondering though is how you plan to mix in the node context. Header menu items do not have access to any node context by default, which is why I suggested adding the action to the document library instead in my first reply. Since you want to have it as a header menu item you need to add some kind of client-side code / logic that manages that node context so that the menu item can access it.