Commit 14c952d5 authored by David Sanders's avatar David Sanders Committed by Tim Graham
Browse files

Fixed #26612 -- Fixed SelectFilter2 buttons changing URL.

parent 996cadfa
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -111,16 +111,17 @@ Requires jQuery, core.js, and SelectBox.js.
            from_box.setAttribute('name', from_box.getAttribute('name') + '_old');

            // Set up the JavaScript event handlers for the select box filter interface
            var move_selection = function(elem, move_func, from, to) {
            var move_selection = function(e, elem, move_func, from, to) {
                if (elem.className.indexOf('active') !== -1) {
                    move_func(from, to);
                    SelectFilter.refresh_icons(field_id);
                }
                e.preventDefault();
            };
            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(choose_all, 'click', function(e) { move_selection(e, this, SelectBox.move_all, field_id + '_from', field_id + '_to'); });
            addEvent(add_link, 'click', function(e) { move_selection(e, this, SelectBox.move, field_id + '_from', field_id + '_to'); });
            addEvent(remove_link, 'click', function(e) { move_selection(e, this, SelectBox.move, field_id + '_to', field_id + '_from'); });
            addEvent(clear_all, 'click', function(e) { move_selection(e, 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, 'keyup', function(e) { SelectFilter.filter_key_up(e, field_id); });
            addEvent(filter_input, 'keydown', function(e) { SelectFilter.filter_key_down(e, field_id); });
+5 −0
Original line number Diff line number Diff line
@@ -881,6 +881,8 @@ class HorizontalVerticalFilterSeleniumTests(AdminWidgetSeleniumTestCase):
            self.assertEqual(self.has_css_class(remove_all_link, 'active'), remove_all)

    def execute_basic_operations(self, mode, field_name):
        original_url = self.selenium.current_url

        from_box = '#id_%s_from' % field_name
        to_box = '#id_%s_to' % field_name
        choose_link = 'id_%s_add_link' % field_name
@@ -1014,6 +1016,9 @@ class HorizontalVerticalFilterSeleniumTests(AdminWidgetSeleniumTestCase):
        self.get_select_option(to_box, str(self.jason.id)).click()
        self.get_select_option(to_box, str(self.john.id)).click()

        # Pressing buttons shouldn't change the URL.
        self.assertEqual(self.selenium.current_url, original_url)

    def test_basic(self):
        self.school.students.set([self.lisa, self.peter])
        self.school.alumni.set([self.lisa, self.peter])