Преглед на файлове

Fix RelatedFieldAjaxListFilter attributes to template passing

Denis K преди 8 години
родител
ревизия
d9076fa39a
променени са 3 файла, в които са добавени 13 реда и са изтрити 0 реда
  1. 1 0
      jet/filters.py
  2. 4 0
      jet/static/jet/js/src/layout-updaters/toolbar.js
  3. 8 0
      jet/templates/jet/related_field_ajax_list_filter.html

+ 1 - 0
jet/filters.py

@@ -15,6 +15,7 @@ except ImportError: # Django 1.6
 
 
 class RelatedFieldAjaxListFilter(RelatedFieldListFilter):
+    template = 'jet/related_field_ajax_list_filter.html'
     ajax_attrs = None
 
     def has_output(self):

+ 4 - 0
jet/static/jet/js/src/layout-updaters/toolbar.js

@@ -32,6 +32,10 @@ ToolbarUpdater.prototype = {
                 var $select = $('<select>').addClass('changelist-filter-select');
                 var $items = $element.find('li');
 
+                $.each($element.prop('attributes'), function() {
+                    $select.attr(this.name, this.value);
+                });
+
                 if ($items.filter('.selected').length > 1) {
                     $select.attr('multiple', true);
                 }

+ 8 - 0
jet/templates/jet/related_field_ajax_list_filter.html

@@ -0,0 +1,8 @@
+{% load i18n %}
+<h3>{% blocktrans with filter_title=title %} By {{ filter_title }} {% endblocktrans %}</h3>
+<ul{% if spec.ajax_attrs %} class="ajax"{% endif %}{% if spec.ajax_attrs %}{{ spec.ajax_attrs }}{% endif %}>
+    {% for choice in choices %}
+        <li{% if choice.selected %} class="selected"{% endif %}>
+        <a href="{{ choice.query_string|iriencode }}" title="{{ choice.display }}">{{ choice.display }}</a></li>
+    {% endfor %}
+</ul>