Display meta-fields in datatables (#1116)

This commit is contained in:
Kevin Papst
2019-09-19 20:28:31 +02:00
committed by GitHub
parent 24cbe3d281
commit 5aa422dde1
71 changed files with 1461 additions and 212 deletions

View File

@@ -9,11 +9,18 @@
</div>
<div class="modal-body">
<form name="{{ name }}_visibility">
{% for title, class in columns %}
{% if 'alwaysVisible' not in class %}
{%- for title, headerOptions in columns -%}
{% if not headerOptions is iterable %}
{% set headerOptions = {'class': headerOptions} %}
{% endif %}
{% set headerTitle = ('label.' ~ title)|trans %}
{% if headerOptions.title is defined %}
{% set headerTitle = headerOptions.title %}
{% endif %}
{% if 'alwaysVisible' not in headerOptions.class %}
<div class="form-group">
<input type="checkbox" id="column_{{ title }}" name="{{ title }}"{% if is_visible_column(name, title) %} checked="checked"{% endif %}>
<label class="control-label" for="column_{{ title }}">{{ ('label.' ~ title)|trans }}</label>
<label class="control-label" for="column_{{ title }}">{{ headerTitle }}</label>
</div>
{% endif %}
{% endfor %}
@@ -66,7 +73,9 @@
{% endif %}
{% endif %}
{% set headerTitle = '' %}
{% if title is not empty and title != 'actions' %}
{% if headerOptions.title is defined %}
{% set headerTitle = headerOptions.title %}
{% elseif title is not empty and title != 'actions' %}
{% set headerTitle = (translationPrefix ~ title)|trans({}, translationDomain) %}
{% endif %}
<th data-field="{{ title }}" {% if not headerOptions.orderBy is same as(false) %}data-order="{{ headerOptions.orderBy }}" {% endif %}class="{{ headerClass }}">{{ headerTitle }}</th>
@@ -168,3 +177,12 @@
</div>
{% endif %}
{% endmacro %}
{% macro datatable_meta_column(entry, field) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set metaField = entry.metaField(field.name) %}
{% if not metaField is null and metaField.value is not null and metaField.value is not empty %}
{% set metaField = metaField.merge(field) %}
{{ widgets.form_type_value(metaField.type, metaField.value, entry) }}
{% endif %}
{% endmacro %}

View File

@@ -102,6 +102,12 @@
</span>
{% endmacro %}
{% macro color_dot(color, tooltip) %}
<span class="label-color" data-toggle="tooltip" data-placement="top" title="{{ tooltip }}">
<span class="dot" style="background-color:{{ color }}"></span>
</span>
{% endmacro %}
{% macro badge_counter(count, url) %}
{% if url %}
<a href="{{ url }}"><span class="badge bg-blue">{{ count }}</span></a>
@@ -294,3 +300,40 @@
{{ macro.badge(tag.name , 'green') }}
{% 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 %}
{% else %}
{{ value }}
{% endif %}
{% endmacro %}