{#
  Variables
    - searchValue
    - items (\Mautic\DynamicContentBundle\Entity\DynamicContent[])
    - categories
    - page
    - limit
    - permissions
    - model
    - tmpl
#}
{% if items|length > 0 %}
    <div class="table-responsive page-list">
        <table class="table table-hover dwctable-list" id="dwcTable">
            <thead>
            <tr>
                {{ include('@MauticCore/Helper/tableheader.html.twig', {
                    'checkall': 'true',
                    'target': '#dwcTable',
                }) }}

                {{ include('@MauticCore/Helper/tableheader.html.twig', {
                        'sessionVar': 'dynamicContent',
                        'orderBy': 'e.name',
                        'text': 'mautic.core.name',
                        'class': 'col-dwc-name',
                        'default': true,
                }) }}

                {{ include('@MauticCore/Helper/tableheader.html.twig', {
                        'sessionVar': 'dynamicContent',
                        'orderBy': 'e.slotName',
                        'text': 'mautic.dynamicContent.label.slot_name',
                        'class': 'col-dwc-slotname visible-md visible-lg',
                }) }}

                {{ include('@MauticCore/Helper/tableheader.html.twig', {
                        'sessionVar': 'dynamicContent',
                        'orderBy': 'c.title',
                        'text': 'mautic.core.category',
                        'class': 'col-dwc-category visible-md visible-lg',
                }) }}

                {{ include('@MauticCore/Helper/tableheader.html.twig', {
                        'sessionVar': 'dynamicContent',
                        'orderBy': 'e.id',
                        'text': 'mautic.core.id',
                        'class': 'col-dwc-id visible-md visible-lg',
                }) }}
            </tr>
            </thead>
            <tbody>
            {% for item in items %}
                <tr>
                    <td>
                        {{ include('@MauticCore/Helper/list_actions.html.twig', {
                                'item': item,
                                'templateButtons': {
                                    'edit': securityHasEntityAccess(permissions['dynamiccontent:dynamiccontents:editown'], permissions['dynamiccontent:dynamiccontents:editother'], item.createdBy),
                                    'clone': permissions['dynamiccontent:dynamiccontents:create'],
                                    'delete': securityHasEntityAccess(permissions['dynamiccontent:dynamiccontents:deleteown'], permissions['dynamiccontent:dynamiccontents:deleteother'], item.createdBy),
                                },
                                'routeBase': 'dynamicContent',
                                'nameGetter': 'getName',
                        }) }}
                    </td>
                    <td>
                        {{ include('@MauticCore/Helper/publishstatus_icon.html.twig', {'item': item, 'model': 'dynamicContent'}) }}
                        <a href="{{ url('mautic_dynamicContent_action', {'objectAction': 'view', 'objectId': item.id}) }}" data-toggle="ajax">
                            {{ item.name }}
                            {% if item.isVariant or item.isTranslation or item.isCampaignBased %}
                                <span>
                                  {% if item.isVariant %}
                                    <span data-toggle="tooltip" title="{{ 'mautic.core.icon_tooltip.ab_test'|trans }}"><i class="ri-fw ri-organization-chart"></i></span>
                                    {% endif %}
                                  {% if item.isTranslation %}
                                    <span data-toggle="tooltip" title="{{ 'mautic.core.icon_tooltip.translation'|trans }}"><i class="ri-fw ri-translate"></i></span>
                                {% endif %}
                                    {% if item.isCampaignBased %}
                                    <span data-toggle="tooltip" title="{{ 'mautic.dwc.form.is.campaign.tooltip'|trans }}"><i class="ri-fw ri-megaphone-line"></i></span>
                                  {% endif %}
                                 </span>
                            {% endif %}
                        </a>
                        {{ customContent('dynamiccontent.name', _context) }}
                    </td>
                    <td class="visible-md visible-lg">{{ item.slotName }}</td>
                    <td class="visible-md visible-lg">
                        {% set catName = item.category is not empty ? item.category.title : 'mautic.core.form.uncategorized'|trans %}
                        {% set color = item.category is not empty ? '#' ~ item.category.color : '' %}
                        <div class="d-flex ai-center gap-xs"><span class="label label-gray label-category" style="background: {{ color }};"> </span> {{ catName }}</div>
                    </td>
                    <td class="visible-md visible-lg">{{ item.id }}</td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
        <div class="panel-footer">
            {{ include('@MauticCore/Helper/pagination.html.twig', {
                    'totalItems': items|length,
                    'page': page,
                    'limit': limit,
                    'menuLinkId': 'mautic_dynamicContent_index',
                    'baseUrl': url('mautic_dynamicContent_index'),
                    'sessionVar': 'dynamicContent',
            }) }}
        </div>
    </div>
{% else %}
    {{ include('@MauticCore/Helper/noresults.html.twig') }}
{% endif %}
