diff --git a/core/modules/views_ui/js/views-admin.js b/core/modules/views_ui/js/views-admin.js index d0204e6..ece184d 100644 --- a/core/modules/views_ui/js/views-admin.js +++ b/core/modules/views_ui/js/views-admin.js @@ -519,7 +519,7 @@ /** * Dynamically click the button that adds a new filter group. */ - clickAddGroupButton: function () { + clickAddGroupButton: function (event) { // Due to conflicts between Drupal core's AJAX system and the Views AJAX // system, the only way to get this to work seems to be to trigger both the // mousedown and submit events. diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/RearrangeFilter.php b/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/RearrangeFilter.php index e15e440..a9f76d1 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/RearrangeFilter.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/RearrangeFilter.php @@ -17,6 +17,13 @@ class RearrangeFilter extends ViewsFormBase { /** + * Constucts a new RearrangeFilter object. + */ + public function __construct($type = NULL) { + $this->setType($type); + } + + /** * {@inheritdoc} */ public function getFormKey() { @@ -199,12 +206,23 @@ public function buildForm(array $form, array &$form_state) { ); } + // Get requestUri from request object. + $requestUri = $this->getRequest()->getRequestUri(); + + // Views provides its own custom handling of AJAX form submissions. Usually + // this happens at the same path, but custom paths may be specified in + // $form_state. + $form_path = empty($form_state['path']) ? $requestUri : $form_state['path']; + $view->getStandardButtons($form, $form_state, 'views_ui_rearrange_filter_form'); $form['actions']['add_group'] = array( '#type' => 'submit', '#value' => $this->t('Create new filter group'), '#id' => 'views-add-group', '#group' => 'add', + '#ajax' => array( + 'path' => $form_path, + ), ); return $form; @@ -255,8 +273,8 @@ public function submitForm(array &$form, array &$form_state) { // If the #group property is set on the clicked button, that means we are // either adding or removing a group, not actually updating the filters. - if (!empty($form_state['clicked_button']['#group'])) { - if ($form_state['clicked_button']['#group'] == 'add') { + if (!empty($form_state['triggering_element']['#group'])) { + if ($form_state['triggering_element']['#group'] == 'add') { // Add a new group $groups['groups'][] = 'AND'; } @@ -289,7 +307,7 @@ public function submitForm(array &$form, array &$form_state) { ); // Return to this form except on actual Update. - $form_state['view']->addFormToStack('rearrange-filter', $form_state['display_id'], 'filter'); + $form_state['view']->addFormToStack('rearrange-filter', $form_state['display_id']); } else { // The actual update button was clicked. Remove the empty groups, and