pedagogy: simpler user interface for autumn and spring search

This commit is contained in:
Antoine Bartuccio 2019-07-05 15:56:50 +02:00
parent cbcd84c931
commit 6f8ec4740c
Signed by: klmp200
GPG Key ID: E7245548C53F904B

View File

@ -6,7 +6,7 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<form action="{{ url('pedagogy:guide') }}" method="get"> <form id="search_form" action="{{ url('pedagogy:guide') }}" method="get">
<p> <p>
<input type="text" name="search"> <input type="text" name="search">
<button>{% trans %}Details{% endtrans %}</button> <button>{% trans %}Details{% endtrans %}</button>
@ -29,6 +29,7 @@
<input type="checkbox" name="semester" value="AUTUMN">A <input type="checkbox" name="semester" value="AUTUMN">A
<input type="checkbox" name="semester" value="SPRING">P <input type="checkbox" name="semester" value="SPRING">P
<input type="checkbox" name="semester" value="AUTUMN_AND_SPRING">
</p> </p>
</form> </form>
{% if can_create_uv(user) %} {% if can_create_uv(user) %}
@ -66,5 +67,30 @@
formStates[$(this).attr("name")] = $(this).attr("value"); formStates[$(this).attr("name")] = $(this).attr("value");
} }
}); });
var autumn_and_spring = $("input[value='AUTUMN_AND_SPRING']").first();
var autumn = $("input[value='AUTUMN']").first();
var spring = $("input[value='SPRING']").first();
// Make autumn and spring hidden if js is enabled
autumn_and_spring.hide();
// Set correctly state of what is checked
if (autumn_and_spring.prop("checked")){
autumn.prop("checked", true);
spring.prop("checked", true);
autumn_and_spring.prop("checked", false);
}
// Handle submit here and modify autumn and spring here
$("#search_form").submit(function(e) {
e.preventDefault();
if (autumn.prop("checked") && spring.prop("checked")){
autumn_and_spring.prop("checked", true);
autumn.prop("checked", false);
spring.prop("checked", false);
}
this.submit();
});
</script> </script>
{% endblock content %} {% endblock content %}