From 532cc838d8d97e5c91de4c7d34909bb8c3bf0799 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 11 Jun 2015 18:52:33 +0200 Subject: [PATCH] SONAR-6624 apply feedback --- .../sonar-web/src/main/js/apps/metrics/app.js | 27 ++++++++++--------- .../src/main/js/apps/metrics/create-view.js | 3 +++ .../src/main/js/apps/metrics/header-view.js | 3 ++- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/metrics/app.js b/server/sonar-web/src/main/js/apps/metrics/app.js index 4792cd7464e..4e42d95a09d 100644 --- a/server/sonar-web/src/main/js/apps/metrics/app.js +++ b/server/sonar-web/src/main/js/apps/metrics/app.js @@ -20,7 +20,8 @@ define([ this.headerView = new HeaderView({ collection: this.metrics, domains: this.domains, - types: this.types + types: this.types, + app: App }); this.layout.headerRegion.show(this.headerView); @@ -38,20 +39,22 @@ define([ // Go! this.metrics.fetch(); - }, - requestDomains = function () { - return $.get(baseUrl + '/api/metrics/domains').done(function (r) { - App.domains = r.domains; - }); - }, - requestTypes = function () { - return $.get(baseUrl + '/api/metrics/types').done(function (r) { - App.types = r.types; - }); }; + + App.requestDomains = function () { + return $.get(baseUrl + '/api/metrics/domains').done(function (r) { + App.domains = r.domains; + }); + }; + App.requestTypes = function () { + return $.get(baseUrl + '/api/metrics/types').done(function (r) { + App.types = r.types; + }); + }; + App.on('start', function (options) { - $.when(window.requestMessages(), requestDomains(), requestTypes()).done(function () { + $.when(window.requestMessages(), App.requestDomains(), App.requestTypes()).done(function () { init.call(App, options); }); }); diff --git a/server/sonar-web/src/main/js/apps/metrics/create-view.js b/server/sonar-web/src/main/js/apps/metrics/create-view.js index 5be34dac1ec..06a192eac33 100644 --- a/server/sonar-web/src/main/js/apps/metrics/create-view.js +++ b/server/sonar-web/src/main/js/apps/metrics/create-view.js @@ -22,6 +22,9 @@ define([ } }).done(function () { that.collection.refresh(); + if (that.options.domains.indexOf(metric.get('domain')) === -1) { + that.options.domains.push(metric.get('domain')); + } that.destroy(); }).fail(function (jqXHR) { that.enableForm(); diff --git a/server/sonar-web/src/main/js/apps/metrics/header-view.js b/server/sonar-web/src/main/js/apps/metrics/header-view.js index aed1d449218..78a9b0da0d0 100644 --- a/server/sonar-web/src/main/js/apps/metrics/header-view.js +++ b/server/sonar-web/src/main/js/apps/metrics/header-view.js @@ -19,7 +19,8 @@ define([ new CreateView({ collection: this.collection, domains: this.options.domains, - types: this.options.types + types: this.options.types, + app: this.options.app }).render(); } }); -- 2.39.5