aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/quality-profiles
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/quality-profiles')
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/actions-view.js33
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/app.js4
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/profile-view.js1
-rw-r--r--server/sonar-web/src/main/js/quality-profiles/profiles-view.js15
4 files changed, 41 insertions, 12 deletions
diff --git a/server/sonar-web/src/main/js/quality-profiles/actions-view.js b/server/sonar-web/src/main/js/quality-profiles/actions-view.js
index 9cb0e2d3f98..3581f909c1b 100644
--- a/server/sonar-web/src/main/js/quality-profiles/actions-view.js
+++ b/server/sonar-web/src/main/js/quality-profiles/actions-view.js
@@ -32,7 +32,9 @@ define([
events: {
'click #quality-profiles-create': 'onCreateClick',
'click #quality-profiles-restore': 'onRestoreClick',
- 'click #quality-profiles-restore-built-in': 'onRestoreBuiltInClick'
+ 'click #quality-profiles-restore-built-in': 'onRestoreBuiltInClick',
+
+ 'click .js-filter-by-language': 'onLanguageClick'
},
onCreateClick: function (e) {
@@ -50,9 +52,15 @@ define([
this.restoreBuiltIn();
},
+ onLanguageClick: function (e) {
+ e.preventDefault();
+ var language = $(e.currentTarget).data('language');
+ this.filterByLanguage(language);
+ },
+
create: function () {
var that = this;
- $.when(this.requestLanguages(), this.requestImporters()).done(function () {
+ this.requestImporters().done(function () {
new CreateProfileView({
collection: that.collection,
languages: that.languages,
@@ -68,13 +76,10 @@ define([
},
restoreBuiltIn: function () {
- var that = this;
- this.requestLanguages().done(function (r) {
- new RestoreBuiltInProfilesView({
- collection: that.collection,
- languages: r.languages
- }).render();
- });
+ new RestoreBuiltInProfilesView({
+ collection: this.collection,
+ languages: this.languages
+ }).render();
},
requestLanguages: function () {
@@ -93,9 +98,17 @@ define([
});
},
+ filterByLanguage: function (language) {
+ this.selectedLanguage = _.findWhere(this.languages, { key: language });
+ this.render();
+ this.collection.trigger('filter', language);
+ },
+
serializeData: function () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
- canWrite: this.options.canWrite
+ canWrite: this.options.canWrite,
+ languages: this.languages,
+ selectedLanguage: this.selectedLanguage
});
}
});
diff --git a/server/sonar-web/src/main/js/quality-profiles/app.js b/server/sonar-web/src/main/js/quality-profiles/app.js
index d139f2b17b5..e2650a470ff 100644
--- a/server/sonar-web/src/main/js/quality-profiles/app.js
+++ b/server/sonar-web/src/main/js/quality-profiles/app.js
@@ -46,7 +46,9 @@ require([
collection: this.profiles,
canWrite: this.canWrite
});
- this.layout.actionsRegion.show(this.actionsView);
+ this.actionsView.requestLanguages().done(function () {
+ App.layout.actionsRegion.show(App.actionsView);
+ });
// Profiles View
this.profilesView = new ProfilesView({
diff --git a/server/sonar-web/src/main/js/quality-profiles/profile-view.js b/server/sonar-web/src/main/js/quality-profiles/profile-view.js
index 680cc25d613..d2d42aee324 100644
--- a/server/sonar-web/src/main/js/quality-profiles/profile-view.js
+++ b/server/sonar-web/src/main/js/quality-profiles/profile-view.js
@@ -37,6 +37,7 @@ define([
onRender: function () {
this.$el.toggleClass('active', this.options.highlighted);
this.$el.attr('data-key', this.model.id);
+ this.$el.attr('data-language', this.model.get('language'));
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body' });
},
diff --git a/server/sonar-web/src/main/js/quality-profiles/profiles-view.js b/server/sonar-web/src/main/js/quality-profiles/profiles-view.js
index fe2e1a97dd8..7909647c32c 100644
--- a/server/sonar-web/src/main/js/quality-profiles/profiles-view.js
+++ b/server/sonar-web/src/main/js/quality-profiles/profiles-view.js
@@ -29,6 +29,10 @@ define([
itemView: ProfileView,
itemViewContainer: '.js-list',
+ collectionEvents: {
+ 'filter': 'filterByLanguage'
+ },
+
itemViewOptions: function (model) {
return {
collectionView: this,
@@ -64,7 +68,16 @@ define([
closeChildren: function () {
Marionette.CompositeView.prototype.closeChildren.apply(this, arguments);
this.$('.js-list-language').remove();
- }
+ },
+
+ filterByLanguage: function (language) {
+ if (language) {
+ this.$('[data-language]').addClass('hidden');
+ this.$('[data-language="' + language + '"]').removeClass('hidden');
+ } else {
+ this.$('[data-language]').removeClass('hidden');
+ }
+ },
});
});