diff options
Diffstat (limited to 'server/sonar-web/src/main/js')
-rw-r--r-- | server/sonar-web/src/main/js/coding-rules/facets/characteristic-facet.js | 37 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/coding-rules/models/state.js | 4 |
2 files changed, 38 insertions, 3 deletions
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' + } } }); |