diff --git a/web/pgadmin/browser/static/js/node.ui.js b/web/pgadmin/browser/static/js/node.ui.js index 064ca3125..393394d2b 100644 --- a/web/pgadmin/browser/static/js/node.ui.js +++ b/web/pgadmin/browser/static/js/node.ui.js @@ -17,47 +17,56 @@ define([ function SelectAll() {} SelectAll.prototype.render = function(decorated) { - var self = this, - $rendered = decorated.call(this), - $selectAll = $([ - '', - ].join('')), - $unselectAll = $([ - '', - ].join('')), - $btnContainer = $( - '
' - ).append($selectAll).append($unselectAll); + let self = this; + let $rendered = decorated.call(this); + + let $selectAll = $([ + '', + ].join('')); + + let $unselectAll = $([ + '', + ].join('')); + + let $btnContainer = $( + '
' + ).append($selectAll).append($unselectAll); if (!this.$element.prop('multiple')) { // this isn't a multi-select -> don't add the buttons! return $rendered; } $rendered.find('.select2-dropdown').prepend($btnContainer); + // Select All button click $selectAll.on('click', function() { $rendered.find('.select2-results__option[aria-selected=false]').each( function() { + // Note: With latest version we do not get data in the data attribute of a element + // Hence as per new logic we will fetch the data from the cache created by Select2. + let data = Utils.GetData($(this)[0], 'data'); self.trigger('select', { - data: $(this).data('data'), + data: data, }); } ); self.trigger('close'); }); + // Unselect All button click $unselectAll.on('click', function() { $rendered.find('.select2-results__option[aria-selected=true]').each( function() { + let data = Utils.GetData($(this)[0], 'data'); self.trigger('unselect', { - data: $(this).data('data'), + data: data, }); } );