From e25ebecf8304b927ad8e75aefa1e1886dab2efeb Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 17 May 2017 11:15:07 +0200 Subject: Operation wizard: collaborators in a specific panel (refs #3595) --- ishtar_common/widgets.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ishtar_common/widgets.py') diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index b0f28a6cf..12db821c5 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -82,12 +82,16 @@ class Select2Multiple(forms.SelectMultiple): self.remote = None if not choices and not self.remote and self.model: choices = self.get_choices() + new_attrs = self.attrs.copy() + new_attrs.update(attrs) + attrs = new_attrs klass = attrs and attrs.get('class') or '' klass += ' ' if klass else '' + 'js-select2' if not attrs: attrs = {} attrs['class'] = klass - attrs['style'] = "width: 370px" + if 'style' not in attrs: + attrs['style'] = "width: 370px" options = "" if self.remote: options = """{ -- cgit v1.2.3 From e5dc6268a843e216ccf14469447d9b6f1ad43b49 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 17 May 2017 11:50:39 +0200 Subject: Operation wizard: collaborator panel more explicit style (refs #3595) --- archaeological_operations/forms.py | 2 +- ishtar_common/static/media/style.css | 4 ++++ ishtar_common/widgets.py | 14 ++++++++++++-- version.py | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) (limited to 'ishtar_common/widgets.py') diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index b9e68980f..8fd9233d2 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -994,7 +994,7 @@ class CollaboratorForm(forms.Form): def __init__(self, *args, **kwargs): super(CollaboratorForm, self).__init__(*args, **kwargs) - self.fields['collaborator'].widget.attrs['style'] = 'width: 100%' + self.fields['collaborator'].widget.attrs['full-width'] = True class OperationFormPreventive(forms.Form): diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index 4e59b0f64..0016ca0e5 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -1483,6 +1483,10 @@ input.widget-oa{ /* select2 overload */ +.select2-container--default .full-width.select2-selection--multiple .select2-selection__choice{ + float: none; +} + .select2-container-multi .select2-choices .select2-search-field { min-width:233px; } diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 12db821c5..42a93ddaa 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -58,7 +58,7 @@ class Select2Multiple(forms.SelectMultiple): css = { 'all': ('select2/css/select2.css',) } - js = ['select2/js/select2.min.js'] + js = ['select2/js/select2.full.min.js'] for lang_code, lang in settings.LANGUAGES: js.append('select2/js/i18n/{}.js'.format(lang_code)) media.add_css(css) @@ -91,7 +91,11 @@ class Select2Multiple(forms.SelectMultiple): attrs = {} attrs['class'] = klass if 'style' not in attrs: - attrs['style'] = "width: 370px" + if attrs.get('full-width', None): + attrs['style'] = "width: 100%" + else: + attrs['style'] = "width: 370px" + options = "" if self.remote: options = """{ @@ -124,6 +128,12 @@ class Select2Multiple(forms.SelectMultiple): except (self.model.DoesNotExist, ValueError): # an old reference? it should not happen pass + if attrs.get('full-width', None): + if options: + options = options[:-1] + ", " + else: + options = "{" + options += " containerCssClass: 'full-width'}" html = super(Select2Multiple, self).render(name, value, attrs, choices) html += """