<%= javascript_include_tag 'navigator/filters/select-filters' %>
<%= javascript_include_tag 'navigator/filters/ajax-select-filters' %>
<%= javascript_include_tag 'navigator/filters/range-filters' %>
+ <%= javascript_include_tag 'navigator/filters/checkbox-filters' %>
+ <%= javascript_include_tag 'navigator/filters/string-filters' %>
<%= javascript_include_tag 'navigator/filters/favorite-filters' %>
<%= javascript_include_tag 'navigator/filters/more-criteria-filters' %>
<%= javascript_include_tag 'navigator/filters/more-criteria-filters' %>
--- /dev/null
+<% if logged_in? %>
+ {
+ <% current_user.favourited_measure_filters.each do |filter| %>
+ '<%= h filter.id -%>': '<%= h filter.name -%>',
+ <% end %>
+ }
+<% else %>
+ null
+<% end %>
--- /dev/null
+{
+<% Api::Utils.languages.each do |lang| %>
+ '<%= h lang.key -%>': '<%= h lang.name -%>',
+<% end %>
+}
+
+
+
};
+ _.extend(window.SS, {
+ languages: <%= render :partial => 'measures/languages' -%>,
+ favorites: <%= render :partial => 'measures/favourites2' -%>
+ });
+
+
var queryParams = [
{ key: 'qualifiers[]', value: <%= @filter.criteria['qualifiers'].to_json -%> },
+ { key: 'alertLevels[]', value: <%= @filter.criteria['alertLevels'].to_json -%> },
+ { key: 'fromDate', value: '<%= h @filter.criteria['fromDate'] -%>' },
+ { key: 'toDate', value: '<%= h @filter.criteria['toDate'] -%>' },
+ { key: 'ageMinDays', value: '<%= h @filter.criteria('ageMinDays') -%>' },
+ { key: 'ageMaxDays', value: '<%= h @filter.criteria['ageMaxDays'] -%>' },
+ <% if @filter.base_resource %>
+ { key: 'base', value: ['<%= h @filter.base_resource.key -%>'], text: ['<%= h @filter.base_resource.name(true) -%>'] },
+ <% end %>
+ { key: 'onFavourites', value: <%= @filter.criteria['onFavourites']=='true' -%> },
+ { key: 'keySearch', value: '<%= h @filter.criteria['keySearch'] -%>' },
+ { key: 'languages[]', value: <%= @filter.criteria['languages'].to_json -%> }
];
window.SS.MeasuresNavigatorApp.start();
</div>
</script>
+<script id="checkboxFilterTemplate" type="text/template">
+ <div class="navigator-filter-label">{{ name }}</div>
+ <div class="navigator-filter-value">
+ <input type="checkbox" name="{{ property }}" value="true" {[ if (value) { ]}checked{[ } ]}>
+ </div>
+ {[ if (optional) { ]}
+ <div class="navigator-filter-disable">×</div>
+ {[ } ]}
+</script>
+
+<script id="stringFilterTemplate" type="text/template">
+ <div class="navigator-filter-details-inner">
+ <input type="text" name="{{ property }}" value="{{ value }}">
+ </div>
+</script>
+
<script id="favoriteFilterTemplate" type="text/template">
<div class="navigator-filter-favorite-toggle"></div>
</script>
(function() {
- var Filter = Backbone.Model.extend({});
+ var Filter = Backbone.Model.extend({
+
+ defaults: {
+ multiple: true
+ }
+
+ });
--- /dev/null
+/* global _:false */
+
+window.SS = typeof window.SS === 'object' ? window.SS : {};
+
+(function() {
+
+ var CheckboxFilterView = window.SS.BaseFilterView.extend({
+ template: '#checkboxFilterTemplate',
+ className: 'navigator-filter navigator-filter-inline',
+
+
+ events: function() {
+ return {
+ 'click .navigator-filter-disable': 'disable'
+ };
+ },
+
+
+ renderInput: function() {},
+
+
+ renderValue: function() {
+ return (this.model.get('value') || false) ? 'Yes' : 'No';
+ },
+
+
+ isDefaultValue: function() {
+ return false;
+ },
+
+
+ restore: function(value) {
+ this.model.set({
+ value: value,
+ enabled: true
+ });
+ }
+
+ });
+
+
+
+ /*
+ * Export public classes
+ */
+
+ _.extend(window.SS, {
+ CheckboxFilterView: CheckboxFilterView
+ });
+
+})();
applyFavorite: function(e) {
var id = $j(e.target).data('id');
- window.location = baseUrl + '/issues/filter/' + id;
+ window.location = baseUrl + this.model.get('favoriteUrl') + '/' + id;
},
manage: function() {
- window.location = baseUrl + '/issues/manage';
+ window.location = baseUrl + this.model.get('manageUrl');
}
});
paramTo = _.findWhere(q, { key: this.model.get('propertyTo') }),
value = {};
- if (paramFrom.value || paramTo.value) {
- if (paramFrom.value) {
+ if ((paramFrom && paramFrom.value) || (paramTo && paramTo.value)) {
+ if (paramFrom && paramFrom.value) {
value[this.model.get('propertyFrom')] = paramFrom.value;
}
- if (paramTo.value) {
+ if (paramTo && paramTo.value) {
value[this.model.get('propertyTo')] = paramTo.value;
}
var id = $j(e.target).val(),
model = this.options.filterView.choices.findWhere({ id: id });
- this.options.filterView.selection.add(model);
- this.options.filterView.choices.remove(model);
+ if (this.model.get('multiple')) {
+ this.options.filterView.selection.add(model);
+ this.options.filterView.choices.remove(model);
+ } else {
+ this.options.filterView.choices.add(this.options.filterView.selection.models);
+ this.options.filterView.selection.reset([model]);
+ }
this.updateValue();
this.updateLists();
renderValue: function() {
var value = this.selection.map(function(item) {
return item.get('text');
- });
+ }),
+ defaultValue = this.model.get('multiple') ? 'All' : 'Any';
- return this.isDefaultValue() ? 'All' : value.join(', ');
+ return this.isDefaultValue() ? defaultValue : value.join(', ');
},
--- /dev/null
+/* global _:false, $j:false */
+
+window.SS = typeof window.SS === 'object' ? window.SS : {};
+
+(function() {
+
+ var DetailsStringFilterView = window.SS.DetailsFilterView.extend({
+ template: '#stringFilterTemplate',
+
+
+ events: {
+ 'change input': 'change'
+ },
+
+
+ change: function(e) {
+ this.model.set('value', $j(e.target).val());
+ },
+
+
+ onShow: function() {
+ window.SS.DetailsFilterView.prototype.onShow.apply(this, arguments);
+ this.$(':input').focus();
+ },
+
+
+ serializeData: function() {
+ return _.extend({}, this.model.toJSON(), {
+ value: this.model.get('value') || ''
+ });
+ }
+
+ });
+
+
+
+ var StringFilterView = window.SS.BaseFilterView.extend({
+
+ initialize: function() {
+ window.SS.BaseFilterView.prototype.initialize.call(this, {
+ detailsView: DetailsStringFilterView
+ });
+ },
+
+
+ renderValue: function() {
+ return this.isDefaultValue() ? '—' : this.model.get('value');
+ },
+
+
+ renderInput: function() {
+ $j('<input>')
+ .prop('name', this.model.get('property'))
+ .prop('type', 'hidden')
+ .css('display', 'none')
+ .val(this.model.get('value') || '')
+ .appendTo(this.$el);
+ },
+
+
+ isDefaultValue: function() {
+ return !this.model.get('value');
+ },
+
+
+ restore: function(value) {
+ this.model.set({
+ value: value,
+ enabled: true
+ });
+ }
+
+ });
+
+
+
+ /*
+ * Export public classes
+ */
+
+ _.extend(window.SS, {
+ StringFilterView: StringFilterView
+ });
+
+})();
type: window.SS.FavoriteFilterView,
enabled: true,
optional: false,
- choices: window.SS.favorites
+ choices: window.SS.favorites,
+ favoriteUrl: '/issues/filter',
+ manageUrl: '/issues/manage'
})]);
}
type: window.SS.FavoriteFilterView,
enabled: true,
optional: false,
- choices: window.SS.favorites
+ choices: window.SS.favorites,
+ favoriteUrl: '/measures/filter',
+ manageUrl: '/measures/manage'
})]);
}
'FIL': 'Files',
'UTS': 'Unit Test Files'
}
+ }),
+
+ new window.SS.Filter({
+ name: 'Age',
+ propertyFrom: 'ageMinDays',
+ propertyTo: 'ageMaxDays',
+ type: window.SS.RangeFilterView,
+ enabled: false,
+ optional: true
+ }),
+
+ new window.SS.Filter({
+ name: 'Alert',
+ property: 'alertLevels[]',
+ type: window.SS.SelectFilterView,
+ enabled: false,
+ optional: true,
+ choices: {
+ 'error': 'Error',
+ 'warn': 'Warning',
+ 'ok': 'Ok'
+ }
+ }),
+
+ new window.SS.Filter({
+ name: 'Components of',
+ property: 'base',
+ type: window.SS.ProjectFilterView,
+ multiple: false,
+ enabled: false,
+ optional: true
+ }),
+
+ new window.SS.Filter({
+ name: 'Favorites only',
+ property: 'onFavourites',
+ type: window.SS.CheckboxFilterView,
+ enabled: false,
+ optional: true
+ }),
+
+ new window.SS.Filter({
+ name: 'Date',
+ propertyFrom: 'fromDate',
+ propertyTo: 'toDate',
+ type: window.SS.DateRangeFilterView,
+ enabled: false,
+ optional: true
+ }),
+
+ new window.SS.Filter({
+ name: 'Key contains',
+ property: 'keySearch',
+ type: window.SS.StringFilterView,
+ enabled: false,
+ optional: true
+ }),
+
+ new window.SS.Filter({
+ name: 'Language',
+ property: 'languages[]',
+ type: window.SS.SelectFilterView,
+ enabled: false,
+ optional: true,
+ choices: window.SS.languages
+ }),
+
+ new window.SS.Filter({
+ name: 'Name contains',
+ property: 'nameSearch',
+ type: window.SS.StringFilterView,
+ enabled: false,
+ optional: true
})
]);
.navigator-filter-optional {
padding-right: 0;
}
+.navigator-filter-inline {
+ cursor: default;
+}
+.navigator-filter-inline:hover,
+.navigator-filter-inline.active {
+ border-color: transparent;
+ background: transparent;
+}
.navigator-filter-label {
display: inline-block;
vertical-align: middle;
padding-right: 0;
}
+.navigator-filter-inline {
+ cursor: default;
+
+ &:hover,
+ &.active {
+ border-color: transparent;
+ background: transparent;
+ }
+}
+
.navigator-filter-label {
display: inline-block;
vertical-align: middle;
<js>/javascripts/navigator/filters/select-filters.js</js>
<js>/javascripts/navigator/filters/ajax-select-filters.js</js>
<js>/javascripts/navigator/filters/range-filters.js</js>
+ <js>/javascripts/navigator/filters/checkbox-filters.js</js>
+ <js>/javascripts/navigator/filters/string-filters.js</js>
<js>/javascripts/navigator/filters/favorite-filters.js</js>
<js>/javascripts/navigator/filters/more-criteria-filters.js</js>
<js>/javascripts/navigator/issues-app.js</js>