diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2014-02-20 13:10:19 +0600 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2014-02-20 13:10:19 +0600 |
commit | be1cb1336c442034584ed1159d8c096265dbc5ef (patch) | |
tree | dcf3846173f6382035716db1f84633278df76510 | |
parent | 9a1b960b4e5b3d9f6a73426739b4a2f99c40268a (diff) | |
download | sonarqube-be1cb1336c442034584ed1159d8c096265dbc5ef.tar.gz sonarqube-be1cb1336c442034584ed1159d8c096265dbc5ef.zip |
Better handle "Unresolved" and "Not assigned" selections
Missed files
5 files changed, 60 insertions, 13 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/navigator/_filter_templates.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/navigator/_filter_templates.html.erb index 4f6f4bf5ce3..21f438b75b4 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/navigator/_filter_templates.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/navigator/_filter_templates.html.erb @@ -14,7 +14,7 @@ <script id="selectFilterItemTemplate" type="text/template"> <li> - <label> + <label {[ if (item.special) { ]}class="special"{[ } ]}> <input type="checkbox" value="{{ item.id }}" {[ if (checked) { ]}checked{[ } ]}> {[ if (item.icon) { ]} diff --git a/sonar-server/src/main/webapp/javascripts/navigator/filters/ajax-select-filters.js b/sonar-server/src/main/webapp/javascripts/navigator/filters/ajax-select-filters.js index e0dd518b704..f3b76e8612a 100644 --- a/sonar-server/src/main/webapp/javascripts/navigator/filters/ajax-select-filters.js +++ b/sonar-server/src/main/webapp/javascripts/navigator/filters/ajax-select-filters.js @@ -1,6 +1,7 @@ define(['backbone', 'navigator/filters/base-filters', 'navigator/filters/select-filters'], function (Backbone, BaseFilters, SelectFilters) { - var PAGE_SIZE = 100; + var PAGE_SIZE = 100, + UNASSIGNED = '<unassigned>'; @@ -328,13 +329,38 @@ define(['backbone', 'navigator/filters/base-filters', 'navigator/filters/select- var AssigneeDetailsFilterView = AjaxSelectDetailsFilterView.extend({ + addToSelection: function(e) { + var id = $j(e.target).val(), + model = this.options.filterView.choices.findWhere({ id: id }); + + if (this.model.get('multiple') && id !== UNASSIGNED) { + this.options.filterView.selection.add(model); + this.options.filterView.choices.remove(model); + + var unresolved = this.options.filterView.selection.findWhere({ id: UNASSIGNED }); + if (unresolved) { + this.options.filterView.choices.add(unresolved); + this.options.filterView.selection.remove(unresolved); + } + } else { + this.options.filterView.choices.add(this.options.filterView.selection.models); + this.options.filterView.choices.remove(model); + this.options.filterView.selection.reset([model]); + } + + this.updateValue(); + this.updateLists(); + }, + + resetChoices: function() { - if (this.options.filterView.selection.findWhere({ id: '<unassigned>' })) { + if (this.options.filterView.selection.findWhere({ id: UNASSIGNED })) { this.options.filterView.choices.reset([]); } else { this.options.filterView.choices.reset([{ - id: '<unassigned>', - text: window.SS.phrases.unassigned + id: UNASSIGNED, + text: window.SS.phrases.unassigned, + special: true }]); } }, @@ -367,9 +393,9 @@ define(['backbone', 'navigator/filters/base-filters', 'navigator/filters/select- if (!!assigned) { if (!param) { - param = { value: '<unassigned>' }; + param = { value: UNASSIGNED }; } else { - param.value += ',<unassigned>'; + param.value += ',' + UNASSIGNED; } } @@ -383,7 +409,7 @@ define(['backbone', 'navigator/filters/base-filters', 'navigator/filters/select- restoreFromText: function(value) { - if (_.indexOf(value, '<unassigned>') !== -1) { + if (_.indexOf(value, UNASSIGNED) !== -1) { this.choices.reset([]); } @@ -392,13 +418,14 @@ define(['backbone', 'navigator/filters/base-filters', 'navigator/filters/select- restoreByRequests: function(value) { - if (_.indexOf(value, '<unassigned>') !== -1) { + if (_.indexOf(value, UNASSIGNED) !== -1) { this.selection.add(new Backbone.Model({ - id: '<unassigned>', - text: window.SS.phrases.unassigned + id: UNASSIGNED, + text: window.SS.phrases.unassigned, + special: true })); this.choices.reset([]); - value = _.reject(value, function(k) { return k === '<unassigned>'; }); + value = _.reject(value, function(k) { return k === UNASSIGNED; }); } AjaxSelectFilterView.prototype.restoreByRequests.call(this, value); @@ -436,7 +463,7 @@ define(['backbone', 'navigator/filters/base-filters', 'navigator/filters/select- formatValue: function() { var q = {}; if (this.model.has('property') && this.model.has('value') && this.model.get('value').length > 0) { - var assignees = _.without(this.model.get('value'), '<unassigned>'); + var assignees = _.without(this.model.get('value'), UNASSIGNED); if (assignees.length > 0) { q[this.model.get('property')] = assignees.join(','); } diff --git a/sonar-server/src/main/webapp/stylesheets/navigator.css b/sonar-server/src/main/webapp/stylesheets/navigator.css index f1e84368c4d..0212999a1cc 100644 --- a/sonar-server/src/main/webapp/stylesheets/navigator.css +++ b/sonar-server/src/main/webapp/stylesheets/navigator.css @@ -521,6 +521,12 @@ overflow: hidden; text-overflow: ellipsis; } +.navigator-filter-select-list label.special { + font-style: italic; +} +.navigator-filter-select-list label.special > span { + text-decoration: underline; +} .navigator-filter-select-list .single { padding: 5px 10px; } diff --git a/sonar-server/src/main/webapp/stylesheets/navigator/filters.css b/sonar-server/src/main/webapp/stylesheets/navigator/filters.css index 4779eca34d1..eba23096c66 100644 --- a/sonar-server/src/main/webapp/stylesheets/navigator/filters.css +++ b/sonar-server/src/main/webapp/stylesheets/navigator/filters.css @@ -180,6 +180,12 @@ overflow: hidden; text-overflow: ellipsis; } +.navigator-filter-select-list label.special { + font-style: italic; +} +.navigator-filter-select-list label.special > span { + text-decoration: underline; +} .navigator-filter-select-list .single { padding: 5px 10px; } diff --git a/sonar-server/src/main/webapp/stylesheets/navigator/filters.less b/sonar-server/src/main/webapp/stylesheets/navigator/filters.less index e4a6096faed..1f240313e18 100644 --- a/sonar-server/src/main/webapp/stylesheets/navigator/filters.less +++ b/sonar-server/src/main/webapp/stylesheets/navigator/filters.less @@ -195,6 +195,14 @@ overflow: hidden; text-overflow: ellipsis; } + + &.special { + font-style: italic; + + & > span { + text-decoration: underline; + } + } } .single { |