{% macro icon(icon) %} {% endmacro %} {%- macro page_actions(tools) -%} {%- endmacro -%} {%- macro entity_actions(tools) -%} {%- endmacro -%} {% macro page_header(title) %} {% endmacro %} {% macro label_boolean(visible) %} {% if visible %} {{ _self.label('yes'|trans, 'success') }} {% else %} {{ _self.label('no'|trans, 'default') }} {% endif %} {% endmacro %} {% macro label_visible(visible) %} {{ _self.label_boolean(visible) }} {% endmacro %} {% macro label_role(role) %} {% set color = 'primary' %} {% if role == 'ROLE_SUPER_ADMIN' %} {% set color = 'danger' %} {% elseif role == 'ROLE_ADMIN' %} {% set color = 'warning' %} {% elseif role == 'ROLE_TEAMLEAD' %} {% set color = 'success' %} {% elseif role == 'ROLE_USER' %} {% set color = 'gray' %} {% endif %} {{ _self.label(role|trans, color) }} {% endmacro %} {% macro username(user) %} {{- user.displayName -}} {% endmacro %} {% macro label_user(user) %} {{ _self.label(user.displayName, 'primary') }} {% endmacro %} {% macro label_team(team, class) %} {{ _self.label(team.name, class|default('primary')) }} {% endmacro %} {% macro user_avatar(user, tooltip, class) %} {% set avatar = avatar(user, admin_lte_context.default_avatar) %} {% if tooltip is same as (false) %} {{ user.displayName }} {% else %} {{ user.displayName }} {% endif %} {% endmacro %} {% macro label_activity(activity, url) %} {% set isVisible = activity.visible %} {% set color = activity.color %} {% if color is empty and activity.project is not null %} {% set color = activity.project.color ?? activity.project.customer.color %} {% endif %} {% if isVisible and not activity.project is null %} {% set isVisible = activity.project.visible %} {% if isVisible and not activity.project.customer is null %} {% set isVisible = activity.project.customer.visible %} {% endif %} {% endif %} {{ _self.label_color_dot('activity', isVisible, activity.name, url, color) }} {% endmacro %} {% macro label_project(project, url) %} {% set isVisible = false %} {% if project.visible and project.customer.visible %} {% set isVisible = true %} {% endif %} {{ _self.label_color_dot('project', isVisible, project.name, url, (project.color ?? project.customer.color)) }} {% endmacro %} {% macro label_customer(customer, url) %} {{ _self.label_color_dot('customer', customer.visible, customer.name, url, customer.color) }} {% endmacro %} {% macro label_color_dot(type, isVisible, name, url, color) %} {%- if url is not empty -%} {{ name }} {%- else -%} {{ name }} {%- endif -%} {% endmacro %} {% macro color_dot(color, tooltip) %} {% endmacro %} {% macro badge_team_access(teams) %} {% if teams|length > 0 %} {{ _self.badge_counter(teams|length) }} {% else %} {{ _self.icon('unlocked') }} {% endif %} {% endmacro %} {% macro badge_counter(count, url) %} {% if url %} {{ count }} {% else %} {{ count }} {% endif %} {% endmacro %} {% macro label(title, type, tooltip) %} {# success, warning, danger, primary #} {{ title }} {% endmacro %} {% macro badge(title, color) %} {{ title }} {% endmacro %} {% macro alert(type, description, title, icon) %}
{% if title and icon %}

{{ title|trans }}

{{ description|trans }} {% elseif icon %}

{{ description|trans }}

{% else %} {{ description|trans }} {% endif %}
{% endmacro %} {% macro callout(type, description, title, icon) %}
{% if title %}

{% if icon %}{% endif %} {{ title|trans }}

{% endif %}

{{ description|trans }}

{% endmacro %} {% macro info_box_progress(title, description, amount, percentage, icon, color) %}
{{ title|trans }} {{ amount }}
{{ description }}
{% endmacro %} {% macro button_group_dropdown(title, actions) %}
{% endmacro %} {% macro table_actions(actions, class) %} {% if actions|length >= 1 %} {% if class is null %} {% set class = 'btn-sm' %} {% endif %} {% set trash = null %} {% set divider = false %} {% endif %} {% endmacro %} {% macro list_group_actions(actions, highlightUrl) %} {% if actions|length > 0 %}
{% for icon, values in actions %} {% if 'divider' in icon and values is null %}
{# #} {% else %} {% if values is not iterable %} {% set values = {'url': values} %} {% endif %} {% if values['children'] is defined %} {{ _self.list_group_actions(values['children'], highlightUrl) }} {% else %} {% if values['title'] is not defined %} {% set values = values|merge({'title': icon|trans({}, 'actions')}) %} {% endif %} {% set class = 'list-group-item' %} {% if highlightUrl == values.url %} {% set class = class ~ ' active' %} {% endif %} {% set values = values|merge({'class': class}) %} {{ _self.action_button(icon, values, false) }} {% endif %} {% endif %} {% endfor %}
{% endif %} {% endmacro %} {% macro action_button(icon, values, type) %} {%- apply spaceless -%} {% set id = null %} {% set onclick = null %} {% set modal = null %} {% set toggle = null %} {% set url = null %} {% set target = null %} {% set title = null %} {% set disabled = false %} {% set attr = {} %} {% set translation_domain = 'messages' %} {% if type is same as (false) %} {% set class = "" %} {% elseif type is null %} {% set class = "btn btn-default btn-" ~ icon ~ " " %} {% else %} {% set class = "btn btn-" ~ type ~ " btn-" ~ icon ~ " " %} {% endif %} {% if values is not iterable %} {% set url = values %} {% if 'onclick:' in url %} {% set onclick = url|replace({'onclick:': ''}) %} {% set url = '#' %} {% endif %} {% if '#collapse' in url %} {% set toggle = 'collapse' %} {% endif %} {% if '#modal' in url %} {% set modal = url %} {% set url = '#' %} {% endif %} {% else %} {% set icon = values.icon ?? icon %} {% set disabled = values.disabled ?? false %} {% set url = values.url ?? '#' %} {% set onclick = values.onclick ?? null %} {% set modal = values.modal ?? null %} {% set toggle = values.toggle ?? null %} {% set target = values.target ?? null %} {% set id = values.id ?? null %} {% set title = values.title ?? null %} {% set class = class ~ ( values.class | default("")) %} {% set attr = values.attr ?? {} %} {% set translation_domain = values.translation_domain ?? translation_domain %} {% endif %} {% if disabled is same as (true) %} {% set class = class ~ " disabled" %} {% endif %} {% if title is not null %}{{ title|trans({}, translation_domain) }}{% else %}{{ _self.icon(icon) }}{% endif %} {% endapply %} {% endmacro %} {% macro button_group(actions, type) %}
{%- apply spaceless -%} {%- for icon,values in actions %} {% if 'divider' in icon and values is null %} {# what to do here ? #} {% else %} {% if values.children is defined %}
{% else %} {{ _self.action_button(icon, values, type) }} {% endif %} {% endif %} {% endfor -%} {% endapply %}
{% endmacro %} {% macro button_action(icon, url) %} {{ macro.icon(icon) }} {% endmacro %} {% macro tag_list(taglist) %} {% import _self as macro %} {% for tag in taglist %} {{ macro.badge(tag.name, tag.color|default('#00a65a')) }} {% endfor %} {% endmacro %} {% macro form_type_value(type, value, entity) %} {% import _self as widgets %} {% if '\\ColorPickerType' in type %} {{ widgets.color_dot(value, value) }} {% elseif '\\DurationType' in type %} {{ value|duration }} {% elseif '\\YesNoType' in type or '\\CheckBoxType' in type %} {{ widgets.label_boolean(value) }} {% elseif '\\DatePickerType' in type %} {{ value|date_short }} {% elseif '\\DateTimePickerType' in type %} {{ value|date_full }} {% elseif '\\CountryType' in type %} {{ value|country }} {% elseif '\\CurrencyType' in type %} {{ value|currency }} {% elseif '\\LanguageType' in type %} {{ value|language }} {% elseif '\\MoneyType' in type %} {% if entity is null %} {{ value }} {% elseif class_name(entity) == 'App\\Entity\\Timesheet' %} {{ value|money(entity.project.customer.currency) }} {% elseif class_name(entity) == 'App\\Entity\\Customer' %} {{ value|money(entity.currency) }} {% elseif class_name(entity) == 'App\\Entity\\Project' %} {{ value|money(entity.customer.currency) }} {% elseif class_name(entity) == 'App\\Entity\\Activity' and entity.project is not null %} {{ value|money(entity.project.customer.currency) }} {% else %} {{ value }} {% endif %} {% elseif '\\TextareaType' in type %} {{ value|nl2br }} {% elseif '\\EmailType' in type %} {{ value }} {% elseif '\\UrlType' in type %} {{ value }} {% else %} {{ value }} {% endif %} {% endmacro %} {% macro team_list(teams, showTitle, collapseAt) %} {% set collapseAt = collapseAt ?? 5 %} {% if showTitle is null %} {% set showTitle = true %} {% endif %} {% import _self as macro %} {% if showTitle %} {% endif %} {% for team in teams|sort((a, b) => a.name <=> b.name) %} {% set users = team.users|filter(u => u.enabled) %} {% set userTeamCount = users|length %} {% endfor %}
{{ 'label.team'|trans }} {{ 'label.user'|trans }}
{{ team.name }} {{ macro.user_avatar(team.teamlead, ('label.teamlead'|trans ~ ': ' ~ team.teamlead.displayName), 'teamlead') }} {% set teamHiddenId = 'team_' ~ team.id ~ '_hiddenUser' ~ random() %} {% set counter = 0 %} {% for user in users %} {% if user != team.teamlead %} {{ macro.user_avatar(user) }} {% set counter = counter + 1 %} {% endif %} {% if userTeamCount > collapseAt and counter == (collapseAt - 1) and loop.index != userTeamCount %} {{ 'label.plus_more'|trans({'%count%': (userTeamCount - collapseAt)}) }} {% endif %} {% endfor %}
{% endmacro %} {% macro nothing_found(events) %} {{ _self.callout('warning', 'error.no_entries_found') }} {% if events is not empty %} {% endif %} {% endmacro %} {# To be used like this: #} {% macro class_customer_row(customer, now) %} {%- if not customer.visible %}warning{% endif -%} {% endmacro %} {# To be used like this: #} {% macro customer_row_attr(customer, now) %} {%- set class = _self.class_customer_row(customer, now) %} {% set dataHref = '' %} {% if is_granted('view', customer) %} {% set class = class ~ ' alternative-link open-edit' %} {% set dataHref = path('customer_details', {'id': customer.id}) %} {% endif -%} class="{{ class }}" data-href="{{ dataHref }}" {% endmacro %} {# To be used like this: #} {% macro class_project_row(project, now) %} {%- if not project.visible or (project.end is not null and project.end < now) %}warning{% endif -%} {% endmacro %} {# To be used like this: #} {% macro project_row_attr(project, now) %} {%- set class = _self.class_project_row(project, now) %} {% set dataHref = '' %} {% if is_granted('view', project) %} {% set class = class ~ ' alternative-link open-edit' %} {% set dataHref = path('project_details', {'id': project.id}) %} {% endif -%} class="{{ class }}" data-href="{{ dataHref }}" {% endmacro %} {# To be used like this: #} {% macro class_activity_row(activity, now) %} {%- if not activity.visible %}warning{% endif -%} {% endmacro %} {# To be used like this: #} {% macro activity_row_attr(activity, now) %} {%- set class = _self.class_activity_row(activity, now) %} {% set dataHref = '' %} {% if is_granted('view', activity) %} {% set class = class ~ ' alternative-link open-edit' %} {% set dataHref = path('activity_details', {'id': activity.id}) %} {% endif -%} class="{{ class }}" data-href="{{ dataHref }}" {% endmacro %} {# To be used like this: #} {% macro class_user_row(user) %} {%- if not user.enabled %}warning{% endif -%} {% endmacro %} {# To be used like this: #} {% macro user_row_attr(user) %} {%- set class = _self.class_user_row(user) %} {% set dataHref = '' %} {% if is_granted('view', user) %} {% set class = class ~ ' alternative-link open-edit' %} {% set dataHref = path('user_profile', {'username': user.username}) %} {% endif -%} class="{{ class }}" data-href="{{ dataHref }}" {% endmacro %} {# To be used mainly in #} {% macro short_stats_row(stats) %}
{% set colLength = 12 / stats|length %} {% for title, value in stats %}
{{ value }}
{{ title }}
{% endfor %}
{% endmacro %}