diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-03-03 17:57:32 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-03-03 17:57:32 +0100 |
commit | b88fd7049dd271e115bbc1f48b49e5d830ee6ef9 (patch) | |
tree | bd11cef40b27df101bc5b93d75f694000c8544fc | |
parent | 1fd202c62b8f7a45b022720fd6a9968dfff5eda9 (diff) | |
download | sonarqube-b88fd7049dd271e115bbc1f48b49e5d830ee6ef9.tar.gz sonarqube-b88fd7049dd271e115bbc1f48b49e5d830ee6ef9.zip |
SONAR-6233 fix characteristic facet on rules page
3 files changed, 51 insertions, 8 deletions
diff --git a/server/sonar-web/src/main/hbs/coding-rules/facets/coding-rules-characteristic-facet.hbs b/server/sonar-web/src/main/hbs/coding-rules/facets/coding-rules-characteristic-facet.hbs index 1742660c33a..645205b0c5c 100644 --- a/server/sonar-web/src/main/hbs/coding-rules/facets/coding-rules-characteristic-facet.hbs +++ b/server/sonar-web/src/main/hbs/coding-rules/facets/coding-rules-characteristic-facet.hbs @@ -2,10 +2,18 @@ <div class="search-navigator-facet-list"> {{#each values}} - <a class="facet search-navigator-facet {{#if parent}}search-navigator-facet-indent{{/if}} js-facet" - data-value="{{val}}" title="{{default label val}}"> - <span class="facet-name">{{default label val}}</span> - <span class="facet-stat">{{numberShort count}}</span> - </a> + {{#eq val 'NONE'}} + <a class="facet search-navigator-facet js-facet" data-empty-characteristic + title="{{t 'coding_rules.noncharacterized'}}"> + <span class="facet-name">{{t 'coding_rules.noncharacterized'}}</span> + <span class="facet-stat">{{numberShort count}}</span> + </a> + {{else}} + <a class="facet search-navigator-facet {{#if parent}}search-navigator-facet-indent{{/if}} js-facet" + data-value="{{val}}" title="{{default label val}}"> + <span class="facet-name">{{default label val}}</span> + <span class="facet-stat">{{numberShort count}}</span> + </a> + {{/eq}} {{/each}} </div> 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 94a954abc7a..5275d260317 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 @@ -22,9 +22,44 @@ define([ 'templates/coding-rules' ], function (BaseFacet) { + var $ = jQuery; + return BaseFacet.extend({ template: Templates['coding-rules-characteristic-facet'], + onRender: function () { + BaseFacet.prototype.onRender.apply(this, arguments); + var value = this.options.app.state.get('query').has_debt_characteristic; + if (value != null && ('' + value === 'false')) { + this.$('.js-facet').filter('[data-empty-characteristic]').addClass('active'); + } + }, + + toggleFacet: function (e) { + var noneCharacteristic = $(e.currentTarget).is('[data-empty-characteristic]'), + property = this.model.get('property'), + obj = {}; + $(e.currentTarget).toggleClass('active'); + if (noneCharacteristic) { + var checked = $(e.currentTarget).is('.active'); + obj.has_debt_characteristic = checked ? 'false' : null; + obj[property] = null; + } else { + obj.has_debt_characteristic = null; + obj[property] = this.getValue(); + } + console.log(obj); + this.options.app.state.updateFilter(obj); + }, + + disable: function () { + var property = this.model.get('property'), + obj = {}; + obj.has_debt_characteristic = null; + obj[property] = null; + this.options.app.state.updateFilter(obj); + }, + getValues: function () { var values = this.model.getValues(), characteristics = this.options.app.characteristics; @@ -32,8 +67,6 @@ define([ 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 value; }); diff --git a/server/sonar-web/src/main/js/coding-rules/models/state.js b/server/sonar-web/src/main/js/coding-rules/models/state.js index 050a7ff58b3..97720d9d5de 100644 --- a/server/sonar-web/src/main/js/coding-rules/models/state.js +++ b/server/sonar-web/src/main/js/coding-rules/models/state.js @@ -30,7 +30,9 @@ define([ allFacets: ['q', 'rule_key', 'languages', 'tags', 'repositories', 'debt_characteristics', 'severities', 'statuses', 'available_since', 'is_template', 'qprofile', 'inheritance', 'active_severities'], facetsFromServer: ['languages', 'repositories', 'tags', 'severities', 'statuses', 'debt_characteristics'], - transform: {} + transform: { + 'has_debt_characteristic': 'debt_characteristics' + } } }); |