From cda77c979e232386ef24ea7a04600f16f3c32c98 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 15 Nov 2022 16:29:30 +0100 Subject: File module refactoring - more tests for files --- .../ishtar/blocks/JQueryCorporationPerson.js | 2 + .../templates/ishtar/blocks/JQueryNaturalPerson.js | 2 + .../templates/ishtar/blocks/JQueryPersonOrga.js | 66 +++++++++++++++++ .../ishtar/wizard/file_confirm_wizard.html | 27 +++++++ .../ishtar/wizard/wizard_instruction.html | 83 ++++++++++++++++++++++ .../ishtar/wizard/wizard_person_orga.html | 76 ++++++++++++++++++++ 6 files changed, 256 insertions(+) create mode 100644 archaeological_files/templates/ishtar/blocks/JQueryCorporationPerson.js create mode 100644 archaeological_files/templates/ishtar/blocks/JQueryNaturalPerson.js create mode 100644 archaeological_files/templates/ishtar/blocks/JQueryPersonOrga.js create mode 100644 archaeological_files/templates/ishtar/wizard/file_confirm_wizard.html create mode 100644 archaeological_files/templates/ishtar/wizard/wizard_instruction.html create mode 100644 archaeological_files/templates/ishtar/wizard/wizard_person_orga.html (limited to 'archaeological_files/templates') diff --git a/archaeological_files/templates/ishtar/blocks/JQueryCorporationPerson.js b/archaeological_files/templates/ishtar/blocks/JQueryCorporationPerson.js new file mode 100644 index 000000000..3eb375167 --- /dev/null +++ b/archaeological_files/templates/ishtar/blocks/JQueryCorporationPerson.js @@ -0,0 +1,2 @@ +var current_status = 'corporation'; +{% include "ishtar/blocks/JQueryPersonOrga.js" %} diff --git a/archaeological_files/templates/ishtar/blocks/JQueryNaturalPerson.js b/archaeological_files/templates/ishtar/blocks/JQueryNaturalPerson.js new file mode 100644 index 000000000..fc4b9a90c --- /dev/null +++ b/archaeological_files/templates/ishtar/blocks/JQueryNaturalPerson.js @@ -0,0 +1,2 @@ +var current_status = 'natural'; +{% include "ishtar/blocks/JQueryPersonOrga.js" %} diff --git a/archaeological_files/templates/ishtar/blocks/JQueryPersonOrga.js b/archaeological_files/templates/ishtar/blocks/JQueryPersonOrga.js new file mode 100644 index 000000000..1877e4579 --- /dev/null +++ b/archaeological_files/templates/ishtar/blocks/JQueryPersonOrga.js @@ -0,0 +1,66 @@ +person_save_callback = function(item_id, lbl){ + var url = {{edit_source}}; + $('#id_{{field_id}}').val(null); + $('#id_select_{{field_id}}').val(lbl); + if (item_id){ + url = {{edit_source}}+item_id; + $('#id_{{field_id}}').val(item_id); + } + $("#id_select_{{field_id}}").trigger('autocompletechange'); + $.get(url , function( data ) { + $( "#div-{{field_id}}" ).html( data ); + }); +}; + +edit_url = {{edit_source}}; +parent_id = "{{field_id}}"; + +person_new_callback = function(){ + var url = {{edit_source}}; + $('#id_{{field_id}}').val(null); + $('#id_select_{{field_id}}').val(null); +} + +$(function() { + var $radios = $('input:radio[name=person_type]'); + if($radios.is(':checked') === false) { + $radios.filter('[value='+ current_status +']').prop('checked', true); + } + + $radios.change(function(){ + var loc = window.location; + window.location = loc.protocol + '//' + loc.host + loc.pathname + "?status=" + $('input:radio[name=person_type]:checked').val(); + }); + + $("#id_select_{{field_id}}").autocomplete({ + source: {{source}}, + select: function( event, ui ) { + var url = {{edit_source}}; + if(ui.item){ + url = {{edit_source}}+ui.item.id; + $('#id_{{field_id}}').val(ui.item.id); + $('#id_{{field_id}}').change(); + } else { + $('#id_{{field_id}}').val(null); + } + $.get(url, function( data ) { + $( "#div-{{field_id}}" ).html( data ); + }); + }, + minLength: 2{% if options %}, + {{options}} + {% endif %} + }); + + $.get( {{edit_source}}{% if selected %}+'{{selected}}'{% endif %}, function( data ) { + $( "#div-{{field_id}}" ).html( data ); + }); + + $(document).on("click", '#id_select_{{field_id}}', function(){ + $('#id_{{field_id}}').val(null); + $('#id_select_{{field_id}}').val(null); + $.get( {{edit_source}}, function( data ) { + $( "#div-{{field_id}}" ).html( data ); + }); + }); +}); diff --git a/archaeological_files/templates/ishtar/wizard/file_confirm_wizard.html b/archaeological_files/templates/ishtar/wizard/file_confirm_wizard.html new file mode 100644 index 000000000..914a5198b --- /dev/null +++ b/archaeological_files/templates/ishtar/wizard/file_confirm_wizard.html @@ -0,0 +1,27 @@ +{% extends "ishtar/wizard/confirm_wizard.html" %} +{% load i18n %} + +{% block "warning_informations" %} +{% for file in numeric_reference_files %} +{% if forloop.first %} +

