update table and add listing and collection class
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{% macro table(table_options, api_response, action, title = "") %}
|
||||
{% macro table(table_options, collection, action, title = "") %}
|
||||
|
||||
{% import "Froxlor/table/tablemacros.html.twig" as tablemacros %}
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
</h3>
|
||||
{% endif %}
|
||||
|
||||
<div class="card">
|
||||
<div class="card table-responsive">
|
||||
<table class="table table-borderless table-striped mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
{% for column in table_options.visible_columns %}
|
||||
<th class="p-3">{{ table_options.columns[column].title }}</th>
|
||||
<th class="p-3">{{ table_options.columns[column].label }}</th>
|
||||
{% endfor %}
|
||||
{% if table_options.actions %}
|
||||
<th class="p-3 text-end">Actions</th>
|
||||
@@ -25,16 +25,16 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for columns in api_response.list %}
|
||||
{% for columns in collection.list %}
|
||||
<tr class="{{ tablemacros.contextual_class(table_options.contextual_class, columns)|trim }}">
|
||||
{% for column in table_options.visible_columns %}
|
||||
<td class="p-3">
|
||||
{% if table_options.columns[column].type is empty %}
|
||||
{{ columns[column] }}
|
||||
{{ tablemacros.column(columns, table_options.columns[column].column)|trim }}
|
||||
{% elseif table_options.columns[column].type == 'boolean' %}
|
||||
{{ tablemacros.boolean(columns[column]) }}
|
||||
{{ tablemacros.boolean(tablemacros.column(columns, table_options.columns[column].column)|trim) }}
|
||||
{% elseif table_options.columns[column].type == 'usage' %}
|
||||
{{ tablemacros.usage(columns[column]) }}
|
||||
{{ tablemacros.usage(tablemacros.column(columns, table_options.columns[column].column)|trim) }}
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endfor %}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{% macro contextual_class(contextual_class, columns) %}
|
||||
{# this could be refactored as filter #}
|
||||
{% for i_key,i_column in columns %}
|
||||
{% for c_key, c_column in contextual_class %}
|
||||
{% if i_key == c_key %}
|
||||
@@ -12,7 +13,6 @@
|
||||
{{ c_column.return }}
|
||||
{% endif %}
|
||||
{% elseif c_column.column is not empty %}
|
||||
check for {{ columns[c_column.column] }}
|
||||
{# check for column #}
|
||||
{% if c_column.operator is empty and columns[c_column.column] == i_column %}
|
||||
{{ c_column.return }}
|
||||
@@ -37,4 +37,17 @@
|
||||
|
||||
{% macro usage(value) %}
|
||||
{{ value }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro column(arr, str) %}
|
||||
{# this could be refactored as filter #}
|
||||
{% set strarr = str|split('.') %}
|
||||
|
||||
{% if strarr|length == 1 %}
|
||||
{{ arr[strarr[0]] }}
|
||||
{% elseif strarr|length == 2 %}
|
||||
{{ arr[strarr[0]][strarr[1]] }}
|
||||
{% else %}
|
||||
column depth not supported
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
@@ -4,6 +4,6 @@
|
||||
|
||||
{% import "Froxlor/table/table.html.twig" as table %}
|
||||
|
||||
{{ table.table(table_options, api_response, '#', table_options.title) }}
|
||||
{{ table.table(table_options, collection, '#', table_options.title) }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user