{% extends "combo/wcs/card.html" %}

{% block cell-content %}
  {{ block.super }}
  <style>
    .{{ cell.get_reference }} .value {
      text-align: center;
    }
  </style>
  <script>
    function initCardCell($cell, url) {
      if ($cell) {
        $('a', $cell).prepend('<img src="' + url + '" /><br />');
      }
    }
    {% if not card_not_found and card.id %}
      {% if card.fields.lien_1_raw %}
        {% with cards|objects:"type-de-liens"|filter_by_internal_id:card.fields.lien_1_raw|get_full|first as type_lien %}
          initCardCell($('.{{ cell.get_reference }} div.value')[0], '{% make_public_url url=type_lien.fields.img_lien.url %}');
        {% endwith %}
      {% endif %}
      {% if card.fields.lien_2_raw %}
        {% with cards|objects:"type-de-liens"|filter_by_internal_id:card.fields.lien_2_raw|get_full|first as type_lien %}
          initCardCell($('.{{ cell.get_reference }} div.value')[1], '{% make_public_url url=type_lien.fields.img_lien.url %}');
        {% endwith %}
      {% endif %}
      {% if card.fields.lien_3_raw %}
        {% with cards|objects:"type-de-liens"|filter_by_internal_id:card.fields.lien_3_raw|get_full|first as type_lien %}
          initCardCell($('.{{ cell.get_reference }} div.value')[2], '{% make_public_url url=type_lien.fields.img_lien.url %}');
        {% endwith %}
      {% endif %}
      {% if card.fields.lien_4_raw %}
        {% with cards|objects:"type-de-liens"|filter_by_internal_id:card.fields.lien_4_raw|get_full|first as type_lien %}
          initCardCell($('.{{ cell.get_reference }} div.value')[3], '{% make_public_url url=type_lien.fields.img_lien.url %}');
        {% endwith %}
      {% endif %}
      {% if card.fields.lien_5_raw %}
        {% with cards|objects:"type-de-liens"|filter_by_internal_id:card.fields.lien_5_raw|get_full|first as type_lien %}
          initCardCell($('.{{ cell.get_reference }} div.value')[4], '{% make_public_url url=type_lien.fields.img_lien.url %}');
        {% endwith %}
      {% endif %}
      {% if card.fields.lien_6_raw %}
        {% with cards|objects:"type-de-liens"|filter_by_internal_id:card.fields.lien_6_raw|get_full|first as type_lien %}
          initCardCell($('.{{ cell.get_reference }} div.value')[5], '{% make_public_url url=type_lien.fields.img_lien.url %}');
        {% endwith %}
      {% endif %}
    {% endif %}
  </script>
{% endblock %}
