{% extends "hdabo_base.html" %}
{% load static %}
{% block title %}HDA - BO : Créer ou modifier un dossier{% endblock %}

{% block js_import %}
{{block.super}}
<script type="text/javascript" src="{% static 'hdabo/js/folders.js' %}"></script>
{% endblock %}

{% block js_declaration %}
    {{block.super}}
    <script type="text/javascript">
    var global_csrf_token = "{{ csrf_token }}";
    var static_url = "{% static '' %}";
    var search_url = "{% url 'searchajax' %}";
    </script>
{% endblock %}

{% block content %}
{{block.super}}
<form class="folder-form" method="POST" action="{% url 'add_or_update_folder' %}" autocomplete="off">
{% csrf_token %}
{% if folder %}<input type="hidden" name="pk" value="{{folder.pk}}" />{% endif %}
<p>Url (adresse de la page sur le portail Histoire de Arts)&nbsp;:<br/>
  <input class="folder-input" type="text" name="url" value="{% if folder %}{{folder.url}}{% endif %}" required="required"/>
</p>
<p>Titre&nbsp;:<br/><input class="folder-input" type="text" name="title" value="{% if folder %}{{folder.title}}{% endif %}"/></p>
<p>Description&nbsp;:<br/><textarea class="folder-input" name="description">{% if folder %}{{folder.description}}{% endif %}</textarea></p>
<p>&nbsp;</p>
<p>Liste des fiches associées au dossier&nbsp;:</p>
<input type="hidden" name="ds_ids" id="ds_ids" value="{% if folder %}{% for d in folder.datasheets.all %}{{ d.pk }},{% endfor %}{% endif %}" />
<ul id="ds-list">
  {% if folder %}{% for d in folder.datasheets.all %}
    <li data-dsid="{{ d.pk }}">{{ d.title }} <span class="remove-ds-from-folder hand_cursor">X</span></li>
  {% endfor %}{% endif %}
</ul>
<p>Rechercher dans les fiches existantes (cliquez sur un résultat pour l'ajouter)&nbsp;:</p>
<p><input type="text" id="ds-search" value=""/> <span id="ok_search" class="hand_cursor"><b>OK</b></span>
<div id="ds-search-list"></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<button type="submit">Envoyer</button>
</form>
{% endblock %}
