From f22b8c87b9a9efde595691c6e5879c4c5b1dc3a6 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Wed, 21 Jan 2015 11:07:57 +0100 Subject: fix SONAR-5820/SONAR-6019 fix characteristic facet --- server/sonar-web/src/main/js/coding-rules/app.js | 10 +++++++-- .../js/coding-rules/facets/characteristic-facet.js | 25 ++++++---------------- .../src/main/js/coding-rules/rule-details-view.js | 1 - .../sonar-web/src/main/js/coding-rules/show-app.js | 10 +++++++-- 4 files changed, 23 insertions(+), 23 deletions(-) (limited to 'server/sonar-web/src/main/js/coding-rules') diff --git a/server/sonar-web/src/main/js/coding-rules/app.js b/server/sonar-web/src/main/js/coding-rules/app.js index cbf845d6410..b467dbaadb7 100644 --- a/server/sonar-web/src/main/js/coding-rules/app.js +++ b/server/sonar-web/src/main/js/coding-rules/app.js @@ -93,8 +93,14 @@ requirejs([ }; }; - App.getSubCharacteristicName = function (name) { - return (App.characteristics[name] || '').replace(': ', ' > '); + App.getSubCharacteristicName = function (key) { + if (key != null) { + var ch = _.findWhere(App.characteristics, { key: key }), + parent = _.findWhere(App.characteristics, { key: ch.parent }); + return [parent.name, ch.name].join(' > '); + } else { + return null; + } }; var appXHR = $.get(baseUrl + '/api/rules/app').done(function(r) { diff --git a/server/sonar-web/src/main/js/coding-rules/facets/characteristic-facet.js b/server/sonar-web/src/main/js/coding-rules/facets/characteristic-facet.js index 256db1fa3d8..359131f5f04 100644 --- a/server/sonar-web/src/main/js/coding-rules/facets/characteristic-facet.js +++ b/server/sonar-web/src/main/js/coding-rules/facets/characteristic-facet.js @@ -1,20 +1,20 @@ define([ - 'coding-rules/facets/base-facet' + 'coding-rules/facets/base-facet' ], function (BaseFacet) { - var $ = jQuery; - return BaseFacet.extend({ getValues: function () { var values = this.model.getValues(), characteristics = this.options.app.characteristics; return values.map(function (value) { - var label = characteristics[value.val]; - if (value.val === 'NONE') { - label = t('coding_rules.noncharacterized'); + var ch = _.findWhere(characteristics, { key: value.val }); + if (ch != null) { + _.extend(value, ch, { label: ch.name }); + } else { + _.extend(value, { label: t('coding_rules.noncharacterized') }); } - return _.extend(value, { label: label }); + return value; }); }, @@ -24,17 +24,6 @@ define([ }); }, - toggleFacet: function (e) { - var obj = {}, - property = this.model.get('property'); - if ($(e.currentTarget).is('.active')) { - obj[property] = null; - } else { - obj[property] = $(e.currentTarget).data('value'); - } - this.options.app.state.updateFilter(obj); - }, - serializeData: function () { return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), { values: this.sortValues(this.getValues()) diff --git a/server/sonar-web/src/main/js/coding-rules/rule-details-view.js b/server/sonar-web/src/main/js/coding-rules/rule-details-view.js index 95475fe7b5a..c6c6d75cb64 100644 --- a/server/sonar-web/src/main/js/coding-rules/rule-details-view.js +++ b/server/sonar-web/src/main/js/coding-rules/rule-details-view.js @@ -171,7 +171,6 @@ define([ isEditable: isEditable, canWrite: this.options.app.canWrite, qualityProfilesVisible: qualityProfilesVisible, - subCharacteristic: this.options.app.getSubCharacteristicName(this.model.get('debtSubChar')), allTags: _.union(this.model.get('sysTags'), this.model.get('tags')) }); } diff --git a/server/sonar-web/src/main/js/coding-rules/show-app.js b/server/sonar-web/src/main/js/coding-rules/show-app.js index 3e815a93f26..1505c23ec51 100644 --- a/server/sonar-web/src/main/js/coding-rules/show-app.js +++ b/server/sonar-web/src/main/js/coding-rules/show-app.js @@ -42,8 +42,14 @@ requirejs([ }; }; - App.getSubCharacteristicName = function (name) { - return (App.characteristics[name] || '').replace(': ', ' > '); + App.getSubCharacteristicName = function (key) { + if (key != null) { + var ch = _.findWhere(App.characteristics, { key: key }), + parent = _.findWhere(App.characteristics, { key: ch.parent }); + return [parent.name, ch.name].join(' > '); + } else { + return null; + } }; var appXHR = $.get(baseUrl + '/api/rules/app').done(function(r) { -- cgit v1.2.3