mirror of https://github.com/django/django.git
Fixed #26575 -- Disabled SelectFilter buttons when inactive.
This commit is contained in:
parent
c9c5ccbd41
commit
e00d77c483
|
@ -111,10 +111,16 @@ Requires jQuery, core.js, and SelectBox.js.
|
||||||
from_box.setAttribute('name', from_box.getAttribute('name') + '_old');
|
from_box.setAttribute('name', from_box.getAttribute('name') + '_old');
|
||||||
|
|
||||||
// Set up the JavaScript event handlers for the select box filter interface
|
// Set up the JavaScript event handlers for the select box filter interface
|
||||||
addEvent(choose_all, 'click', function() { SelectBox.move_all(field_id + '_from', field_id + '_to'); SelectFilter.refresh_icons(field_id); });
|
var move_selection = function(elem, move_func, from, to) {
|
||||||
addEvent(add_link, 'click', function() { SelectBox.move(field_id + '_from', field_id + '_to'); SelectFilter.refresh_icons(field_id); });
|
if (elem.className.indexOf('active') !== -1) {
|
||||||
addEvent(remove_link, 'click', function() { SelectBox.move(field_id + '_to', field_id + '_from'); SelectFilter.refresh_icons(field_id); });
|
move_func(from, to);
|
||||||
addEvent(clear_all, 'click', function() { SelectBox.move_all(field_id + '_to', field_id + '_from'); SelectFilter.refresh_icons(field_id); });
|
SelectFilter.refresh_icons(field_id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
addEvent(choose_all, 'click', function(e) { move_selection(this, SelectBox.move_all, field_id + '_from', field_id + '_to'); });
|
||||||
|
addEvent(add_link, 'click', function(e) { move_selection(this, SelectBox.move, field_id + '_from', field_id + '_to'); });
|
||||||
|
addEvent(remove_link, 'click', function(e) { move_selection(this, SelectBox.move, field_id + '_to', field_id + '_from'); });
|
||||||
|
addEvent(clear_all, 'click', function(e) { move_selection(this, SelectBox.move_all, field_id + '_to', field_id + '_from'); });
|
||||||
addEvent(filter_input, 'keypress', function(e) { SelectFilter.filter_key_press(e, field_id); });
|
addEvent(filter_input, 'keypress', function(e) { SelectFilter.filter_key_press(e, field_id); });
|
||||||
addEvent(filter_input, 'keyup', function(e) { SelectFilter.filter_key_up(e, field_id); });
|
addEvent(filter_input, 'keyup', function(e) { SelectFilter.filter_key_up(e, field_id); });
|
||||||
addEvent(filter_input, 'keydown', function(e) { SelectFilter.filter_key_down(e, field_id); });
|
addEvent(filter_input, 'keydown', function(e) { SelectFilter.filter_key_down(e, field_id); });
|
||||||
|
|
|
@ -158,6 +158,18 @@ class AdminSeleniumTestCase(SeleniumTestCase, StaticLiveServerTestCase):
|
||||||
actual_values.append(option.get_attribute('value'))
|
actual_values.append(option.get_attribute('value'))
|
||||||
self.assertEqual(values, actual_values)
|
self.assertEqual(values, actual_values)
|
||||||
|
|
||||||
|
def assertSelectedOptions(self, selector, values):
|
||||||
|
"""
|
||||||
|
Asserts that the <SELECT> widget identified by `selector` has the
|
||||||
|
selected options with the given `values`.
|
||||||
|
"""
|
||||||
|
options = self.selenium.find_elements_by_css_selector('%s > option' % selector)
|
||||||
|
actual_values = []
|
||||||
|
for option in options:
|
||||||
|
if option.get_attribute('selected'):
|
||||||
|
actual_values.append(option.get_attribute('value'))
|
||||||
|
self.assertEqual(values, actual_values)
|
||||||
|
|
||||||
def has_css_class(self, selector, klass):
|
def has_css_class(self, selector, klass):
|
||||||
"""
|
"""
|
||||||
Returns True if the element identified by `selector` has the CSS class
|
Returns True if the element identified by `selector` has the CSS class
|
||||||
|
|
|
@ -966,6 +966,32 @@ class HorizontalVerticalFilterSeleniumTests(AdminWidgetSeleniumTestCase):
|
||||||
str(self.arthur.id), str(self.cliff.id),
|
str(self.arthur.id), str(self.cliff.id),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# Choose some more options --------------------------------------------
|
||||||
|
self.get_select_option(from_box, str(self.peter.id)).click()
|
||||||
|
self.get_select_option(from_box, str(self.lisa.id)).click()
|
||||||
|
|
||||||
|
# Confirm they're selected after clicking inactive buttons: ticket #26575
|
||||||
|
self.assertSelectedOptions(from_box, [str(self.peter.id), str(self.lisa.id)])
|
||||||
|
self.selenium.find_element_by_id(remove_link).click()
|
||||||
|
self.assertSelectedOptions(from_box, [str(self.peter.id), str(self.lisa.id)])
|
||||||
|
|
||||||
|
# Unselect the options ------------------------------------------------
|
||||||
|
self.get_select_option(from_box, str(self.peter.id)).click()
|
||||||
|
self.get_select_option(from_box, str(self.lisa.id)).click()
|
||||||
|
|
||||||
|
# Choose some more options --------------------------------------------
|
||||||
|
self.get_select_option(to_box, str(self.jason.id)).click()
|
||||||
|
self.get_select_option(to_box, str(self.john.id)).click()
|
||||||
|
|
||||||
|
# Confirm they're selected after clicking inactive buttons: ticket #26575
|
||||||
|
self.assertSelectedOptions(to_box, [str(self.jason.id), str(self.john.id)])
|
||||||
|
self.selenium.find_element_by_id(choose_link).click()
|
||||||
|
self.assertSelectedOptions(to_box, [str(self.jason.id), str(self.john.id)])
|
||||||
|
|
||||||
|
# Unselect the options ------------------------------------------------
|
||||||
|
self.get_select_option(to_box, str(self.jason.id)).click()
|
||||||
|
self.get_select_option(to_box, str(self.john.id)).click()
|
||||||
|
|
||||||
def test_basic(self):
|
def test_basic(self):
|
||||||
self.school.students.set([self.lisa, self.peter])
|
self.school.students.set([self.lisa, self.peter])
|
||||||
self.school.alumni.set([self.lisa, self.peter])
|
self.school.alumni.set([self.lisa, self.peter])
|
||||||
|
|
Loading…
Reference in New Issue