Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time

Actions

Actions are some kind of tasks which should be performed after a process has been finished... E.g. let the user download a file.

Therefore you can define certain actions in the "Actions" Tab. callbackWindow

These actions are then shown in the "active processes panel" and in the Logs callbackWindow

Sometimes you want to set these actions programmatically. This can be done with:

use \Elements\Bundle\ProcessManagerBundle\Executor\Action;
#...


$downloadAction = new Action\Download();
$downloadAction
    ->setAccessKey('myIcon')
    ->setLabel('Download Icon')
    ->setFilePath('/public/bundles/elementsprocessmanager/img/sprite-open-item-action.png')
    ->setDeleteWithMonitoringItem(false);

$openItemAction = new Action\OpenItem();
$openItemAction
    ->setLabel('Open document')
    ->setItemId(1)
    ->setType('document');

$monitoringItem->setActions([
    $downloadAction,
    $openItemAction
]);

$monitoringItem->save();

Action Types:

Download

Provides a download button after the process has been finished. Programmatically creation:

$downloadAction = new Action\Download();
$downloadAction
    ->setAccessKey('myIcon')
    ->setLabel('Download Icon')
    ->setFilePath('/public/bundles/elementsprocessmanager/img/sprite-open-item-action.png')
    ->setDeleteWithMonitoringItem(false);
$monitoringItem->setActions([
    $downloadAction
]);

$monitoringItem->save();

Open Item

The "Open item" shows a button after the process is finished with which the user can open an object/document/asset.

Programmatically creation:

$openItemAction = new Action\OpenItem();
$openItemAction
    ->setLabel('Open document')
    ->setItemId(1) //id of the document/object/asset
    ->setType('document');
$monitoringItem->setActions([
    $openItemAction
]);

$monitoringItem->save();

JS Event

The JS Event fires a custom javascript event. In your Bundle you can perform custom actions... Lets assume you add an event with the event name "export.sayHello". Your Javscript part to hook into this event could be:

pimcoreReady: function (params, broker) {
        document.addEventListener('export.sayHello', function (e) {
            let detail = e.detail;
            let source = detail.source;
            let monitoringItem = detail.monitoringItem;
            let actionData = detail.actionData;
            let actionButtonPanel = detail.actionButtonPanel;
            let obj = detail.obj;
            let index = detail.index;

            //click in active process list
            if(source == 'activeProcessList'){
                if(monitoringItem.status == 'finished'){
                    let button = Ext.create('Ext.Button', {
                        text: actionData.label || 'Super Button',
                        icon : actionData.icon || '/bundles/pimcoreadmin/img/flat-color-icons/biohazard.svg',
                        style: (index > 0 ? 'margin-left:5px;' : ''),
                        scale: 'small',
                        handler: function() {
                            let eventData = actionData.eventData;
                            let data = null;
                            if(eventData){
                                data = Ext.decode(eventData);
                            }
                            console.log('Custom data:');
                            console.log(data);
                            alert('Hello from custom event :-)')
                        }
                    });
                    actionButtonPanel.items.add(button);
                }
            }

            //click from grid
            if(source == 'gridList'){
                if(monitoringItem.status == 'finished'){
                    let eventData = actionData.eventData;
                    let data = null;
                    if(eventData){
                        data = Ext.decode(eventData);
                    }
                    console.log('Custom data:');
                    console.log(data);
                    alert('Hello from custom event - Grid view :-)')
                }

            }


        }, false);
    }