Skip to content

Custom Actions

ViUR defines Custom Actions as various ways to integrate interactive buttons into a handler. Since admin v4.9.0, the field clientActions can be used instead of customActions for defining actions.

The CustomAction definition is a dictionary that is mapped to an internal name, allowing it to be positioned under actions.

python

def adminInfo(self):
  return {
      "name": "User",
      "actions"      : ["mycustomaction"],
      "customActions": {
          "mycustomaction": {"name":"Test","action":"open","url":"https://www.viur.dev"}
      }
  }

Options

FieldDescriptionExample
nameDisplay nameMy Action
accessA list of access fields['root']
iconIcon definitionSee adminInfo
variantShoelace Button definitionSee Shoelace
outlineShoelace Button definitionSee Shoelace
show_labelAllows displaying only the icontrue oder false
actionMust be one of the following values: fetch,view,open,route,component,actionSee below
urlExternal or internal URL, or a route within the Admin interface./user/view/self
paramsParams are used with the view action to pass additional parameters to the handler.{'rootNode':"{{key}}"}
targetDisplays the action form in a popup instead of a tab.popup
fetch_methodSend action from as POST instead of GETPOST
enabledDefines when the button is active.True or Logics expression for selections
additionalEvalDataAdditional data provided to the logics expressions to determine whether a button is enabled or disabled.---
thenPerforms a module reload or vi reload after the action is executed.reload-module or reload-vi
confirmEnabled if defined a Confirm Popup with the defined textAre you sure?
successSuccess MessageAction was Successful

Supported Actions

Depending on the requirements, one of the following actions can be defined.

fetch

Calls a URL specified under url within the project. The fetch_method is taken into account. If an skey is required, it can be passed as a query parameter using a placeholder — for example: /myendpoint?skey={{skey}}.

After a successful request, the then action is executed (if defined), and the success message is displayed (if defined).

view

The view action refers to admin URLs, all located under /db/. The current selection is passed along as context and also includes any parameters defined in the corresponding CustomAction.

open

The open action can be used to open a URL in a new browser window.

route

The route action is used to open a tab in the Admin interface at a specific path, for example: /db/user/list. Custom routes created through modifications to the Admin interface can also be accessed in this way. The name and icon can be overridden by the values defined in the corresponding customAction.

component

A component previously defined in an Admin modification can be used as a complete replacement for the button. The component must include a prop named info, which receives the full customAction definition as its value.

action

Allows a form action to be displayed either as a popup or within a tab. @viur_selected_keys is included in the context when the action is executed.