{% extends bap.layout %} {% import '@OroUI/macros.html.twig' as UI %} {% oro_title_set({params : {"%name%": dashboard.getLabel() }}) %} {% block breadcrumb %} {% set breadcrumbs = [ {'label': 'oro.dashboard.menu.dashboards_tab.label'|trans }, {'label': dashboard.getLabel()|trans } ] %} {% include '@OroNavigation/Menu/breadcrumbs.html.twig' %} {% endblock breadcrumb %} {% block content %} {% set widgetIdPrefix = 'dashboard-widget-' ~ random() ~ '-' %} {% set allowEdit = is_granted('EDIT', dashboard.entity) %} {% set availableWidgets = [] %} {% for widgetName, widget in widgets %} {% if widget.acl is not defined or is_granted(widget.acl) %} {% set icon = asset(widget.icon|default("bundles/orodashboard/img/no_icon.png")) %} {% set title = widget.label|trans %} {% set description = '' %} {% if widget.description is defined %} {% set description = widget.description|trans %} {% endif %} {% set availableWidgets = availableWidgets|merge([{ 'dialogIcon': icon, 'iconClass': widget.icon_class|default(null), 'title': title, 'widgetName': widgetName, 'description': description, 'isNew': widget.isNew, 'configurationDialogOptions': widget.configuration_dialog_options }]) %} {% endif %} {% endfor %} {% set widgetIds = [] %} {% for widget in dashboard.widgets %} {% if widget.config.acl is not defined or is_granted(widget.config.acl) %} {% set widgetIds = widgetIds|merge([widgetIdPrefix ~ widget.id]) %} {% endif %} {% endfor %} {% set dashboardContainerOptions = { widgetIds: widgetIds, dashboardId: dashboard.id, columnsSelector: '.dashboard-column', allowEdit: allowEdit ? 'true' : 'false', availableWidgets: availableWidgets } %} {% import '@OroUI/macros.html.twig' as UI %}
{% block widgets_content %} {% set contentClass = contentClass|default('dashboard-container') %}
{% block widgets %} {% import _self as dashboardMacros %} {{ dashboardMacros.renderWidgetsColumn({ 'widgets': dashboard.getOrderedColumnWidgets(0, false, true), 'columnElementId': 'dashboard-column-0', 'columnClass': 'dashboard-column', 'widgetIdPrefix': widgetIdPrefix, 'allowEdit': allowEdit }) }} {{ dashboardMacros.renderWidgetsColumn({ 'widgets': dashboard.getOrderedColumnWidgets(1, true, false), 'columnElementId': 'dashboard-column-1', 'columnClass': 'dashboard-column', 'widgetIdPrefix': widgetIdPrefix, 'allowEdit': allowEdit }) }} {% endblock widgets %}
{% endblock widgets_content %}
{% endblock content %} {% macro renderWidgetsColumn(options) %}
{% for widget in options.widgets %} {% if widget.config.acl is not defined or is_granted(widget.config.acl) %} {{ oro_widget_render({ 'widgetType': 'dashboard-item', 'wid': options.widgetIdPrefix ~ widget.id, 'url': path(widget.config.route, widget.config.route_parameters|merge({'_widgetId': widget.id})), 'state': { 'id': widget.id, 'expanded': widget.expanded, 'layoutPosition': widget.layoutPosition, }, 'allowEdit': options.allowEdit, 'showConfig': options.allowEdit and widget.config.configuration|length > 0, 'widgetName': widget.entity.name, 'configurationDialogOptions': widget.config.configuration_dialog_options }) }} {% endif %} {% endfor %}
{% if options.allowEdit %} {{ 'oro.dashboard.empty_column_message.allowed'|trans|raw }} {% else %} {{ 'oro.dashboard.empty_column_message.denied'|trans }} {% endif %}
{% endmacro %}