Commit d807d87e authored by eduardo morales alberti's avatar eduardo morales alberti Committed by Marcin Grabias
Browse files

Issue #3349616 by Eduardo Morales Alberti, CRZDEV, Graber: Add throbber on Ajax petition

parent 938f1820
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -11,6 +11,9 @@ views.field.views_bulk_operations_bulk_form:
    form_step:
      type: boolean
      label: 'Display configuration form on a separate page'
    ajax_loader:
      type: boolean
      label: 'Show throbber on VBO ajax petitions.'
    buttons:
      type: boolean
      label: 'Display action options as buttons'
+8 −2
Original line number Diff line number Diff line
@@ -128,14 +128,20 @@
        var $selectionInfo = this.$selectionInfo;
        var target_uri = drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix + 'views-bulk-operations/ajax/' + this.view_id + '/' + this.display_id;

        var ajaxDrupal = Drupal.ajax({
        var ajax_options = {
          url: target_uri,
          progress: false,
          submit: {
            list: list,
            op: op
          }
        });
        };

        if (drupalSettings.hasOwnProperty('vbo') && drupalSettings.vbo.hasOwnProperty('ajax_loader') && drupalSettings.vbo.ajax_loader) {
          ajax_options.progress = { type: 'fullscreen' };
        }

        var ajaxDrupal = Drupal.ajax(ajax_options);

        ajaxDrupal.original_success = ajaxDrupal.success;
        ajaxDrupal.success = function (data, status) {
+12 −0
Original line number Diff line number Diff line
@@ -381,6 +381,7 @@ class ViewsBulkOperationsBulkForm extends FieldPluginBase implements CacheableDe
    $options['batch'] = ['default' => TRUE];
    $options['batch_size'] = ['default' => 10];
    $options['form_step'] = ['default' => TRUE];
    $options['ajax_loader'] = ['default' => FALSE];
    $options['buttons'] = ['default' => FALSE];
    $options['clear_on_exposed'] = ['default' => TRUE];
    $options['action_title'] = ['default' => $this->t('Action')];
@@ -432,6 +433,13 @@ class ViewsBulkOperationsBulkForm extends FieldPluginBase implements CacheableDe
      '#access' => FALSE,
    ];

    $form['ajax_loader'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Show ajax throbber.'),
      '#description' => $this->t('With this enabled, a throbber will be shown when an ajax petition from VBO is triggered.'),
      '#default_value' => $this->options['ajax_loader'],
    ];

    $form['buttons'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Display selectable actions as buttons.'),
@@ -620,6 +628,10 @@ class ViewsBulkOperationsBulkForm extends FieldPluginBase implements CacheableDe
      $this->view->style_plugin->options['views_bulk_operations_enabled'] = TRUE;
    }
    $form['#attached']['library'][] = 'views_bulk_operations/frontUi';
    if ($this->options['ajax_loader']) {
      $form['#attached']['drupalSettings']['vbo']['ajax_loader'] = TRUE;
    }

    // Only add the bulk form options and buttons if
    // there are results and any actions are available.
    $action_options = $this->getBulkOptions();
+1 −0
Original line number Diff line number Diff line
@@ -166,6 +166,7 @@ display:
          batch: false
          batch_size: 10
          form_step: true
          ajax_loader: true
          buttons: true
          action_title: Action
          clear_on_exposed: true
+1 −0
Original line number Diff line number Diff line
@@ -164,6 +164,7 @@ display:
          batch: true
          batch_size: 2
          form_step: true
          ajax_loader: false
          buttons: false
          action_title: Action
          clear_on_exposed: true
Loading