From f93dcc82d5b383bb77c1fa44ad8d3258911cb415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 10 Jul 2015 16:56:51 +0200 Subject: [PATCH] qualif: use select2 to select formdef --- requirements.txt | 1 + setup.py | 1 + welco/settings.py | 1 + welco/static/css/style.css | 4 ++-- welco/static/js/welco.js | 5 ++++- welco/templates/welco/base.html | 3 ++- welco/templates/welco/qualification.html | 1 - 7 files changed, 11 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index b4d677d..fc38151 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ Django>=1.7 gadjo +django-select2 diff --git a/setup.py b/setup.py index cb96cd8..9ba4b56 100644 --- a/setup.py +++ b/setup.py @@ -99,6 +99,7 @@ setup( ], install_requires=['django>=1.7', 'gadjo', + 'django-select2', ], zip_safe=False, cmdclass={ diff --git a/welco/settings.py b/welco/settings.py index 7557004..8222d0b 100644 --- a/welco/settings.py +++ b/welco/settings.py @@ -38,6 +38,7 @@ INSTALLED_APPS = ( 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'django_select2', 'welco.sources.mail', 'welco.qualif', 'gadjo', diff --git a/welco/static/css/style.css b/welco/static/css/style.css index 28e62d9..d3a0fde 100644 --- a/welco/static/css/style.css +++ b/welco/static/css/style.css @@ -115,7 +115,7 @@ div#content .cell.qualif form button.done { bottom: 1ex; } +div#content .cell.qualif .select2-container, div#content .cell.qualif select { - max-width: 100%; - + width: 98%; } diff --git a/welco/static/js/welco.js b/welco/static/js/welco.js index 1c9034d..370ce09 100644 --- a/welco/static/js/welco.js +++ b/welco/static/js/welco.js @@ -11,7 +11,10 @@ $(function() { source_pk: source_pk}, async: true, dataType: 'html', - success: function(data) { $('.cell.qualif > div').replaceWith(data); }, + success: function(data) { + $('.cell.qualif > div').replaceWith(data); + $('.cell.qualif select').select2(); + }, error: function(error) { console.log(':(', error); } }); }); diff --git a/welco/templates/welco/base.html b/welco/templates/welco/base.html index 8850189..9ce7cdc 100644 --- a/welco/templates/welco/base.html +++ b/welco/templates/welco/base.html @@ -1,5 +1,5 @@ {% extends "gadjo/base.html" %} -{% load static %} +{% load static django_select2_tags %} {% block page-title %}Welco{% endblock %} {% block site-title %}Welco{% endblock %} @@ -10,4 +10,5 @@ {% block extrascripts %} {{ block.super }} +{% import_django_select2_js_css %} {% endblock %} diff --git a/welco/templates/welco/qualification.html b/welco/templates/welco/qualification.html index 97d44b0..9c0039b 100644 --- a/welco/templates/welco/qualification.html +++ b/welco/templates/welco/qualification.html @@ -1,7 +1,6 @@ {% load i18n %}
-

{% trans 'Associated Form' %}

{% if association %}
    {% for formdef in association.formdefs.all %}