Skip to content

Commit 6701060

Browse files
committed
Merge branch 'release/1.5.0b0'
2 parents 2a8daf3 + cf39b70 commit 6701060

File tree

5 files changed

+41
-19
lines changed

5 files changed

+41
-19
lines changed

adminlteui/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = '1.4.0'
1+
version = '1.5.0b0'
22
default_app_config = 'adminlteui.apps.AdminlteUIConfig'
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<select name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>{% for group_name, group_choices, group_index in widget.optgroups %}{% if group_name %}
2+
<optgroup label="{{ group_name }}">{% endif %}{% for option in group_choices %}
3+
{% include option.template_name with widget=option %}{% endfor %}{% if group_name %}
4+
</optgroup>{% endif %}{% endfor %}
5+
</select>
6+
<script>django.jQuery('#id_{{widget.name}}').select2()</script>

adminlteui/widgets.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44

55
class AdminlteSelect(Select):
6+
template_name = "adminlte/widgets/select.html"
67

78
def _get_media(self):
89
return forms.Media(
@@ -17,6 +18,8 @@ def _get_media(self):
1718

1819

1920
class AdminlteSelectMultiple(SelectMultiple):
21+
template_name = "adminlte/widgets/select.html"
22+
2023
def build_attrs(self, base_attrs, extra_attrs=None):
2124
extra_attrs['multiple'] = 'multiple'
2225
return {**base_attrs, **(extra_attrs or {})}

docs/about.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# ChangeLog
22

3+
## [v1.5.0b0](https://github.com/wuyue92tree/django-adminlte-ui/releases/tag/1.5.0b0)
4+
5+
- add adminlte/widgets/select.html && auto active select2 by select id.
6+
7+
## [v1.4.0](https://github.com/wuyue92tree/django-adminlte-ui/releases/tag/1.4.0)
8+
9+
- feature #6 add `ADMINLTE_SETTINGS`;
10+
- update menu render logic.
11+
312
## [v1.3.3](https://github.com/wuyue92tree/django-adminlte-ui/releases/tag/1.3.3)
413

514
- add menu on the top;

docs/guide.md

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,41 +54,45 @@ before custom option, you should known what adminlte has used.
5454

5555
### AdminlteSelect
5656

57+
> Since v1.5.0b0, you don't need modify new template to active select2.
58+
5759
example:
5860
```
5961
# adminlte/admin.py
6062
@admin.register(Menu)
6163
class MenuAdmin(TreeAdmin):
6264
...
63-
change_form_template = 'adminlte/menu_change_form.html'
65+
# change_form_template = 'adminlte/menu_change_form.html'
6466
formfield_overrides = {
6567
models.ForeignKey: {'widget': AdminlteSelect}
6668
}
6769
6870
# adminlte/menu_change_form.html
6971
# active the target select
70-
{% extends 'admin/change_form.html' %}
71-
72-
{% block extrajs %}
73-
{{ block.super }}
74-
<script>
75-
django.jQuery('#id_content_type').select2();
76-
</script>
77-
{% endblock %}
72+
# {% extends 'admin/change_form.html' %}
73+
74+
# {% block extrajs %}
75+
# {{ block.super }}
76+
# <script>
77+
# django.jQuery('#id_content_type').select2();
78+
# </script>
79+
# {% endblock %}
7880
```
7981
effect:
8082

8183
![adminlte_select](https://github.com/wuyue92tree/django-adminlte-ui/blob/master/images/adminlte_select.png?raw=true)
8284

8385
### AdminlteSelectMultiple
8486

87+
> Since v1.5.0b0, you don't need modify new template to active select2.
88+
8589
example:
8690
```
8791
# adminlte/admin.py
8892
@admin.register(Menu)
8993
class MenuAdmin(TreeAdmin):
9094
...
91-
change_form_template = 'adminlte/menu_change_form.html'
95+
# change_form_template = 'adminlte/menu_change_form.html'
9296
formfield_overrides = {
9397
# multiple for ManayToManyField
9498
models.ManayToManyField: {'widget': AdminlteSelectMultiple(
@@ -98,14 +102,14 @@ class MenuAdmin(TreeAdmin):
98102
99103
# adminlte/menu_change_form.html
100104
# active the target select
101-
{% extends 'admin/change_form.html' %}
102-
103-
{% block extrajs %}
104-
{{ block.super }}
105-
<script>
106-
django.jQuery('#id_content_type').select2();
107-
</script>
108-
{% endblock %}
105+
# {% extends 'admin/change_form.html' %}
106+
107+
# {% block extrajs %}
108+
# {{ block.super }}
109+
# <script>
110+
# django.jQuery('#id_content_type').select2();
111+
# </script>
112+
# {% endblock %}
109113
```
110114
effect:
111115

0 commit comments

Comments
 (0)