{% extends '@tables/shortcode.twig' %}

{% block before_table %}
    {% set exportLinksPosition = table.settings.exportLinksPosition | default('before_table') %}
    {% if exportLinksPosition == 'before_table' %}
        {% include '@tables_pro/features/exportLinks.twig' %}
    {% endif %}
{% endblock %}

{% block after_table %}
    {% set exportLinksPosition = table.settings.exportLinksPosition | default('before_table') %}
    {% if exportLinksPosition == 'after_table' %}
        {% include '@tables_pro/features/exportLinks.twig' %}
    {% endif %}
    {% spaceless %}
		<div class="stbConditionsData"
			{% if table.conditionsData | length and table.conditionsData.conditions | length > 0 %}
                 data-id="{{ table.id }}"
                 data-view-id="{{ table.view_id }}"
                 data-types="{{ table.conditionsData.types | json_encode | e }}"
                 data-operators="{{ table.conditionsData.operators | json_encode | e }}"
                 data-conditions="{{ table.conditionsData.conditions | json_encode | e }}"
        	{% endif %}
		></div>
        {% if table.settings.source is defined and table.settings.source.database is defined %}
            <div class="stbDBEditData"
                {% if table.settings.source.error is defined %}
                    data-error="{{ table.settings.source.error }}"
                {% elseif table.settings.source.dbUniqData is defined and table.settings.source.dbUniqData | length > 0 %}
                    data-table="{{ table.settings.source.dbTable }}"
                    data-fields="{{ table.settings.source.dbFields | json_encode | e }}"
                    data-unique-fields="{{ table.settings.source.dbUniqFields | json_encode | e }}"
                    data-unique-data="{{ table.settings.source.dbUniqData | json_encode | e }}"
                {% endif %}
            ></div>
        {% endif %}
    {% endspaceless %}
{% endblock %}

{% block table_attributes %}
    {% if table.settings.exportLogo.src is not empty %}
        data-export-logo="{{ table.settings.exportLogo|json_encode|e }}"
    {% endif %}
    {% if table.settings.saveEditableFields is not empty %}
        data-save-editable-fields="1"
    {% endif %}
    {% if table.settings.markLastEditedCell is not empty %}
        data-mark-last-edited-cell="1"
    {% endif %}
    {% if table.settings.sqlValues is not empty %}
        data-sql-values="{{ table.settings.sqlValues }}"
    {% endif %}
{% endblock %}
