{% macro collection_prototype(widget) %} {% if 'prototype' in widget.vars|keys %} {% set form = widget.vars.prototype %} {% set name = widget.vars.prototype.vars.name %} {% else %} {% set form = widget %} {% set name = widget.vars.full_name %} {% endif %}
{{ form_errors(form) }} {% if form.children|length %} {% for child in form %} {{ form_errors(child) }} {{ form_widget(child) }} {% endfor %} {% else %} {{ form_widget(form) }} {% endif %} {{ form_rest(form) }}
{% endmacro %} {% macro tooltip(tooltip, tooltip_parameters, tooltip_placement, details_enabled, details_link, details_anchor) %} {% set tooltip_parameters = tooltip_parameters|default({}) %} {% set tooltip = tooltip|trans(tooltip_parameters, "tooltips") %} {% if tooltip is not empty %} {% set details_anchor = details_anchor|default(null) %} {% set details_link = details_link|default(null) %} {% set details_enabled = details_enabled|default(false) %} {% set tooltip_placement = tooltip_placement|default(null) %} {# Help link logic #} {% if details_enabled or details_anchor or details_link %} {% set helpLink = details_link|default(get_help_link()) %} {% if details_anchor %} {% set helpLink = helpLink ~ '#' ~ details_anchor %} {% endif %} {% set tooltip = tooltip ~ '
' ~ 'oro.form.tooltip.read_more'|trans ~ '
' %} {% endif %} {# End help link logic #} {% set tooltip = '
' ~ tooltip ~ '
' %} {% endif %} {% endmacro %} {# Render attribute row Parameters: title - attribute title value - attribute value additionalData - array with additional data #} {% macro attibuteRow(title, value, additionalData) %} {% set attributeValue %}
{% if value.value is not defined %}
{{ value }}
{% else %}
{{ value.value }} {{ value.hint }}
{% endif %}
{% if additionalData|length %} {% for data in additionalData.data %}
{{ attribute(data, additionalData.field) }}
{% endfor %} {% endif %} {% endset %} {{ _self.renderAttribute(title, attributeValue) }} {% endmacro %} {# Render attribute row with custom data block Parameters: title - row title data - row data #} {% macro renderAttribute(title, data) %}
{{ data|raw }}
{% endmacro %} {# Render property block Parameters: title - property title data - property data #} {% macro renderProperty(title, data) %} {{ _self.renderHtmlProperty(title, data|escape) }} {% endmacro %} {# Render html property block Parameters: title - property title data - property data #} {% macro renderHtmlProperty(title, data) %} {{ _self.renderAttribute(title, '
' ~ data|default('oro.ui.empty'|trans) ~ '
') }} {% endmacro %} {# Create the link Parameters - array: [ 'path' - button url 'class' - default class 'aCss' - additional button class 'title' - button title 'iCss' - css class for 'i' tag (icon) 'label' - button label ] #} {% macro link(parameters) %} {# need to remove spaces just before label #} {% set iconHtml = '' %} {% if parameters.iCss is defined %} {% set iconHtml %} {% endset %} {% else %} {% endif %} {% spaceless %} {{ iconHtml|trim|raw }}{{ parameters.label|trim }} {% endspaceless %} {% endmacro %} {# Create the button Parameters - array: [ 'path' - button url 'aCss' - additional button class 'title' - button title 'iCss' - css class for 'i' tag (icon) 'label' - button label ] #} {% macro button(parameters) %}
{{ _self.link(parameters|merge({'class': 'btn back icons-holder-text'})) }}
{% endmacro %} {# Create dropdown button Parameters - array: [ 'label' - button label 'elements' - dropdown elements 'html' - html from placeholder 'aCss' - additional drop down class ] #} {% macro dropdownButton(parameters) %}
{% if parameters.iCss is defined %} {% endif %} {{ parameters.label }}
{% endmacro %} {# Create the dropdown button item Parameters - array: [ 'path' - button url 'aCss' - additional button class 'title' - button title 'iCss' - css class for 'i' tag (icon) 'label' - button label ] #} {% macro dropdownItem(parameters) %}
  • {{ _self.link(parameters) }}
  • {% endmacro %} {# Create the dropdown button wich preserves last used button Parameters - array: [ 'html' - original buttons markup 'groupKey' - key, to remember last used button 'options' - options for pinnedDropdownButtonProcessor widget ] #} {% macro pinnedDropdownButton(parameters) %} {% if isDesktopVersion() %} {% set options = parameters.options|default({})|merge({ groupKey: parameters.groupKey is defined ? parameters.groupKey : '', useMainButtonsClone: true }) %}
    {{ parameters.html|raw }}
    {% else %} {{ parameters.html|raw }} {% endif %} {% endmacro %} {# Predefiend pinnedDropdownButton's settings for save button #} {% macro dropdownSaveButton(parameters) %} {% set parameters = { 'groupKey': 'saveButtons', 'options': { 'moreButtonAttrs': { 'class': 'btn-success' } } }|merge(parameters|default({})) %} {{ _self.pinnedDropdownButton(parameters) }} {% endmacro %} {# Create 'Cancel' button Parameters 'path' - button url 'label' - button label | 'Cancel' by default #} {% macro cancelButton(path, label) %} {% if label is empty %} {% set label = 'Cancel'|trans %} {% endif %} {{ _self.button({'path' : path, 'title' : label, 'label' : label}) }} {% endmacro %} {# Create 'Edit' button Parameters - array: [ 'path' - button url 'aCss' - additional button class 'title' - button title | 'Edit' by default 'label' - button label | 'Edit' by default 'entity_label' - if specified will be added for title and label ] #} {% macro editButton(parameters) %} {% set iCss = ['icon-edit'] %} {% set aCss = ['edit-button', 'main-group'] %} {% if parameters.iCss is defined %} {% set iCss = parameters.iCss|split(' ')|merge(iCss) %} {% endif %} {% if parameters.aCss is defined %} {% set aCss = parameters.aCss|split(' ')|merge(aCss) %} {% endif %} {% if parameters.title is defined %} {% set title = parameters.title %} {% else %} {% set title = parameters.entity_label is defined ? 'oro.ui.edit_entity'|trans({'%entityName%': parameters.entity_label}) : 'oro.ui.edit'|trans %} {% endif %} {% set label = parameters.label is defined ? parameters.label : 'oro.ui.edit'|trans %} {% set parameters = parameters|merge({ 'iCss': iCss|join(' '), 'aCss': aCss|join(' '), 'title': title, 'label': label }) %} {{ _self.button(parameters) }} {% endmacro %} {# Create 'add' button Parameters - array: [ 'path' - button url 'aCss' - additional button class 'title' - button title | 'Create' by default 'label' - button label | 'Create' by default 'entity_label' - if specified will be added for title and label ] #} {% macro addButton(parameters) %} {% if parameters.label is defined %} {% set label = parameters.label %} {% else %} {% set label = parameters.entity_label is defined ? 'oro.ui.create_entity'|trans({'%entityName%': parameters.entity_label}) : 'oro.ui.create'|trans %} {% endif %} {% if parameters.title is defined %} {% set title = parameters.title %} {% else %} {% set title = parameters.entity_label is defined ? 'oro.ui.create_entity'|trans({'%entityName%': parameters.entity_label}) : 'oro.ui.create'|trans %} {% endif %} {{ label }} {% endmacro %} {# Delete button with javascript handler Parameters - array: [ 'aCss' - additional css class for 'a' tag 'dataId' - data-id parameter 'dataMessage' - message before delete record | 'Are you sure you want to delete this %entity_label%?' by default 'dataRedirect' - url to redirect after delete | '%entity_label% deleted' by default 'dataUrl' - data-url parameter 'title' - button title | 'Delete' by default 'label' - button label | 'Delete' by default 'entity_label' - if specified will be added for title, label and messages| 'item' by default 'disabled' - if true this control is rendered as disabled ] #} {% macro deleteButton(parameters) %} {% set aCss = 'btn icons-holder-text' %} {% if parameters.disabled is defined and parameters.disabled %} {% set aCss = aCss ~ ' disabled' %} {% endif %} {% if parameters.aCss is defined %} {% set aCss = aCss ~ ' ' ~ parameters.aCss %} {% endif %} {% set parameters = parameters|merge({'aCss': aCss}) %}
    {{ _self.deleteLink(parameters) }}
    {% endmacro %} {% macro deleteLink(parameters) %} {% set entityLabel = parameters.entity_label is defined ? parameters.entity_label : 'oro.ui.item'|trans %} {% set label = parameters.label is defined ? parameters.label : 'oro.ui.delete'|trans %} {% if parameters.title is defined %} {% set title = parameters.title %} {% else %} {% set title = parameters.entity_label is defined ? 'oro.ui.delete_entity'|trans({'%entityName%': parameters.entity_label}) : 'oro.ui.delete'|trans %} {% endif %} {% set message = parameters.dataMessage is defined ? parameters.dataMessage : 'oro.ui.delete_confirm'|trans({ '%entity_label%' : entityLabel }) %} {% set successMessage = parameters.successMessage is defined ? parameters.successMessage : 'oro.ui.delete_message'|trans({ '%entity_label%' : entityLabel }) %} {% set url = parameters.dataUrl is defined ? parameters.dataUrl : '' %} {% set linkParams = { 'data': { 'message': message, 'success-message': successMessage, 'url': url }, 'iCss': 'icon-trash', 'aCss': parameters.aCss, 'title': title, 'label': label, 'path': 'javascript:void(0);' } %} {% if (parameters.dataId is defined) %} {% set data = linkParams.data|merge({'id': parameters.dataId}) %} {% set linkParams = linkParams|merge({ 'data': data }) %} {% endif %} {% if parameters.dataRedirect is defined %} {% set data = linkParams.data|merge({'redirect': parameters.dataRedirect}) %} {% set linkParams = linkParams|merge({ 'data': data }) %} {% endif %} {% if parameters.data is defined %} {% for dataItemName,dataItemValue in parameters.data %} {% set data = linkParams.data|merge({(dataItemName): dataItemValue}) %} {% set linkParams = linkParams|merge({ 'data': data }) %} {% endfor %} {% endif %} {{ _self.link(linkParams) }} {% endmacro %} {# A button with javascript handler Parameters - array: [ 'class' - default class 'aCss' - additional css class for 'a' tag 'iCss' - additional css class for 'i' tag 'dataId' - data-id parameter 'dataUrl' - data-url parameter 'dataRedirect' - url to redirect after an operation finished 'successMessage' - a message which will be shown after an operation finished 'title' - button title 'label' - button label 'visible' - determined whether the button is visible or not. Defaults to true, 'dataAttributes' - additional data attributes ] #} {% macro clientLink(parameters) %} {% endmacro %} {% macro renderWidgetDataAttributes(options) %} {{ _self.renderAttributes(options, 'widget') }} {% endmacro %} {% macro renderAttributes(options, prefix) %} {% for name, value in options %} {% if (value is iterable) %} {% set value = value|json_encode(constant('JSON_FORCE_OBJECT')) %} {% endif %} data-{% if prefix is not empty %}{{ prefix }}-{% endif %}{{ name }}="{{ value }}" {% endfor %} {% endmacro %} {# A button with javascript handler Parameters - array: [ 'class' - default class 'aCss' - additional css class for 'a' tag 'iCss' - additional css class for 'i' tag 'dataId' - data-id parameter 'dataUrl' - data-url parameter 'dataRedirect' - url to redirect after an operation finished 'successMessage' - a message which will be shown after an operation finished 'title' - button title 'label' - button label 'visible' - determined whether the button is visible or not. Defaults to true ] #} {% macro clientButton(parameters) %}
    {{ _self.clientLink(parameters|merge({'class': 'btn icons-holder-text'})) }}
    {% endmacro %} {# A button with javascript handler Parameters - array: [ 'class' - default class 'aCss' - additional css class for 'a' tag 'iCss' - additional css class for 'i' tag 'dataId' - data-id parameter 'dataUrl' - data-url parameter 'dataRedirect' - url to redirect after an operation finished 'successMessage' - a message which will be shown after an operation finished 'title' - button title 'label' - button label 'visible' - determined whether the button is visible or not. Defaults to true ] #} {% macro dropdownClientItem(parameters) %}
  • {{ _self.clientLink(parameters) }}
  • {% 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 saveAndCloseButton(label) %} {% if label is empty %} {% set label = 'Save and Close'|trans %} {% endif %} {{ _self.buttonType({'type': 'submit', 'class': 'btn-success', 'label': label}) }} {% endmacro %} {% macro saveAndStayButton(label) %} {% if label is empty %} {% set label = 'Save'|trans %} {% endif %} {{ _self.buttonType({'type': 'button', 'class': 'btn-success main-group', 'label': label, 'action': 'save_and_stay'}) }} {% endmacro %} {# Separator between buttons #} {% macro buttonSeparator() %}
    {% 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 useSpan - flag to indicate is subblock must have css class specified in spanClass parameter or not spanClass - css class name of subblock, if this parameter is not specified the css class is span6 #} {% macro scrollSubblock(title, data, isForm, useSpan, spanClass) %} {% set spanClass = spanClass|default('responsive-cell') %} {#% if useSpan is not defined or useSpan == true %} {% set span = spanClass %} {% else %} {% set span = '' %} {% endif %} {% if span %}
    {% endif %#}
    {% if title|length %}
    {{ title }}
    {% endif %} {% for dataBlock in data %} {{ dataBlock|raw }} {% endfor %}
    {#% if span %}
    {% endif %#} {% 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) %} {% set cols = subblocks|length %}

    {{ title }}

    {% if isForm is defined and isForm == true %}
    {% else %}
    {% endif %} {% for subblock in subblocks %} {{ _self.scrollSubblock(subblock.title is defined and subblock.title|length ? subblock.title : null, subblock.data, isForm, subblock.useSpan is defined ? subblock.useSpan : true, subblock.spanClass is defined ? subblock.spanClass : '') }} {% endfor %} {% if isForm is defined and isForm == true %}
    {% else %}
    {% endif %}
    {% 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 'priority' - a number that can be used to change the order of blocks '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|oro_sort_by %}
    {% 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) }} {% 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 %} {# Create collection field block Parameters: field - form collection field label - label of block buttonCaption - Caption of add entity button #} {% macro collectionField(field, label, buttonCaption) %}
    {% for emailField in field.children %} {{ _self.collection_prototype(emailField) }} {% endfor %}
    {{ buttonCaption }}
    {% 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 %} {# Render link to entity owner Parameters: entity - entity record #} {% macro entityOwnerLink(entity) %} {%- if entity.owner is defined and entity.owner %} {% if resource_granted('VIEW', entity.owner) %} {% set ownerType = oro_get_owner_type(entity) %} {% if (ownerType == 'USER') %} {% set ownerPath = path('oro_user_view', {'id': entity.owner.id}) %} {% set ownerName = entity.owner|oro_format_name %} {% elseif (ownerType == 'BUSINESS_UNIT') %} {% set ownerPath = path('oro_business_unit_view', {'id': entity.owner.id}) %} {% set ownerName = entity.owner.name %} {% elseif (ownerType == 'ORGANIZATION') %} {% set ownerName = entity.owner.name %} {% endif %} {% if ownerName is defined %} {{ 'oro.ui.owner'|trans }}: {% if ownerPath is defined %} {{ ownerName }} {% else %} {{ ownerName }} {% endif %} {% endif %} {% endif %} {% endif -%} {% endmacro %} {%- macro renderUrl(url, title, class) -%} {% spaceless %} {% if title is empty %} {% set title = url %} {% endif %} {% if class is empty %} {% set class = '' %} {% endif %} {% if url is not empty %} {{ title }} {% endif %} {% endspaceless %} {%- endmacro -%} {%- macro renderPhone(phone, title) -%} {% if title is empty %} {% set title = phone %} {% endif %} {% if phone is not empty %} {{ title }} {% endif %} {%- endmacro -%} {% macro getApplicableForUnderscore(str) %} {{ str|replace({ "', "', "<%": '<% print("<" + "%"); %>', "%>": '<% print("%" + ">"); %>', })|raw }} {% endmacro %}