summaryrefslogtreecommitdiff
path: root/archaeological_files_pdl/templates/ishtar/wizard/wizard_instruction.html
blob: 34db944aafc46ed0fdd3cfc3e19ff7649557f627 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{% extends "ishtar/wizard/default_wizard.html" %}
{% load i18n range table_form %}
{% block form_detail %}
  <div class="form-row">
    {% with wizard.form.in_charge as field %}
    {% include "blocks/bs_field_snippet.html" %}
    {% endwith %}
    {% with wizard.form.related_file as field %}
    {% include "blocks/bs_field_snippet.html" %}
    {% endwith %}
    {% with wizard.form.comment as field %}
    {% include "blocks/bs_field_snippet.html" %}
    {% endwith %}

    <div class="form-group col-lg-6">
      <span class="required">
        <label class="required">{% trans "State of the file:" %}</label>
      </span>
        <div class="form-group col-lg-12 mb-0">
          <span><input type='radio' name='state' value='open' id='state-open'/>
          <label for='state-open'>Dossier actif</label></span>
        </div>
        <div class="form-group col-lg-12">
          <span>{{wizard.form.end_date.errors}}<input type='radio' name='state' value='closed' id='state-closed'/>
            <label for='state-closed'>Dossier clos / date de clôture</label> : {{wizard.form.end_date|safe}}</span>
        </div>
    </div>
    {% with wizard.form.instruction_deadline as field %}{% with saisine_type_message as extra_field_label %}
    {% include "blocks/bs_field_snippet.html" %}
    {% endwith %}{% endwith %}
    <div class="form-group col-lg-6">
      <span class="required">
        <label>{{wizard.form.numeric_reference.label}}{% trans ":" %}</label>
      </span>
      <div class="form-inline">
        {{wizard.form.numeric_reference.errors}}
        {% if FILE_PREFIX %}<span class="pr-2">{{FILE_PREFIX}}</span>{% endif %}
        <span class="pr-2">{{wizard.form.year|safe}}</span> -
        <span class="pl-2">{{wizard.form.numeric_reference|safe}}</span>
      </div>
    </div>
  </div>
{% endblock %}

{% block "js_extra_ready" %}
    if ($('#id_instruction-{{CURRENT_ACTION}}-end_date').val()){
        $("#state-closed").prop('checked', true);
    } else {
        $("#state-open").prop('checked', true);
    }

    check_state = function(){
        var state = $("input[name=state]:checked").val();
        if (state == 'closed'){
            $('#id_instruction-{{CURRENT_ACTION}}-end_date').focus();
            $('#id_instruction-{{CURRENT_ACTION}}-end_date').prop('disabled', false);
        } else if (state == 'open'){
            $('#id_instruction-{{CURRENT_ACTION}}-end_date').val('');
            $('#id_instruction-{{CURRENT_ACTION}}-end_date').prop('disabled', true);
        }
    };

    $('input[name=state]').click(check_state);

    check_state();

    $('#submit_form').click(function(){
        var state = $("input[name=state]:checked").val();
        if (state == 'closed'){
            if (!$('#id_instruction-{{CURRENT_ACTION}}-end_date').val()){
                alert("{% trans 'You must select a closing date.' %}")
                return false;
            }
            return true;
        } else if (state == 'open'){
            return true;
        } else {
            alert("{% trans 'You must select a state for this file.' %}")
            return false;
        }
        return true;
    });
    {% endblock %}