roannais-icitoyen: use select2 for "choix commune" cell (#41678)

This commit is contained in:
Thomas Jund 2020-04-15 19:00:54 +02:00
parent 34c9564a12
commit 7efbe596b2
4 changed files with 34 additions and 12 deletions

View File

@ -779,6 +779,18 @@ div.carrousel-content {
}
}
// cell Choix commune
// use select2 autocomplète
#form-cell-choix-commune {
span.select2-container {
min-width: 0;
margin: 0;
}
div.select2-container, span.select2-container {
padding-bottom: 0;
}
}
// WCS
div#gauche {
@media ($max-mobile-viewport) {

View File

@ -3,7 +3,8 @@
"variables": {
"pwa_display": "standalone",
"theme_color": "#ff3300",
"email_header_asset": "emails:logo"
"email_header_asset": "emails:logo",
"included_js_libraries": ["jquery.js", "select2.js"]
},
"settings": {
"combo": {

View File

@ -3,9 +3,9 @@
{% if title %}<h2>{{ title }}</h2>{% endif %}
<div>
{% include "combo/asset_picture_fragment.html" %}
<form>
<select id="select-choix-commune">
<option value="">-- Sélectionnez --</option>
<form id="form-cell-choix-commune">
<select id="select-cell-choix-commune" class="select-cell-choix-commune">
<option value="">Sélectionnez</option>
{% for link in links %}
<option value="{{ link.url }}">{{ link.title }}</option>
{% endfor %}
@ -20,13 +20,14 @@
<script>
$(function() {
$('#select-choix-commune').on('change', function(e){
e.preventDefault;
var link = this.value;
if (!link) {
return;
}
window.location.href = link;
});
$('#select-cell-choix-commune')
.select2()
.on('select2:select', function(e){
var link = e.params.data.id;
if (!link) {
return;
}
window.location.href = link;
});
});
</script>

View File

@ -0,0 +1,8 @@
{% extends "combo/page_template.html" %}
{% load combo gadjo %}
{% block extra_top_head_js %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="{{eservices_url}}static/js/select2/select2.css">
<script src="{{eservices_url}}static/js/select2/select2.js"></script>
{% endblock %}