Loading js/frontUi.js +33 −32 Original line number Diff line number Diff line Loading @@ -17,22 +17,24 @@ }; /** * Views Bulk Operation selection object. * VBO selection handling class. */ Drupal.viewsBulkOperationsSelection = { view_id: '', display_id: '', list: {}, $summary: null, $actionSelect: null, vbo_form: null, class viewsBulkOperationsSelection { constructor(vbo_form) { this.vbo_form = vbo_form; this.$actionSelect = $('select[name="action"]', vbo_form); this.view_id = ''; this.display_id = ''; this.$summary = null; } /** * Bind event handlers to an element. * * @param {jQuery} element */ bindEventHandlers: function ($element, index) { bindEventHandlers($element, index) { if ($element.length) { var selectionObject = this; $element.on('keypress', function (event) { Loading @@ -54,17 +56,17 @@ } }); } }, } bindCheckboxes: function () { bindCheckboxes() { var selectionObject = this; var checkboxes = $('.form-checkbox', this.vbo_form); checkboxes.on('change', function (event) { selectionObject.toggleButtonsState(); }); }, } toggleButtonsState: function() { toggleButtonsState() { // If no rows are checked, disable any form submit actions. var checkedCheckboxes = $('.form-checkbox:checked', this.vbo_form); var buttons = $('[id^="edit-actions"] input[type="submit"], [id^="edit-actions"] button[type="submit"]', this.vbo_form); Loading @@ -77,16 +79,16 @@ else { buttons.prop('disabled', !anyItemsSelected); } }, } bindActionSelect: function () { bindActionSelect() { if (this.$actionSelect.length) { var selectionObject = this; this.$actionSelect.on('change', function (event) { selectionObject.toggleButtonsState(); }); } }, } /** * Perform an AJAX request to update selection. Loading @@ -95,7 +97,7 @@ * @param {mixed} index * @param {string} value */ update: function (state, index, value) { update(state, index, value) { if (value === undefined) { value = null; } Loading Loading @@ -148,8 +150,7 @@ var $viewsTables = $('.vbo-table', $vboForm); var $primarySelectAll = $('.vbo-select-all', $vboForm); var tableSelectAll = []; Drupal.viewsBulkOperationsSelection.vbo_form = $vboForm; Drupal.viewsBulkOperationsSelection.$actionSelect = $('select[name="action"]', $vboForm); let vboSelection = new viewsBulkOperationsSelection($vboForm); // When grouping is enabled, there can be multiple tables. if ($viewsTables.length) { Loading @@ -163,13 +164,13 @@ var $multiSelectElement = $vboForm.find('.vbo-multipage-selector').first(); if ($multiSelectElement.length) { Drupal.viewsBulkOperationsSelection.$selectionInfo = $multiSelectElement.find('.vbo-info-list-wrapper').first(); Drupal.viewsBulkOperationsSelection.$summary = $multiSelectElement.find('summary').first(); Drupal.viewsBulkOperationsSelection.view_id = $multiSelectElement.attr('data-view-id'); Drupal.viewsBulkOperationsSelection.display_id = $multiSelectElement.attr('data-display-id'); vboSelection.$selectionInfo = $multiSelectElement.find('.vbo-info-list-wrapper').first(); vboSelection.$summary = $multiSelectElement.find('summary').first(); vboSelection.view_id = $multiSelectElement.attr('data-view-id'); vboSelection.display_id = $multiSelectElement.attr('data-display-id'); // Get the list of all checkbox values and add AJAX callback. Drupal.viewsBulkOperationsSelection.list = []; vboSelection.list = []; var $contentWrappers; if ($viewsTables.length) { Loading @@ -181,19 +182,19 @@ $contentWrappers.each(function (index) { var $contentWrapper = $(this); Drupal.viewsBulkOperationsSelection.list[index] = {}; vboSelection.list[index] = {}; $contentWrapper.find('.views-field-views-bulk-operations-bulk-form input[type="checkbox"]').each(function () { var value = $(this).val(); if (value != 'on') { Drupal.viewsBulkOperationsSelection.list[index][value] = value; Drupal.viewsBulkOperationsSelection.bindEventHandlers($(this), index); vboSelection.list[index][value] = value; vboSelection.bindEventHandlers($(this), index); } }); // Bind event handlers to select all checkbox. if ($viewsTables.length && tableSelectAll.length) { Drupal.viewsBulkOperationsSelection.bindEventHandlers(tableSelectAll[index], index); vboSelection.bindEventHandlers(tableSelectAll[index], index); } }); } Loading Loading @@ -228,12 +229,12 @@ }); if ($multiSelectElement.length) { Drupal.viewsBulkOperationsSelection.bindEventHandlers($primarySelectAll, 'selection_method_change'); vboSelection.bindEventHandlers($primarySelectAll, 'selection_method_change'); } } Drupal.viewsBulkOperationsSelection.bindCheckboxes(); Drupal.viewsBulkOperationsSelection.bindActionSelect(); Drupal.viewsBulkOperationsSelection.toggleButtonsState(); vboSelection.bindCheckboxes(); vboSelection.bindActionSelect(); vboSelection.toggleButtonsState(); }; })(jQuery, Drupal); src/Plugin/views/field/ViewsBulkOperationsBulkForm.php +1 −1 Original line number Diff line number Diff line Loading @@ -791,7 +791,7 @@ class ViewsBulkOperationsBulkForm extends FieldPluginBase implements CacheableDe $form['header'][$this->options['id']]['multipage']['list'] = $this->getMultipageList($this->tempStoreData); $form['header'][$this->options['id']]['multipage']['clear'] = [ '#type' => 'submit', '#value' => $this->t('Clear'), '#value' => $this->t('Clear selection'), '#submit' => [[$this, 'clearSelection']], '#limit_validation_errors' => [], ]; Loading Loading
js/frontUi.js +33 −32 Original line number Diff line number Diff line Loading @@ -17,22 +17,24 @@ }; /** * Views Bulk Operation selection object. * VBO selection handling class. */ Drupal.viewsBulkOperationsSelection = { view_id: '', display_id: '', list: {}, $summary: null, $actionSelect: null, vbo_form: null, class viewsBulkOperationsSelection { constructor(vbo_form) { this.vbo_form = vbo_form; this.$actionSelect = $('select[name="action"]', vbo_form); this.view_id = ''; this.display_id = ''; this.$summary = null; } /** * Bind event handlers to an element. * * @param {jQuery} element */ bindEventHandlers: function ($element, index) { bindEventHandlers($element, index) { if ($element.length) { var selectionObject = this; $element.on('keypress', function (event) { Loading @@ -54,17 +56,17 @@ } }); } }, } bindCheckboxes: function () { bindCheckboxes() { var selectionObject = this; var checkboxes = $('.form-checkbox', this.vbo_form); checkboxes.on('change', function (event) { selectionObject.toggleButtonsState(); }); }, } toggleButtonsState: function() { toggleButtonsState() { // If no rows are checked, disable any form submit actions. var checkedCheckboxes = $('.form-checkbox:checked', this.vbo_form); var buttons = $('[id^="edit-actions"] input[type="submit"], [id^="edit-actions"] button[type="submit"]', this.vbo_form); Loading @@ -77,16 +79,16 @@ else { buttons.prop('disabled', !anyItemsSelected); } }, } bindActionSelect: function () { bindActionSelect() { if (this.$actionSelect.length) { var selectionObject = this; this.$actionSelect.on('change', function (event) { selectionObject.toggleButtonsState(); }); } }, } /** * Perform an AJAX request to update selection. Loading @@ -95,7 +97,7 @@ * @param {mixed} index * @param {string} value */ update: function (state, index, value) { update(state, index, value) { if (value === undefined) { value = null; } Loading Loading @@ -148,8 +150,7 @@ var $viewsTables = $('.vbo-table', $vboForm); var $primarySelectAll = $('.vbo-select-all', $vboForm); var tableSelectAll = []; Drupal.viewsBulkOperationsSelection.vbo_form = $vboForm; Drupal.viewsBulkOperationsSelection.$actionSelect = $('select[name="action"]', $vboForm); let vboSelection = new viewsBulkOperationsSelection($vboForm); // When grouping is enabled, there can be multiple tables. if ($viewsTables.length) { Loading @@ -163,13 +164,13 @@ var $multiSelectElement = $vboForm.find('.vbo-multipage-selector').first(); if ($multiSelectElement.length) { Drupal.viewsBulkOperationsSelection.$selectionInfo = $multiSelectElement.find('.vbo-info-list-wrapper').first(); Drupal.viewsBulkOperationsSelection.$summary = $multiSelectElement.find('summary').first(); Drupal.viewsBulkOperationsSelection.view_id = $multiSelectElement.attr('data-view-id'); Drupal.viewsBulkOperationsSelection.display_id = $multiSelectElement.attr('data-display-id'); vboSelection.$selectionInfo = $multiSelectElement.find('.vbo-info-list-wrapper').first(); vboSelection.$summary = $multiSelectElement.find('summary').first(); vboSelection.view_id = $multiSelectElement.attr('data-view-id'); vboSelection.display_id = $multiSelectElement.attr('data-display-id'); // Get the list of all checkbox values and add AJAX callback. Drupal.viewsBulkOperationsSelection.list = []; vboSelection.list = []; var $contentWrappers; if ($viewsTables.length) { Loading @@ -181,19 +182,19 @@ $contentWrappers.each(function (index) { var $contentWrapper = $(this); Drupal.viewsBulkOperationsSelection.list[index] = {}; vboSelection.list[index] = {}; $contentWrapper.find('.views-field-views-bulk-operations-bulk-form input[type="checkbox"]').each(function () { var value = $(this).val(); if (value != 'on') { Drupal.viewsBulkOperationsSelection.list[index][value] = value; Drupal.viewsBulkOperationsSelection.bindEventHandlers($(this), index); vboSelection.list[index][value] = value; vboSelection.bindEventHandlers($(this), index); } }); // Bind event handlers to select all checkbox. if ($viewsTables.length && tableSelectAll.length) { Drupal.viewsBulkOperationsSelection.bindEventHandlers(tableSelectAll[index], index); vboSelection.bindEventHandlers(tableSelectAll[index], index); } }); } Loading Loading @@ -228,12 +229,12 @@ }); if ($multiSelectElement.length) { Drupal.viewsBulkOperationsSelection.bindEventHandlers($primarySelectAll, 'selection_method_change'); vboSelection.bindEventHandlers($primarySelectAll, 'selection_method_change'); } } Drupal.viewsBulkOperationsSelection.bindCheckboxes(); Drupal.viewsBulkOperationsSelection.bindActionSelect(); Drupal.viewsBulkOperationsSelection.toggleButtonsState(); vboSelection.bindCheckboxes(); vboSelection.bindActionSelect(); vboSelection.toggleButtonsState(); }; })(jQuery, Drupal);
src/Plugin/views/field/ViewsBulkOperationsBulkForm.php +1 −1 Original line number Diff line number Diff line Loading @@ -791,7 +791,7 @@ class ViewsBulkOperationsBulkForm extends FieldPluginBase implements CacheableDe $form['header'][$this->options['id']]['multipage']['list'] = $this->getMultipageList($this->tempStoreData); $form['header'][$this->options['id']]['multipage']['clear'] = [ '#type' => 'submit', '#value' => $this->t('Clear'), '#value' => $this->t('Clear selection'), '#submit' => [[$this, 'clearSelection']], '#limit_validation_errors' => [], ]; Loading