You can use these custom buttons from custom HTML templates that you work with in your project.
To create a custom button you will need to set the following properties on your button:
-
data-toggle="react-modal"
-
data-target="#<id del modal>" (identificador único que elijas)
In addition, you must make an include of the template "base_customizable_add_document_modal.html" with the properties that you want indicating them with the "with". The available properties are the following:
- modalID (required) ➜ unique identifier you chose for the button's data-target property (must be the same, but without the "#" hash).
- parentDocumentUUID (optional) ➜ UUID of the parent document in case you want to create the new document as related to it. If not specified, the document will be created without being related to any.
- seriesUUID (optional) ➜ UUID of the space where the new document will be created. If not specified, it will allow the user to choose the space with a selector.
- documentTypeUUID (optional) ➜ UUID of the form with which the new document will be created. If not given, it will allow the user to choose the form with a selector.
- folderUUID (optional) ➜ UUID of the document folder in which the new document will be created inside. If not specified, it will not be created inside any folder.
- askForRequiredMetadata (optional) ➜ receives the values "true" or "false". In case of "true", the fields marked as required from the selected form will be requested in the creation. In case of not indicating it or indicating "false", it will not ask for them.
- openOnSamePage (optional) ➜ receives the values "true" or "false". In case of "true", when the document creation is done, it will redirect you in the same tab to the new document view. In case of not indicating it or indicating "false", it will open the newly created document in a new tab.
EXAMPLES
1. Custom button in the sidebar with unique identifier "custom-sidebar-button" whose properties are to ask for the required metadata and after creation redirect in the same tab to the view of the new document.
custom_sidebar.html
<li class="nav-item">
<a id="star" data-toggle="react-modal"
data-target="#custom-sidebar-button"
class="nav-link active">
<i class="nav-icon fal fa-star fa-fw" title=Custom></i>
<span class="masked">Custom</span>
</a>
</li>
{% include "base_customizable_add_document_modal.html" with openOnSamePage="true" askForRequiredMetadata="true" modalID="custom-sidebar-button" %}
Custom button in the document view with unique identifier "custom-document-button" whose properties indicated are the UUID of the space in which it is going to be created and the UUID of the parent document so that it is created as related to it. By not indicating openOnSamePage, it will open it in a new tab, and by not indicating askForRequiredMetadata, it will not ask for them in the creation.
{% load filetags %}
<a class="btn m-0" data-toggle="react-modal"
data-target="#custom-document-button"
title="Boton custom">
<i class="fal fa-star"></i>
</a>
{% include "base_customizable_add_document_modal.html" with modalID="custom-document-button" serieUUID=fil.serie.uuid parentDocumentUUID=fil.uuid %}
USEFUL CONDITIONS TO HIDE/SHOW BUTTONS
Here are some conditions you can use to control whether or not to show your custom buttons:
To show buttons if the user belongs to X group, encompass the buttons in the following condition:
{% with request.user.get_groups_names as group_names %}
{% if '<name_del_grupo>' in group_names %}
...
{% endif %}
{% endwith %}
To display the buttons only if the user is a super user, wrap the buttons in the following condition:
{% if request.user.is_superuser %}
...
{% endif %}
To display the buttons only if the user is super admin of the current team, include the buttons in the following condition:
{% if request.user.is_super_admin_team %}
...
{% endif %}
More information on GUI customization can be found in the following article Advanced user interface customization.
Comments
0 comments
Please sign in to leave a comment.