{% extends "@MapbenderManager/layouts/tabbed.html.twig" %}
{%- import '@MapbenderManager/macros/tabs.html.twig' as tab_macros -%}

{%- block js -%}
    {{- parent() -}}
    <script type="text/javascript" src="{{ asset('bundles/mapbendermanager/js/service-list.js') }}"></script>
{%- endblock -%}

{% block heading %}
    {%- if grants is not empty -%}
        <div class="dropdown bs-dropdown pull-right">
            <button type="button" class="btn btn-light" data-bs-toggle="dropdown"><i class="fas fa-bars"></i></button>
            <ul class="dropdown-menu">
                {%- if grants.refresh | default(false) -%}
                <li>
                    <a class="dropdown-item" href="{{ path("mapbender_manager_repository_updateform", {"sourceId": source.id}) }}">
                        <i class="fas fa-fw fa-rotate"></i> {{ 'mb.manager.source.update' | trans }}
                    </a>
                </li>
                <li>
                    <a class="dropdown-item" href="{{ path('mapbender_manager_sourceinstance_createshared', {'source': source}) }}">
                        <i class="fas fa-fw fa-wifi"></i> {{ 'mb.manager.source.instance.create_reusable' | trans }}
                    </a>
                </li>
                {%- endif -%}
                {%- if grants.delete | default(false) -%}
                    {%- if (grants | length) > 1 -%}
                        <li><hr class="dropdown-divider"></li>
                    {%- endif -%}
                    <li class="bg-danger">
                        <a class="dropdown-item -fn-delete" href="#"
                           data-url="{{ path("mapbender_manager_repository_delete",{"sourceId": source.id}) }}" data-id="{{ source.id }}">
                            <i class="far fa-fw fa-trash-can"></i> {{ 'mb.actions.delete' | trans}}
                        </a>
                    </li>
                {%- endif -%}
            </ul>
        </div>
    {%- endif -%}
    {{ parent() }}
    <div class="clear"></div>
{% endblock heading %}

{% block tab_container_contact %}
    <div{{ tab_macros.tab_content_attributes('Contact', 'serviceContainer') }}>{#- #containerContact -#}
        {% block contact_content %}
        {% include '@MapbenderManager/Repository/source/view-contact.html.twig' with {'contact' : source.contact} %}
        {% endblock contact_content %}
    </div>
{% endblock tab_container_contact %}

  {% block tab_headers %}
      {{- tab_macros.tab_header('MetaData', 'mb.manager.source.metadata.metadata', 'active') -}}{#- #tabMetaData -#}
      {{- tab_macros.tab_header('Applications', 'mb.terms.application.plural') -}}{#- #tabApplications -#}
      {%- if source.contact is defined and source.contact -%}
      {{- tab_macros.tab_header('Contact', 'mb.manager.source.metadata.contact') -}}{#- #tabContact -#}
      {%- endif -%}
      {{- tab_macros.tab_header('Service', 'mb.manager.source.metadata.details') -}}{#- #tabService -#}
      {{- tab_macros.tab_header('Layers', 'mb.manager.source.metadata.layers') -}}{#- #tabLayers -#}
  {% endblock tab_headers %}

    {% block tab_containers %}
        <div{{ tab_macros.tab_content_attributes('MetaData', 'active serviceContainer') }}>{#- #containerMetaData -#}
            {% block metadata_content %}
                {% include '@MapbenderManager/Repository/source/view-metadata-common.html.twig' %}
            {% endblock metadata_content %}
        </div>
        <div{{ tab_macros.tab_content_attributes('Applications', 'serviceContainer') }}>{#- #containerApplications -#}
            {% block applications_content %}
                {% include '@MapbenderManager/Repository/source/applications.html.twig' %}
            {% endblock applications_content %}
        </div>
        {%- if source.contact is defined and source.contact -%}
            {{- block('tab_container_contact') -}}
        {%- endif -%}
        <div{{ tab_macros.tab_content_attributes('Service', 'serviceContainer') }}>{#- #containerService -#}
            {% block details_content %}
                {% include '@MapbenderManager/Repository/source/view-details-common.html.twig' %}
            {% endblock details_content %}
        </div>
        <div{{ tab_macros.tab_content_attributes('Layers', 'serviceContainer') }}>{#- #containerLayers -#}
            {% block layers_content %}
            {# no default / common ground content #}
            {% endblock layers_content %}
        </div>
    {% endblock tab_containers %}
