{% load dashboard static thumbnail %}
{% if not in_dashboard %}
<div class="dashboard-settings">
<div class="dashboard-meta">
<h2>Délibérations communales</h2>
{% if json.meta.description %}<div>{{json.meta.description}}</div>{% endif %}
</div>
<div class="dashboard-switch">
  {% with tile=cell|as_dashboard_cell:request.user %}
  <input type="checkbox" id="deliberations-communales-id"
      data-add-tile-url="{% url 'combo-dashboard-add-tile' cell_reference=cell.get_reference %}"
      {% if tile %}
      checked
      data-remove-tile-url="{% url 'combo-dashboard-remove-tile' cell_reference=tile.cell.get_reference %}"
      {% endif %}
    >
  {% endwith %}
  <script>
  $('#deliberations-communales-id').on('change', function() {
    if ($(this).is(':checked')) {
      var $checkbox = $(this);
      $.ajax({
        url: $(this).data('add-tile-url'),
        success: function(data) {
          $checkbox.data('remove-tile-url', data.cell_data.remove_url);
          $('h1#logo').addClass('dashboard-change').on('animationend', function() { $('h1#logo').removeClass('dashboard-change')});
        }
      });
    } else {
      $.ajax({
        url: $(this).data('remove-tile-url'),
        success: function(data) {}
      });
    }
  });
  </script>
</div>
</div>

{% else %}
<h2>Délibérations communales</h2>

{% for entry in json.data %}
<div class="delib">
<img src="{{site_base}}{% static "" %}{{css_variant}}/article-placeholder.svg" alt="" height="160" width="160">
<div>
        <h3><a href="{{ entry.PLONE_id }}">Séance du {{ entry.title }}</a></h3>
        <br>
        <p>
        {% if entry.review_state == 'decision' %}Décision
        {% elif entry.review_state == 'in_project' %}Projet de décision
        {% endif %}</p>
</div>
</div>
{% empty %}
<p>Aucune.</p>
{% endfor %}

{% if plone_deliberations_url %}
<div class="all"><a class="pk-button" href="{{ plone_deliberations_url }}">Toutes les délibérations</a></p>
{% endif %}

{% endif %}
