diff --git a/djadmin2/settings.py b/djadmin2/settings.py index b90f3ff..5153979 100644 --- a/djadmin2/settings.py +++ b/djadmin2/settings.py @@ -8,9 +8,8 @@ from django.conf import settings # views. This is a security feature. # See the docstring on djadmin2.types.ModelAdmin2 for more detail. MODEL_ADMIN_ATTRS = ( - 'list_display', 'list_display_links', 'list_filter', 'admin', - 'search_fields', - 'field_renderers', + 'actions_selection_counter', 'list_display', 'list_display_links', + 'list_filter', 'admin', 'search_fields', 'field_renderers', 'index_view', 'detail_view', 'create_view', 'update_view', 'delete_view', 'get_default_view_kwargs', 'get_list_actions', 'actions_on_bottom', 'actions_on_top', diff --git a/djadmin2/static/themes/bootstrap/js/actions.js b/djadmin2/static/themes/bootstrap/js/actions.js index 64d25b9..af7e1f8 100644 --- a/djadmin2/static/themes/bootstrap/js/actions.js +++ b/djadmin2/static/themes/bootstrap/js/actions.js @@ -5,14 +5,16 @@ $(function() { var selectedCount = element.find('.selected-count'); var updateSelectedCount = function() { - var count = 0; - for (var ix = 0; ix < selectCheckbox.length; ix++) { - if ($(selectCheckbox[ix]).prop('checked')) { - count++; - } + if (selectedCount.length) { + var count = 0; + for (var ix = 0; ix < selectCheckbox.length; ix++) { + if ($(selectCheckbox[ix]).prop('checked')) { + count++; + } + } + selectAllCheckbox.prop('checked', count == selectCheckbox.length); + selectedCount.text(count); } - selectAllCheckbox.prop('checked', count == selectCheckbox.length); - selectedCount.text(count); }; selectAllCheckbox.click(function(e) { diff --git a/djadmin2/themes/djadmin2theme_default/templates/djadmin2theme_default/includes/list_actions.html b/djadmin2/themes/djadmin2theme_default/templates/djadmin2theme_default/includes/list_actions.html index 5b309d5..2357875 100644 --- a/djadmin2/themes/djadmin2theme_default/templates/djadmin2theme_default/includes/list_actions.html +++ b/djadmin2/themes/djadmin2theme_default/templates/djadmin2theme_default/includes/list_actions.html @@ -14,7 +14,9 @@ - {% blocktrans with selected='0' total=object_list|length %}{{selected}} of {{total}} selected{% endblocktrans %} + {% if view.model_admin.actions_selection_counter %} + {% blocktrans with selected='0' total=object_list|length %}{{selected}} of {{total}} selected{% endblocktrans %} + {% endif %}