Details about operations object for lists protocol.
diff --git a/ListsProtocol.wiki b/ListsProtocol.wiki index b88444f..ec5dcc1 100644 --- a/ListsProtocol.wiki +++ b/ListsProtocol.wiki
@@ -93,5 +93,66 @@ ---- == *operations* == +The _operations_ object is used in the protocol to define general behaviour of the list for buttons and rows actions. That is, you can define a number of buttons that will appear on top of the list, e.g. for add/edit/delete links (only consistent if you define {{{toolbar: [true, "top"]}}} in the _configurations_ object), and a default behaviour when a user clicks on a row of the list. Here an example explained: + +{{{ +"operations": { + "buttons": [ + { + "bounds": [0,"all"], + "id": "add", + "caption": "Add a user", + "type": "redirect_simple", + "parameters": { + "link": "http://add1", + "new_window": true + } + }, + { + "bounds": [1,1], + "id": "edit", + "caption": "Edit user(s)", + "type": "redirect_custom", + "parameters": { + "new_window": true + } + }, + { + "bounds": [1,"all"], + "id": "delete", + "caption": "Delete user(s)", + "type": "post", + "parameters": { + "url": "/user/roles", + "keys": ["key","link_id"], + "refresh": "table" + } + } + ], + "row" : { + "type": "redirect_custom", + "parameters": { + "new_window": true + } + } +} +}}} + +=== *buttons* === +The _buttons_ *array of objects* defines general behaviour for buttons displayed on the top of the list. Each object in the array has the following details: + * *bounds*: is an *array of integers* or an *array of an integer and the keyword "_all_"*. This array defines a range in which the button is enabled. The _"all"_ keyword is dynamically and automatically substituted with the number of records in the list. + * *id*: is a *string* that should define a _unique id_ for the button which is referred by _data/operations/buttons_ object. This unique id is limited to the _buttons_ array. IDs with the same name in different lists on the same page don't conflict. + * *caption*: is a *string* as shown to the end user (this can be customized for each row, see _data_operations_buttons_caption) + * *type*: is a *string* which defines the behaviour of the button. At the moment there are three different behaviours you can choose from for buttons: _"redirect_simple"_, _"redirect_custom"_ and _"post"_ (see below). + * *parameters*: is an *object* that defines (using key/value pairs) parameters for the method _type_ chosen. + +Following a list of methods allowed for buttons: + # *redirect_simple*: this type of behaviour is normally used when the button should be static and should always redirect to the same url (e.g. "Add user"). Parameters accepted are of the following types: {{{"link": "http://whatever"}}} (that is, a *string* with the url the button should redirect to) and {{{"new_window": true}}} (that is, a *boolean* which define whether the redirected page should be shown in a new window or not). + # *redirect_custom*: this type of behaviour is used when the button should dinamically change the link where the user should be redirected depending on which row is chosen (e.g. "Edit user") (see _data/operations/buttons/link_ and _data/operations/buttons/caption_). Only parameter accepted is {{{"new_window": true}}} (that is, a *boolean* which define whether the redirected page should be shown in a new window or not). + # *post*: this type of behaviour is used when the button should send something to the backend (e.g. a list of entities to delete). Parameters accepted are of following types: {{{"url": "http://whatever"}}} (that is, a *string* with the url the button should send data to the backend), {{{"keys": ["key","link_id"]}}} (that is, an *array of strings*: each string should be one of the _name_ key in the _colModel_ array, see _configuration/colModel_ and those will define which data should be sent back, using an array of objects, to the backend for each entity selected client side), {{{"refresh": "table"}}} is a *string* which determines whether the table should be refreshed or not: at the moment only "table" option is allowed, support for single "row" refreshing will be made some time in the future. + +=== *row* === +Row actions are allowed only if no {{{multiselect: true}}} is found in the _configuration_ object. Only *redirect_custom* method is allowed, with the same options as for _operations/buttons_. Details to define the url of each row in _data/operations/row_ details. + ---- == *data* == \ No newline at end of file