{% extends "MapbenderManagerBundle::manager.html.twig" %}

{% block title %}{{ "mb.manager.admin.applications" | trans }}{% endblock %}

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

{% block manager_content %}

  {% include "MapbenderManagerBundle:Application:actions.html.twig" %}
  {% if applications | length > 0 %}

  <label for="inputFilterApplications" class="labelInput">{{"mb.manager.admin.filter.application"|trans}}</label><input id="inputFilterApplications" type="text" class="input listFilterInput">

    <ul id="listFilterApplications" class="listFilterContainer clear listFilterBoxes listFilterApplicationBoxes">
      {% for application in applications %}
        <li class="filterItem">
          <a target="_blank" href="{{ path('mapbender_core_application_application', {'slug': application.slug}) }}" title="{{ 'mb.manager.admin.application.view' | trans }} {{ application.title }}">
            <div class="col1">
              <div class="cell">
              {% if application.screenshot is not null %}
                  <img src="{{ uploads_web_url }}/{{application.slug}}/{{application.screenshot}}?t={% if time != null %}{{ time | date('d.m.Y-H:i:s') }}{% endif %}">
              {% else %}
                  <span class="iconAppDefault"></span>
              {% endif %}
              </div>
            </div>
          </a>
          <div class="col2 box">
            <a href="{{ path('mapbender_core_application_application', {'slug': application.slug}) }}" class="title" title="{{ 'mb.manager.admin.application.view_this' | trans }}">
              {{ application.title }}
            </a>
            <span class="smallerText">{{ application.slug }}</span>
            <div class="description">{{ application.description }}</div>
            <div class="buttonGroup">
              <a class="iconView iconBig" target="_blank" href="{{ path('mapbender_core_application_application', {'slug': application.slug}) }}" title="{{ 'mb.manager.admin.application.view' | trans }} {{ application.title }}"></a>

              {% if application.source is constant('Mapbender\\CoreBundle\\Entity\\Application::SOURCE_DB') and is_granted('EDIT', application) %}
                <a class="iconCopy iconBig" href="{{ path('mapbender_manager_application_copydirectly', {'slug': application.slug}) }}" title="{{ 'mb.manager.admin.application.duplicate'|trans }} {{ application.title }}"></a>
              {% endif %}

              {% if application.source is constant('Mapbender\\CoreBundle\\Entity\\Application::SOURCE_DB') and is_granted('EDIT', application) %}
                <a class="iconEdit iconBig" href="{{ path('mapbender_manager_application_edit',  {'slug': application.slug}) }}" title="{{ 'mb.manager.admin.application.edit.title' | trans }} {{ application.title }}"></a>
              {% endif %}

              {% if application.source is constant('Mapbender\\CoreBundle\\Entity\\Application::SOURCE_DB') and is_granted('EDIT', application) %}
                <a href="#" class="iconPublish iconBig {% if application.published %}enabled iconPublishActive{% else %}disabled{% endif %}" title="{{ 'mb.manager.admin.application.public.on_off' | trans }} {{ application.title }}"
                   data-url="{{ path('mapbender_manager_application_togglestate', {'slug': application.slug}) }}"></a>
              {% endif %}

              {% if application.source is constant('Mapbender\\CoreBundle\\Entity\\Application::SOURCE_DB') and is_granted('DELETE', application) %}
                <span class="iconRemove iconBig"
                      title="{{'mb.manager.admin.application.delete'|trans}} {{ application.title }}"
                      data-url="{{ path('mapbender_manager_application_delete', { 'slug': application.slug}) }}"
                      data-slug="{{ application.slug }}"
                ></span>
              {% endif %}
            </div>
          </div>
        </li>
      {% endfor %}
    </ul>
    <div class="clearContainer"></div>
  {% else %}
    <span class="description">{{ 'mb.manager.admin.application.no_application' | trans }}</span>
  {% endif %}
  <div class="clearContainer"></div>

{% endblock %}
