From: Stas Vilchik Date: Wed, 15 Oct 2014 08:55:53 +0000 (+0200) Subject: SONAR-5736 The select list component does not fetch more than one page X-Git-Tag: 4.5.1-RC1~29 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=01ae5b1fed246ac25e15e8efe2ba75fd0c5b9516;p=sonarqube.git SONAR-5736 The select list component does not fetch more than one page --- diff --git a/server/sonar-web/src/main/js/common/select-list.js b/server/sonar-web/src/main/js/common/select-list.js index e19dea825ec..30ca5e50a6f 100644 --- a/server/sonar-web/src/main/js/common/select-list.js +++ b/server/sonar-web/src/main/js/common/select-list.js @@ -51,8 +51,10 @@ requirejs(['backbone'], function (Backbone) { settings = $.extend(this.settings, options); settings.data.page = nextPage; - + settings.remove = false; this.fetch(settings); + } else { + options.error(); } } @@ -171,6 +173,28 @@ requirejs(['backbone'], function (Backbone) { this.listenTo(this.collection, 'remove', this.removeModel); this.listenTo(this.collection, 'change:selected', this.confirmFilter); this.settings = options.settings; + + var that = this; + this.showFetchSpinner = function () { + that.$listContainer.addClass('loading'); + }; + this.hideFetchSpinner = function () { + that.$listContainer.removeClass('loading'); + }; + + var onScroll = function () { + that.showFetchSpinner(); + + that.collection.fetchNextPage({ + success: function () { + that.hideFetchSpinner(); + }, + error: function () { + that.hideFetchSpinner(); + } + }); + }; + this.onScroll = _.throttle(onScroll, 1000); }, render: function () { @@ -331,29 +355,12 @@ requirejs(['backbone'], function (Backbone) { this.filterBySelection(); }, - showFetchSpinner: function () { - this.$listContainer.addClass('loading'); - }, - - hideFetchSpinner: function () { - this.$listContainer.removeClass('loading'); - }, - scroll: function () { var scrollBottom = this.$listContainer.scrollTop() >= - this.$list[0].scrollHeight - this.$listContainer.outerHeight(), - that = this; + this.$list[0].scrollHeight - this.$listContainer.outerHeight(); if (scrollBottom && this.collection.more) { - $.throttle(250, function () { - that.showFetchSpinner(); - - that.collection.fetchNextPage({ - success: function () { - that.hideFetchSpinner(); - } - }); - })(); + this.onScroll(); } }