aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/webapp/javascripts
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2014-03-04 19:58:39 +0100
committerStas Vilchik <vilchiks@gmail.com>2014-03-04 19:58:49 +0100
commitb8422fb4f8fa94ee20810cc92d94b6b0bcd1c47b (patch)
treec779668d9365d037a47b4c06d29ee86f8db6d825 /sonar-server/src/main/webapp/javascripts
parentf90ef17c9a5226a699b4bc4316d9626b92940c0a (diff)
downloadsonarqube-b8422fb4f8fa94ee20810cc92d94b6b0bcd1c47b.tar.gz
sonarqube-b8422fb4f8fa94ee20810cc92d94b6b0bcd1c47b.zip
SONAR-4854 Support of the new rules WS
Diffstat (limited to 'sonar-server/src/main/webapp/javascripts')
-rw-r--r--sonar-server/src/main/webapp/javascripts/navigator/filters/ajax-select-filters.js19
-rw-r--r--sonar-server/src/main/webapp/javascripts/navigator/filters/rule-filters.js48
2 files changed, 32 insertions, 35 deletions
diff --git a/sonar-server/src/main/webapp/javascripts/navigator/filters/ajax-select-filters.js b/sonar-server/src/main/webapp/javascripts/navigator/filters/ajax-select-filters.js
index 02bb8e25539..070164abf0f 100644
--- a/sonar-server/src/main/webapp/javascripts/navigator/filters/ajax-select-filters.js
+++ b/sonar-server/src/main/webapp/javascripts/navigator/filters/ajax-select-filters.js
@@ -1,8 +1,6 @@
define(['backbone', 'navigator/filters/base-filters', 'navigator/filters/choice-filters', 'common/handlebars-extensions'], function (Backbone, BaseFilters, ChoiceFilters) {
- var PAGE_SIZE = 100,
- UNASSIGNED = '';
-
+ var PAGE_SIZE = 100;
var Suggestions = Backbone.Collection.extend({
@@ -27,7 +25,7 @@ define(['backbone', 'navigator/filters/base-filters', 'navigator/filters/choice-
}, options.data || {});
var settings = _.extend({}, options, { data: this.data });
- Backbone.Collection.prototype.fetch.call(this, settings);
+ return Backbone.Collection.prototype.fetch.call(this, settings);
},
@@ -35,8 +33,9 @@ define(['backbone', 'navigator/filters/base-filters', 'navigator/filters/choice-
if (this.more) {
this.data.p += 1;
var settings = _.extend({ remove: false }, options, { data: this.data });
- this.fetch(settings);
+ return this.fetch(settings);
}
+ return false;
}
});
@@ -150,12 +149,14 @@ define(['backbone', 'navigator/filters/base-filters', 'navigator/filters/choice-
scroll: function() {
- var el = this.$('.choices'),
- scrollBottom = el.scrollTop() >=
- el[0].scrollHeight - el.outerHeight();
+ var that = this,
+ el = this.$('.choices'),
+ scrollBottom = el.scrollTop() >= el[0].scrollHeight - el.outerHeight();
if (scrollBottom) {
- this.options.filterView.selection.fetchNextPage();
+ this.options.filterView.choices.fetchNextPage().done(function() {
+ that.updateLists();
+ });
}
},
diff --git a/sonar-server/src/main/webapp/javascripts/navigator/filters/rule-filters.js b/sonar-server/src/main/webapp/javascripts/navigator/filters/rule-filters.js
index 26e908f9090..62a37f952e5 100644
--- a/sonar-server/src/main/webapp/javascripts/navigator/filters/rule-filters.js
+++ b/sonar-server/src/main/webapp/javascripts/navigator/filters/rule-filters.js
@@ -1,35 +1,18 @@
define(['backbone', 'navigator/filters/base-filters', 'navigator/filters/ajax-select-filters'], function (Backbone, BaseFilters, AjaxSelectFilters) {
- var RuleSuggestions = Backbone.Collection.extend({
+ var RuleSuggestions = AjaxSelectFilters.Suggestions.extend({
url: function() {
- return baseUrl + '/api/rules';
+ return baseUrl + '/api/rules/list';
},
parse: function(r) {
- return _
- .filter(r, function(item) {
- return item.title;
- })
- .map(function(item) {
- return { id: item.key, text: item.title };
- });
- },
-
-
- fetch: function(options) {
- var data = {};
- if (options.data && options.data.s) {
- data.searchtext = options.data.s;
- }
-
- var settings = _.extend({}, options, { data: data });
- Backbone.Collection.prototype.fetch.call(this, settings);
- },
-
-
- fetchNextPage: function() {}
+ this.more = r.more;
+ return r.results.map(function(r) {
+ return { id: r.key, text: r.name };
+ });
+ }
});
@@ -44,8 +27,21 @@ define(['backbone', 'navigator/filters/base-filters', 'navigator/filters/ajax-se
},
- createRequest: function() {
-
+ createRequest: function(v) {
+ var that = this;
+ return jQuery
+ .ajax({
+ url: baseUrl + '/api/rules/show',
+ type: 'GET',
+ data: { key: v }
+ })
+ .done(function (r) {
+ that.choices.add(new Backbone.Model({
+ id: r.rule.key,
+ text: r.rule.name,
+ checked: true
+ }));
+ });
}
});