WoodWing Help Center

Action plugin - elvisContext

Elvis 5 action plug-in - elvisContext

The desktop client provides a loaded plug-in page with context information - elvisContext - about the current state of the client, this includes information like the currently selected assets or folders and information about the logged in user. The elvisContext also provides functions to perform actions inside the client, like open a search, activate a collection, close a tab, etc.

There are 2 ways context information can be provided to the plug-in page:

  1. For static HTML pages, a global JavaScript variable called elvisContext.
  2. For dynamic server side pages like ASP, JSP, PHP, as a POST variable called elvisContext, containing a JSON formatted String.

Note: Context properties are available for both static and dynamic pages, context functions are exclusively available for static HTML pages

Properties

The properties can be divided in application-wide properties, properties from the currently active tab and settings from the plug-in configuration.

elvisContext: {
   app { ... },
   activeTab { ... },
   plugin { ... }
}

Application object properties - app

Application-wide properties

serverUrl Elvis server URL.
queryString Top left search box value.
userProfile UserProfile object containing information on the user performing the action, check the example for property details.
pluginsRootUrl Active plug-ins folder URL.
pluginsBaseRootUrl Base plug-ins folder URL.

Currently active tab properties - activeTab

Properties from the currently active tab.

originalFolderSelection[] Array of simple Folder objects representing the folder selection before selection permissions are applied.
folderSelection[] Array of simple Folder objects representing the folder selection filtered by selection permissions.
originalAssetSelection[] Array of simple Hit objects containing a limited set of metadata fields. Represents the asset selection before selection permissions are applied and before containers are flattened.
assetSelection[] Array of simple Hit objects containing a limited set of metadata fields. Represents the asset selection containing assets from flattened containers and filtered by selection permissions.
queryString Tab search box value.

plug-in configuration - plug-in

plug-in configuration properties.

configProperties Object representation of the configuration properties defined in the plug-in configuration file.
messages[] Object representation of the messages defined in the plug-in configuration file.
pluginUrl plug-in folder URL.
pluginBaseUrl Base plug-in folder URL.

Example property context

The following example shows the context information after searching for "rocks" inside /Demo Zone/images, selecting the "Rocks" collection.

var elvisContext = {
   "plugin": {
      "messages": {
         "button.tooltip": "Show action debug information",
         "button.label": "Debug Info Tab",
         "title": "Action Debug info"
      },
      "configProperties": {
         "someCustomProperty2": {
            "description": "Description of someCustomProperty2, can be used for...",
            "name": "someCustomProperty2",
            "value": "bar"
         },
         "someCustomProperty1": {
            "description": "Description of someCustomProperty1, can be used for...",
            "name": "someCustomProperty1",
            "value": "foo"
         }
      },
      "pluginUrl": "http://localhost:8080/plugins/samples/action_plugins/debug/debug_tab",
      "pluginBaseUrl": "http://localhost:8080/plugins/plugin_base/action.base/debug.base"
   },
   "app": {
      "pluginsRootUrl": "http://localhost:8080/plugins",
      "pluginsBaseRootUrl": "http://localhost:8080/plugins/plugin_base",
      "userProfile": {
         "fullName": "admin",
         "groups": [],
         "userZone": "/Users/admin",
         "email": null,
         "username": "admin",
         "authorities": [
            "ROLE_AIR_CLIENT",
            "ROLE_CHECKOUT",
            "ROLE_DOWNLOAD",
            "ROLE_EMAIL",
            "ROLE_EXPORT_SCE",
            "ROLE_EXPORT_WEB",
            "ROLE_EXPORT_YOUTUBE",
            "ROLE_IMAGE_MANIPULATION",
            "ROLE_IMPORT",
            "ROLE_INDESIGN_CLIENT",
            "ROLE_PHOTOSHOP_CLIENT",
            "ROLE_REGENERATE_THUMBNAIL",
            "ROLE_SUPERUSER",
            "ROLE_USER",
            "ROLE_USER_ZONE"
         ]
      },
      "queryString": "rocks",
      "serverUrl": "http://localhost:8080"
   },
   "activeTab": {
      "originalAssetSelection": [
         {
            "folderPath": "/Demo Zone/Images/Nature",
            "assetDomain": "container",
            "id": "AWBJxHVhKbbAy4KMeyQHuB",
            "filename": "Rocks.collection",
            "assetPath": "/Demo Zone/Images/Nature/Rocks.collection",
            "extension": "collection",
            "name": "Rocks",
            "assetType": "collection"
         }
      ],
      "queryString": "rocks",
      "originalFolderSelection": [
         {
            "name": "/Images",
            "assetPath": "/Demo Zone/Images"
         }
      ],
      "assetSelection": [
         {
            "folderPath": "/Demo Zone/Images/Nature",
            "assetDomain": "image",
            "id": "Eg0PZaQ9qssAnB605OSP6r",
            "filename": "Grand Canyon 2.jpg",
            "assetPath": "/Demo Zone/Images/Nature/Grand Canyon 2.jpg",
            "extension": "jpg",
            "name": "Grand Canyon 2.jpg",
            "assetType": "jpg"
         },
         {
            "folderPath": "/Demo Zone/Images/Nature",
            "assetDomain": "image",
            "id": "CnYHegOHKeC9OrXWfu7moY",
            "filename": "Antelope Canyon.jpg",
            "assetPath": "/Demo Zone/Images/Nature/Antelope Canyon.jpg",
            "extension": "jpg",
            "name": "Antelope Canyon.jpg",
            "assetType": "jpg"
         },
         {
            "folderPath": "/Demo Zone/Images/Nature",
            "assetDomain": "image",
            "id": "D7CDZmtvqTSBrAH-j0_fA6",
            "filename": "Kerala.jpg",
            "assetPath": "/Demo Zone/Images/Nature/Kerala.jpg",
            "extension": "jpg",
            "name": "Kerala.jpg",
            "assetType": "jpg"
         }
      ],
      "folderSelection": [
         {
            "name": "/Images",
            "assetPath": "/Demo Zone/Images"
         }
      ]
   }
};

Functions

plug-in context functions are exclusively available from static HTML pages hosted inside the plug-ins folder.

Example JavaScript function calls

  • Open a search tab and search for obama

elvisContext.openSearch("obama");

  • Open a search tab and search for images sorted by status

elvisContext.openSearch("assetDomain:image", "status");

  • Open a search tab browsed to the "Demo Zone" folder, showing subfolders.

elvisContext.openBrowse("/Demo Zone", true);

  • Activate a collection

elvisContext.activateContainers("0JkPrbQc40g8RQIC1NI6uo");

Debug plug-ins

The debug plug-ins allow you easily review property values and test all functions, more info can be found in Debug plug-ins.

Was this article helpful?
0 out of 0 found this helpful / Created: / Updated:
Have more questions? Submit a request

0 Comments

Article is closed for comments.