{# Render attribute row Parameters: title - attribute title value - attribute value additionalData - array with additional data #} {% macro attibuteRow(title, value, additionalData) %} {% macro attribute_data(value, additionalData) %} {% if value.value is not defined %}
{{ value }}
{% else %}
{{ value.value }}
{{ value.hint|trans }}
{% endif %} {% if additionalData|length %} {% for data in additionalData.data %}
{{ attribute(data, additionalData.field) }}
{% endfor %} {% endif %} {% endmacro %} {{ _self.renderAttribute(title, _self.attribute_data(value, additionalData)) }} {% endmacro %} {# Render attribute row with custom data block Parameters: title - row title data - row data #} {% macro renderAttribute(title, data) %}
{{ data|raw }}
{% endmacro %} {# Delete button with javascript handler Parameters - array: [ 'aCss' - additional css class for 'a' tag 'dataId' - data-id parameter 'dataMessage' - message before delete record 'dataRedirect' - url to redirect after delete 'dataUrl' - data-url parameter 'title' - button title 'label' - button label ] #} {% macro deleteButton(parameters) %} {{ parameters.label|trans -}} {% endmacro %} {# Button macros with custom button type Parameters - array: [ 'type' - button type 'class' - additional button css classes 'label' - label of button ] #} {% macro buttonType(parameters) %} {% endmacro %} {% macro saveAndStayButton(acl = '', label = 'Save') %} {% if acl is empty or resource_granted(acl) %} {{ _self.buttonType({ 'type': 'button', 'class': 'AknButton--apply AknButtonList-item', 'label': label, 'action': 'save_and_stay', 'iClass': 'icon-ok' }) }} {% endif %} {% endmacro %} {# Create scroll sub block for scroll block Parameters: title - title of sub block data - array with data fields (i.e. form_row() or attibuteRow() data) isForm - flag what scroll block mut contain the form #} {% macro scrollSubblock(title, data, isForm, class) %}
{% if title|length %}
{{ title|trans }}
{% endif %}
{% for dataBlock in data %} {{ dataBlock|raw }} {% endfor %}
{% endmacro %} {# Create scroll block for scroll data area Parameters: blockId - id of block title - block title 'subblocks' - array with scroll sub blocks: [ 'title' - title of sub block 'data' - array with data fields (i.e. form_row() or attibuteRow() data) ] isForm - flag what scroll block mut contain the form contentAttributes - additional attributes for block content useSubBlockDivider - indicates if 'row-fluid-divider' css class should be added to a row when there are more than one subblocks #} {% macro scrollBlock(blockId, title, subblocks, isForm, contentAttributes, useSubBlockDivider, isActive) %}
{% for subblock in subblocks %} {{ _self.scrollSubblock( subblock.title|length ? subblock.title : null, subblock.data, isForm, subblock.class is defined ? subblock.class : '' ) }} {% endfor %}
{% endmacro %} {# Create scroll blocks (like in view or update pages) Parameters: dataTarget - id of scroll block data - array with scroll data blocks form data parameter structure: [ 'dataBlocks' - array of blocks. each block consist of: [ 'title' - title of scroll block 'class' - additional css class for scroll block menu item 'useSubBlockDivider' - [optional] indicates if 'row-fluid-divider' css class should be added to a row when there are more than one subblocks 'subblocks' - array with scroll sub blocks: [ 'title' - title of sub block 'data' - array with data fields (i.e. form_row() or attibuteRow() data) ] ] 'formErrors' - errors from the form 'hiddenData' - additional data (hidden fields from the form) ] #} {% macro scrollData(dataTarget, data, form = null) %} {% if form is defined and form %} {% set isForm = true %} {% else %} {% set isForm = false %} {% endif %} {% set dataBlocks = data.dataBlocks %}
{% if data.formErrors is defined and data.formErrors | length%}
{{ data.formErrors|raw }}
{% endif %} {% for scrollBlock in dataBlocks %} {{ _self.scrollBlock( "scroll-" ~ loop.index, scrollBlock.title, scrollBlock.subblocks, isForm, scrollBlock.content_attr is defined ? scrollBlock.content_attr : null, scrollBlock.useSubBlockDivider is defined ? scrollBlock.useSubBlockDivider : true, loop.first ) }} {% endfor %} {% if data.hiddenData is defined or isForm %}
{% if data.hiddenData is defined %} {{ data.hiddenData|raw }} {% endif %} {% if isForm %} {{ form_rest(form) }} {% endif %}
{% endif %}
{% endmacro %} {# Render attributes of HTML element. Parameters: attr - attributes excludes - names of attributes which should not be rendered even if they exist in attr parameter #} {% macro attributes(attr, excludes) %} {% spaceless %} {% set attr = attr|default({}) %} {% for attrname, attrvalue in attr %}{% if not excludes is defined or not excludes[attrname] is defined %}{% if attrname in ['placeholder', 'title'] %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}" {% else %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endif %}{% endfor %} {% endspaceless %} {% endmacro %}