<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>
'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;
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;
});
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'
+ }
}
});