Ticket #10615: admin-actions-counter-10625-2.diff

File admin-actions-counter-10625-2.diff, 3.4 KB (added by Martin Mahner, 15 years ago)

Patch for Django 1.2-pre-alpha

  • django/contrib/admin/media/css/changelists.css

    diff --git a/django/contrib/admin/media/css/changelists.css b/django/contrib/admin/media/css/changelists.css
    index 4303378..6746f20 100644
    a b  
    228228    border-right: 1px solid #ddd;
    229229}
    230230
     231.action_counter{
     232    font-size: 11px;
     233    margin: 0 0.5em;
     234    padding-right: 0.5em;
     235    border-right: 1px solid #ccc;
     236}
     237
    231238#changelist table input {
    232239    margin: 0;
    233240}
  • django/contrib/admin/media/js/actions.js

    diff --git a/django/contrib/admin/media/js/actions.js b/django/contrib/admin/media/js/actions.js
    index d34488a..e0b3c3e 100644
    a b  
    11var Actions = {
    22    init: function() {
     3        counterSpans = document.getElementsBySelector('span._acnt');
     4        actionCheckboxes = document.getElementsBySelector('tr input.action-select');
    35        var selectAll = document.getElementById('action-toggle');
    46        if (selectAll) {
    57            selectAll.style.display = 'inline';
    68            addEvent(selectAll, 'click', function() {
    79                Actions.checker(selectAll.checked);
     10                Actions.counter();
     11            });
     12        }       
     13        for(var i = 0; i < actionCheckboxes.length; i++) {
     14            addEvent(actionCheckboxes[i], 'click', function() {
     15                Actions.counter();
    816            });
    917        }
    1018        var changelistTable = document.getElementsBySelector('#changelist table')[0];
    var Actions = {  
    2836        } 
    2937    },
    3038    checker: function(checked) {
    31         var actionCheckboxes = document.getElementsBySelector('tr input.action-select');
    3239        for(var i = 0; i < actionCheckboxes.length; i++) {
    3340            actionCheckboxes[i].checked = checked;
    3441            Actions.toggleRow(actionCheckboxes[i].parentNode.parentNode, checked);
    3542        }
     43    },
     44    counter: function() {
     45        counter = 0;
     46        for(var i = 0; i < actionCheckboxes.length; i++) {
     47            if(actionCheckboxes[i].checked){
     48                counter++;
     49            }
     50        }
     51        for(var i = 0; i < counterSpans.length; i++) {
     52            counterSpans[i].innerHTML = counter;
     53        }
    3654    }
    3755};
    3856
    39 addEvent(window, 'load', Actions.init);
     57addEvent(window, 'load', Actions.init);
     58 No newline at end of file
  • django/contrib/admin/templates/admin/actions.html

    diff --git a/django/contrib/admin/templates/admin/actions.html b/django/contrib/admin/templates/admin/actions.html
    index bf4b975..4fea071 100644
    a b  
    11{% load i18n %}
    22<div class="actions">
     3    <span class="action_counter">
     4    {% ifequal cl.result_count 1 %}
     5        {% blocktrans with cl.result_count as total_count and cl.opts.verbose_name as module_name %}<span class="_acnt">0</span> of {{ total_count }} {{ module_name }} selected{% endblocktrans %}
     6    {% else %}
     7        {% blocktrans with cl.result_count as total_count and cl.opts.verbose_name_plural as module_name %}<span class="_acnt">0</span> of {{ total_count }} {{ module_name }} selected{% endblocktrans %}
     8    {% endifequal %}
     9    </span>
    310    {% for field in action_form %}<label>{{ field.label }} {{ field }}</label>{% endfor %}
    411    <button type="submit" class="button" title="{% trans "Run the selected action" %}" name="index" value="{{ action_index|default:0 }}">{% trans "Go" %}</button>
    512</div>
Back to Top