How can a button be configured to run operations on the list of related documents?

Tabla de contenidos

Athento allows, in the list of related documents, adding buttons with custom behavior.

This is done with the datatable functionality to add buttons.

In the case of Athento, the Javascirpt code must be defined in a property called CUSTOM_RELATED_DOCUMENTS_BUTTONS in the file athentose/settings_custom/local_settings.py

 

An example configuration would be:

 

CUSTOM_RELATED_DOCUMENTS_BUTTONS  = "['copy', 'excel', 'selectAll', 'selectNone', \
{\
     text: 'Validate document',\
     action: function ( e, dt, node, config ) {\
        run_operations_on_related_documents([[192,'Validating document'], [193,'Changing status']]);\
 }\
}]"

 

Where you can see how they are defined:

  1. The list of usual buttons: ‘copy’, ‘excel’, etc.
  2. The custom button in that same list, which is defined with a “JSON” structure with the parameters “text” and “action“. As a value for “action” a function is assigned that calls the function run_operations_on_related_documents with a list of tuples. This list of tuples contains as its first value the identifier of the operation to execute and as its second value a message to display to the user while that operation is being executed.

In the above code, what would need to be parameterized in each case is shown in bold.