+ +
+{% endif %} +{% endfor %} +{% for file in similar_files %} +{% if forloop.first %} +

+ +
+{% endif %} +{% endfor %} +{% endblock %} diff --git a/archaeological_files/templates/ishtar/wizard/wizard_instruction.html b/archaeological_files/templates/ishtar/wizard/wizard_instruction.html new file mode 100644 index 000000000..34db944aa --- /dev/null +++ b/archaeological_files/templates/ishtar/wizard/wizard_instruction.html @@ -0,0 +1,83 @@ +{% extends "ishtar/wizard/default_wizard.html" %} +{% load i18n range table_form %} +{% block form_detail %} +
+ {% 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 %} + +
+ + + +
+ + +
+
+ {{wizard.form.end_date.errors}} + : {{wizard.form.end_date|safe}} +
+
+ {% with wizard.form.instruction_deadline as field %}{% with saisine_type_message as extra_field_label %} + {% include "blocks/bs_field_snippet.html" %} + {% endwith %}{% endwith %} +
+ + + +
+ {{wizard.form.numeric_reference.errors}} + {% if FILE_PREFIX %}{{FILE_PREFIX}}{% endif %} + {{wizard.form.year|safe}} - + {{wizard.form.numeric_reference|safe}} +
+
+
+{% 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 %} diff --git a/archaeological_files/templates/ishtar/wizard/wizard_person_orga.html b/archaeological_files/templates/ishtar/wizard/wizard_person_orga.html new file mode 100644 index 000000000..36f1aa4f8 --- /dev/null +++ b/archaeological_files/templates/ishtar/wizard/wizard_person_orga.html @@ -0,0 +1,76 @@ +{% extends "ishtar/wizard/default_wizard.html" %} +{% load i18n range table_form %} +{% block wizard_form %} + +
{% csrf_token %} +
+{% if wizard.form.media %}{{ wizard.form.media }}{% endif %} +{{ wizard.management_form }} + + + + + + + + + + + +
Statut
+ + + {% if wizard.form.non_field_errors %} + + {%endif%} + +{% block corporation %} +{% endblock %} +
{{wizard.form.non_field_errors}}
+
+ + {% if wizard.form.non_field_errors %} + + {%endif%} + +{% block natural %} +{% endblock %} +
{{wizard.form.non_field_errors}}
+
+ +
+{% block otherfields %} +{% endblock %} +
+{% block extra_head_po %} +{% endblock %} + + +{{ previous_fields|safe }} + {% block "footer" %} + + {% endblock %} +
+
+{% endblock %} + -- cgit v1.2.3