'navigator/filters/base-filters',
'navigator/filters/choice-filters',
'navigator/filters/string-filters',
+ 'navigator/filters/date-filter-view',
'coding-rules/views/filters/quality-profile-filter-view',
'coding-rules/views/filters/inheritance-filter-view',
BaseFilters,
ChoiceFilters,
StringFilterView,
+ DateFilterView,
QualityProfileFilterView,
InheritanceFilterView
) ->
name: t 'coding_rules.filters.name'
property: 'name'
type: StringFilterView
- enabled: true
- optional: false
-
- @filters.add new BaseFilters.Filter
- name: t 'coding_rules.filters.key'
- property: 'key'
- type: StringFilterView
- enabled: true
- optional: false
-
- @filters.add new BaseFilters.Filter
- name: t 'coding_rules.filters.description'
- property: 'description'
- type: StringFilterView
- enabled: true
- optional: false
@filters.add new BaseFilters.Filter
name: t 'coding_rules.filters.language'
property: 'languages'
type: ChoiceFilters.ChoiceFilterView
- enabled: true
- optional: false
choices: @languages
- @filters.add new BaseFilters.Filter
- name: t 'coding_rules.filters.repository'
- property: 'repositories'
- type: ChoiceFilters.ChoiceFilterView
- enabled: true
- optional: false
- choices: @repositories
-
@filters.add new BaseFilters.Filter
name: t 'coding_rules.filters.severity'
property: 'severities'
type: ChoiceFilters.ChoiceFilterView
- enabled: true
- optional: false
choices:
'BLOCKER': t 'severity.BLOCKER'
'CRITICAL': t 'severity.CRITICAL'
'MINOR': 'severity-minor'
'INFO': 'severity-info'
- @filters.add new BaseFilters.Filter
- name: t 'coding_rules.filters.status'
- property: 'statuses'
- type: ChoiceFilters.ChoiceFilterView
- enabled: true
- optional: false
- choices: @statuses
-
@filters.add new BaseFilters.Filter
name: t 'coding_rules.filters.tag'
property: 'tags'
type: ChoiceFilters.ChoiceFilterView
- enabled: true
- optional: false
choices: @tags
@activeInFilter = new BaseFilters.Filter
property: 'in_quality_profile'
type: QualityProfileFilterView
multiple: false
- enabled: true
- optional: false
@filters.add @activeInFilter
+
+ @filters.add new BaseFilters.Filter
+ name: t 'coding_rules.filters.key'
+ property: 'key'
+ type: StringFilterView
+ enabled: false
+ optional: true
+
+ @filters.add new BaseFilters.Filter
+ name: t 'coding_rules.filters.description'
+ property: 'description'
+ type: StringFilterView
+ enabled: false
+ optional: true
+
+ @filters.add new BaseFilters.Filter
+ name: t 'coding_rules.filters.repository'
+ property: 'repositories'
+ type: ChoiceFilters.ChoiceFilterView
+ enabled: false
+ optional: true
+ choices: @repositories
+
+ @filters.add new BaseFilters.Filter
+ name: t 'coding_rules.filters.status'
+ property: 'statuses'
+ type: ChoiceFilters.ChoiceFilterView
+ enabled: false
+ optional: true
+ choices: @statuses
+
+ @filters.add new BaseFilters.Filter
+ name: t 'coding_rules.filters.availableSince'
+ property: 'availableSince'
+ type: DateFilterView
+ enabled: false
+ optional: true
+
@inactiveInFilter = new BaseFilters.Filter
name: t 'coding_rules.filters.out_of_quality_profile'
property: 'out_of_quality_profile'
type: QualityProfileFilterView
multiple: false
- enabled: true
- optional: false
+ enabled: false
+ optional: true
@filters.add @inactiveInFilter
@filters.add new BaseFilters.Filter
name: t 'coding_rules.filters.inheritance'
property: 'inheritance'
type: InheritanceFilterView
- enabled: true
- optional: false
+ enabled: false
+ optional: true
+ multiple: false
qualityProfileFilter: @activeInFilter
choices:
- 'option1': 'Option 1'
- 'option2': 'Option 2'
+ 'any': t 'coding_rules.filters.inheritance.any'
+ 'not_inhertited': t 'coding_rules.filters.inheritance.not_inherited'
+ 'inhertited': t 'coding_rules.filters.inheritance.inherited'
+ 'overriden': t 'coding_rules.filters.inheritance.overriden'
@filterBarView = new CodingRulesFilterBarView
app: @
}
});
- requirejs(['backbone', 'backbone.marionette', 'coding-rules/layout', 'coding-rules/router', 'coding-rules/views/header-view', 'coding-rules/views/actions-view', 'coding-rules/views/filter-bar-view', 'coding-rules/views/coding-rules-list-view', 'navigator/filters/base-filters', 'navigator/filters/choice-filters', 'navigator/filters/string-filters', 'coding-rules/views/filters/quality-profile-filter-view', 'coding-rules/views/filters/inheritance-filter-view', 'coding-rules/mockjax'], function(Backbone, Marionette, CodingRulesLayout, CodingRulesRouter, CodingRulesHeaderView, CodingRulesActionsView, CodingRulesFilterBarView, CodingRulesListView, BaseFilters, ChoiceFilters, StringFilterView, QualityProfileFilterView, InheritanceFilterView) {
+ requirejs(['backbone', 'backbone.marionette', 'coding-rules/layout', 'coding-rules/router', 'coding-rules/views/header-view', 'coding-rules/views/actions-view', 'coding-rules/views/filter-bar-view', 'coding-rules/views/coding-rules-list-view', 'navigator/filters/base-filters', 'navigator/filters/choice-filters', 'navigator/filters/string-filters', 'navigator/filters/date-filter-view', 'coding-rules/views/filters/quality-profile-filter-view', 'coding-rules/views/filters/inheritance-filter-view', 'coding-rules/mockjax'], function(Backbone, Marionette, CodingRulesLayout, CodingRulesRouter, CodingRulesHeaderView, CodingRulesActionsView, CodingRulesFilterBarView, CodingRulesListView, BaseFilters, ChoiceFilters, StringFilterView, DateFilterView, QualityProfileFilterView, InheritanceFilterView) {
var App, appXHR;
jQuery.ajaxSetup({
error: function(jqXHR) {
this.filters.add(new BaseFilters.Filter({
name: t('coding_rules.filters.name'),
property: 'name',
- type: StringFilterView,
- enabled: true,
- optional: false
- }));
- this.filters.add(new BaseFilters.Filter({
- name: t('coding_rules.filters.key'),
- property: 'key',
- type: StringFilterView,
- enabled: true,
- optional: false
- }));
- this.filters.add(new BaseFilters.Filter({
- name: t('coding_rules.filters.description'),
- property: 'description',
- type: StringFilterView,
- enabled: true,
- optional: false
+ type: StringFilterView
}));
this.filters.add(new BaseFilters.Filter({
name: t('coding_rules.filters.language'),
property: 'languages',
type: ChoiceFilters.ChoiceFilterView,
- enabled: true,
- optional: false,
choices: this.languages
}));
- this.filters.add(new BaseFilters.Filter({
- name: t('coding_rules.filters.repository'),
- property: 'repositories',
- type: ChoiceFilters.ChoiceFilterView,
- enabled: true,
- optional: false,
- choices: this.repositories
- }));
this.filters.add(new BaseFilters.Filter({
name: t('coding_rules.filters.severity'),
property: 'severities',
type: ChoiceFilters.ChoiceFilterView,
- enabled: true,
- optional: false,
choices: {
'BLOCKER': t('severity.BLOCKER'),
'CRITICAL': t('severity.CRITICAL'),
'INFO': 'severity-info'
}
}));
- this.filters.add(new BaseFilters.Filter({
- name: t('coding_rules.filters.status'),
- property: 'statuses',
- type: ChoiceFilters.ChoiceFilterView,
- enabled: true,
- optional: false,
- choices: this.statuses
- }));
this.filters.add(new BaseFilters.Filter({
name: t('coding_rules.filters.tag'),
property: 'tags',
type: ChoiceFilters.ChoiceFilterView,
- enabled: true,
- optional: false,
choices: this.tags
}));
this.activeInFilter = new BaseFilters.Filter({
name: t('coding_rules.filters.in_quality_profile'),
property: 'in_quality_profile',
type: QualityProfileFilterView,
- multiple: false,
- enabled: true,
- optional: false
+ multiple: false
});
this.filters.add(this.activeInFilter);
+ this.filters.add(new BaseFilters.Filter({
+ name: t('coding_rules.filters.key'),
+ property: 'key',
+ type: StringFilterView,
+ enabled: false,
+ optional: true
+ }));
+ this.filters.add(new BaseFilters.Filter({
+ name: t('coding_rules.filters.description'),
+ property: 'description',
+ type: StringFilterView,
+ enabled: false,
+ optional: true
+ }));
+ this.filters.add(new BaseFilters.Filter({
+ name: t('coding_rules.filters.repository'),
+ property: 'repositories',
+ type: ChoiceFilters.ChoiceFilterView,
+ enabled: false,
+ optional: true,
+ choices: this.repositories
+ }));
+ this.filters.add(new BaseFilters.Filter({
+ name: t('coding_rules.filters.status'),
+ property: 'statuses',
+ type: ChoiceFilters.ChoiceFilterView,
+ enabled: false,
+ optional: true,
+ choices: this.statuses
+ }));
+ this.filters.add(new BaseFilters.Filter({
+ name: t('coding_rules.filters.availableSince'),
+ property: 'availableSince',
+ type: DateFilterView,
+ enabled: false,
+ optional: true
+ }));
this.inactiveInFilter = new BaseFilters.Filter({
name: t('coding_rules.filters.out_of_quality_profile'),
property: 'out_of_quality_profile',
type: QualityProfileFilterView,
multiple: false,
- enabled: true,
- optional: false
+ enabled: false,
+ optional: true
});
this.filters.add(this.inactiveInFilter);
this.filters.add(new BaseFilters.Filter({
name: t('coding_rules.filters.inheritance'),
property: 'inheritance',
type: InheritanceFilterView,
- enabled: true,
- optional: false,
+ enabled: false,
+ optional: true,
+ multiple: false,
qualityProfileFilter: this.activeInFilter,
choices: {
- 'option1': 'Option 1',
- 'option2': 'Option 2'
+ 'any': t('coding_rules.filters.inheritance.any'),
+ 'not_inhertited': t('coding_rules.filters.inheritance.not_inherited'),
+ 'inhertited': t('coding_rules.filters.inheritance.inherited'),
+ 'overriden': t('coding_rules.filters.inheritance.overriden')
}
}));
this.filterBarView = new CodingRulesFilterBarView({
'coding_rules.activate_quality_profile': 'Activate Quality Profile'
'coding_rules.deactivate_quality_profile': 'Deactivate'
+ 'coding_rules.filters.availableSince': 'Available Since'
'coding_rules.filters.description': 'Description'
'coding_rules.filters.in_quality_profile': 'In Quality Profile'
'coding_rules.filters.inheritance': 'Inheritance'
- 'coding_rules.filters.inheritance.inactive': 'Inheritance criteria is available when a quality profile is selected'
+ 'coding_rules.filters.inheritance.inactive': 'Inheritance criteria is available when an inherited quality profile is selected'
+ 'coding_rules.filters.inheritance.any': 'Any'
+ 'coding_rules.filters.inheritance.not_inherited': 'Not Inherited'
+ 'coding_rules.filters.inheritance.inherited': 'Inherited'
+ 'coding_rules.filters.inheritance.overriden': 'Overriden'
'coding_rules.filters.key': 'Key'
'coding_rules.filters.language': 'Language'
'coding_rules.filters.name': 'Name'
responseText: JSON.stringify
more: false
results: [
- { id: 'sonarway', text: 'Sonar Way' },
- { id: 'qp1', text: 'Quality Profile 1' },
- { id: 'qp2', text: 'Quality Profile 2' },
- { id: 'qp3', text: 'Quality Profile 3' },
+ { id: 'sonarway', text: 'Sonar Way', parent: null },
+ { id: 'qp1', text: 'Quality Profile 1', parent: 'sonarway' },
+ { id: 'qp2', text: 'Quality Profile 2', parent: 'sonarway' },
+ { id: 'qp3', text: 'Quality Profile 3', parent: null },
]
'coding_rules.quality_profiles': 'Quality Profiles',
'coding_rules.activate_quality_profile': 'Activate Quality Profile',
'coding_rules.deactivate_quality_profile': 'Deactivate',
+ 'coding_rules.filters.availableSince': 'Available Since',
'coding_rules.filters.description': 'Description',
'coding_rules.filters.in_quality_profile': 'In Quality Profile',
'coding_rules.filters.inheritance': 'Inheritance',
- 'coding_rules.filters.inheritance.inactive': 'Inheritance criteria is available when a quality profile is selected',
+ 'coding_rules.filters.inheritance.inactive': 'Inheritance criteria is available when an inherited quality profile is selected',
+ 'coding_rules.filters.inheritance.any': 'Any',
+ 'coding_rules.filters.inheritance.not_inherited': 'Not Inherited',
+ 'coding_rules.filters.inheritance.inherited': 'Inherited',
+ 'coding_rules.filters.inheritance.overriden': 'Overriden',
'coding_rules.filters.key': 'Key',
'coding_rules.filters.language': 'Language',
'coding_rules.filters.name': 'Name',
results: [
{
id: 'sonarway',
- text: 'Sonar Way'
+ text: 'Sonar Way',
+ parent: null
}, {
id: 'qp1',
- text: 'Quality Profile 1'
+ text: 'Quality Profile 1',
+ parent: 'sonarway'
}, {
id: 'qp2',
- text: 'Quality Profile 2'
+ text: 'Quality Profile 2',
+ parent: 'sonarway'
}, {
id: 'qp3',
- text: 'Quality Profile 3'
+ text: 'Quality Profile 3',
+ parent: null
}
]
})
onChangeQualityProfile: ->
qualityProfile = @qualityProfileFilter.get 'value'
- if _.isArray(qualityProfile) && qualityProfile.length == 1
+ parentQualityProfile = @qualityProfileFilter.get 'parentQualityProfile'
+ if _.isArray(qualityProfile) && qualityProfile.length == 1 && parentQualityProfile
@makeActive()
else
@makeInactive()
--- /dev/null
+// Generated by CoffeeScript 1.6.3
+(function() {
+ var __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ define(['navigator/filters/choice-filters'], function(ChoiceFilters) {
+ var InheritanceFilterView, _ref;
+ return InheritanceFilterView = (function(_super) {
+ __extends(InheritanceFilterView, _super);
+
+ function InheritanceFilterView() {
+ _ref = InheritanceFilterView.__super__.constructor.apply(this, arguments);
+ return _ref;
+ }
+
+ InheritanceFilterView.prototype.initialize = function() {
+ InheritanceFilterView.__super__.initialize.apply(this, arguments);
+ this.qualityProfileFilter = this.model.get('qualityProfileFilter');
+ this.listenTo(this.qualityProfileFilter, 'change:value', this.onChangeQualityProfile);
+ return this.onChangeQualityProfile();
+ };
+
+ InheritanceFilterView.prototype.onChangeQualityProfile = function() {
+ var parentQualityProfile, qualityProfile;
+ qualityProfile = this.qualityProfileFilter.get('value');
+ parentQualityProfile = this.qualityProfileFilter.get('parentQualityProfile');
+ if (_.isArray(qualityProfile) && qualityProfile.length === 1 && parentQualityProfile) {
+ return this.makeActive();
+ } else {
+ return this.makeInactive();
+ }
+ };
+
+ InheritanceFilterView.prototype.makeActive = function() {
+ this.model.set({
+ inactive: false,
+ title: ''
+ });
+ this.model.trigger('change:enabled');
+ return this.$el.removeClass('navigator-filter-inactive').prop('title', '');
+ };
+
+ InheritanceFilterView.prototype.makeInactive = function() {
+ this.model.set({
+ inactive: true,
+ title: t('coding_rules.filters.inheritance.inactive')
+ });
+ this.model.trigger('change:enabled');
+ this.choices.each(function(model) {
+ return model.set('checked', false);
+ });
+ this.detailsView.updateLists();
+ this.detailsView.updateValue();
+ return this.$el.addClass('navigator-filter-inactive').prop('title', t('coding_rules.filters.inheritance.inactive'));
+ };
+
+ InheritanceFilterView.prototype.showDetails = function() {
+ if (!this.$el.is('.navigator-filter-inactive')) {
+ return InheritanceFilterView.__super__.showDetails.apply(this, arguments);
+ }
+ };
+
+ InheritanceFilterView.prototype.restore = function(value) {
+ if (_.isString(value)) {
+ value = value.split(',');
+ }
+ if (this.choices && value.length > 0) {
+ this.model.set({
+ value: value,
+ enabled: true
+ });
+ return this.onChangeQualityProfile;
+ } else {
+ return this.clear();
+ }
+ };
+
+ return InheritanceFilterView;
+
+ })(ChoiceFilters.ChoiceFilterView);
+ });
+
+}).call(this);
initialize: ->
super
@choices = new QualityProfileSuggestions
+ @listenTo @model, 'change:value', @updateParentQualityProfile
+
+
+ updateParentQualityProfile: ->
+ selected = @getSelected()
+ if selected.length == 1
+ @model.set 'parentQualityProfile', selected[0].get('parent')
+ else
+ @model.unset 'parentQualityProfile'
QualityProfileFilterView.prototype.initialize = function() {
QualityProfileFilterView.__super__.initialize.apply(this, arguments);
- return this.choices = new QualityProfileSuggestions;
+ this.choices = new QualityProfileSuggestions;
+ return this.listenTo(this.model, 'change:value', this.updateParentQualityProfile);
+ };
+
+ QualityProfileFilterView.prototype.updateParentQualityProfile = function() {
+ var selected;
+ selected = this.getSelected();
+ if (selected.length === 1) {
+ return this.model.set('parentQualityProfile', selected[0].get('parent'));
+ } else {
+ return this.model.unset('parentQualityProfile');
+ }
};
return QualityProfileFilterView;
var Filter = Backbone.Model.extend({
defaults: {
+ enabled: true,
+ optional: false,
multiple: true,
placeholder: ''
}
--- /dev/null
+define [
+ 'navigator/filters/string-filters'
+], (
+ StringFilterView
+) ->
+
+ class DateFilterView extends StringFilterView
+
+ render: ->
+ super
+ @detailsView.$('input').prop 'placeholder', '1970-01-31'
--- /dev/null
+// Generated by CoffeeScript 1.6.3
+(function() {
+ var __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ define(['navigator/filters/string-filters'], function(StringFilterView) {
+ var DateFilterView, _ref;
+ return DateFilterView = (function(_super) {
+ __extends(DateFilterView, _super);
+
+ function DateFilterView() {
+ _ref = DateFilterView.__super__.constructor.apply(this, arguments);
+ return _ref;
+ }
+
+ DateFilterView.prototype.render = function() {
+ DateFilterView.__super__.render.apply(this, arguments);
+ return this.detailsView.$('input').prop('placeholder', '1970-01-31');
+ };
+
+ return DateFilterView;
+
+ })(StringFilterView);
+ });
+
+}).call(this);