diff options
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/static/media/style.css | 13 | ||||
-rw-r--r-- | ishtar_common/templates/window.html | 5 | ||||
-rw-r--r-- | ishtar_common/widgets.py | 18 |
3 files changed, 34 insertions, 2 deletions
diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index b19366dc1..5168cba6e 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -932,3 +932,16 @@ a.remove{ #merge-table th.small{ width:80px; } + +/* select2 overload */ + +.select2-container-multi .select2-choices .select2-search-field { + min-width:233px; +} + +.select2-container-multi .select2-choices { + border: 0 solid #FFF; + background-color: #FFF; + background-image: none; +} + diff --git a/ishtar_common/templates/window.html b/ishtar_common/templates/window.html index c473eff89..c3d8ccf6a 100644 --- a/ishtar_common/templates/window.html +++ b/ishtar_common/templates/window.html @@ -14,6 +14,7 @@ <script language="javascript" type="text/javascript" src="{{JQUERY_UI_URL}}jquery-ui.js"></script> <script language="javascript" type="text/javascript" src="{{JQUERY_UI_URL}}ui/i18n/jquery.ui.datepicker-{{COUNTRY}}.js"></script> <script language="javascript" type="text/javascript" src="{{STATIC_URL}}/js/ishtar.js"></script> + {{form.media}} <link type="text/css" href="{{JQUERY_UI_URL}}css/smoothness/jquery-ui.css" rel="stylesheet" /> <link rel="stylesheet" href="{{STATIC_URL}}/media/style.css" /> {% block extra_head %} @@ -31,8 +32,8 @@ save_and_close_window("{{parent_name}}", "{{parent_pk}}", "{{new_item_label}}", <table> {% for field in form %} <tr{% if field.field.required %} class='required'{% endif %}> - <th><label for="{{ field.label }}">{{ field.label_tag }}</th> - <td> {{ field.errors }}{{field|safe}}</td> + <th>{{ field.label_tag }}</th> + <td>{{ field.errors }}{{field|safe}}</td> </tr>{% endfor %} <tr><td colspan='2' class='submit_button'><input type="submit" id="submit_new_item" value="{% trans "Add" %}"/></td></tr> </table> diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 404d5fabe..0ba4061a8 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -37,6 +37,24 @@ import models reverse_lazy = lazy(reverse, unicode) + +class Select2Multiple(forms.SelectMultiple): + class Media: + css = { + 'all': ('select2/css/select2.css',) + } + js = ('select2/js/select2.min.js', + 'select2/js/init.js') + + def render(self, name, value, attrs=None, choices=()): + klass = attrs and attrs.get('class') or '' + klass += ' ' if klass else '' + 'js-select2' + if not attrs: + attrs = {} + attrs['class'] = klass + return super(Select2Multiple, self).render(name, value, attrs, + choices) + class MultipleAutocompleteField(forms.MultipleChoiceField): def __init__(self, *args, **kwargs): self.model = None |