Added in actions_selection_counter, will add tests/polish next commit.

This commit is contained in:
Kevin Diale 2013-07-29 14:48:05 -04:00
parent b7b0d9ba8c
commit 6ff47746df
4 changed files with 15 additions and 11 deletions

View file

@ -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',

View file

@ -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) {

View file

@ -14,7 +14,9 @@
</div>
<input type="hidden" name="action" value="" />
<small class="muted">
{% blocktrans with selected='<span class="selected-count">0</span>' total=object_list|length %}{{selected}} of {{total}} selected{% endblocktrans %}
{% if view.model_admin.actions_selection_counter %}
{% blocktrans with selected='<span class="selected-count">0</span>' total=object_list|length %}{{selected}} of {{total}} selected{% endblocktrans %}
{% endif %}
</small>
<div class="pull-right">
{% if permissions.has_add_permission %}

View file

@ -58,6 +58,7 @@ class ModelAdmin2(with_metaclass(ModelAdminBase2)):
This prevents us from easily implementing methods/setters which
bypass the blocking features of the ImmutableAdmin.
"""
actions_selection_counter = True
list_display = ('__str__',)
list_display_links = ()
list_filter = ()