aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2014-01-27 18:54:52 +0600
committerStas Vilchik <vilchiks@gmail.com>2014-01-27 18:55:06 +0600
commitd0ad835875e3707198711655aebc8957d5959c5d (patch)
tree28d4b52fe2d7541285679aecd2d5766aa4963e3c /sonar-server/src
parent1215bbe2d4569aab44e1bd2503e7d0897c7e3180 (diff)
downloadsonarqube-d0ad835875e3707198711655aebc8957d5959c5d.tar.gz
sonarqube-d0ad835875e3707198711655aebc8957d5959c5d.zip
New Issues Page: assign
Diffstat (limited to 'sonar-server/src')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/issues/search.html.erb9
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/issues/templates/_issue_detail_assign_form.hbs.erb11
-rw-r--r--sonar-server/src/main/webapp/javascripts/navigator/issues.js138
3 files changed, 155 insertions, 3 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/search.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/search.html.erb
index 8d86d8813a5..9db76769384 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/search.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/search.html.erb
@@ -21,6 +21,7 @@
<%= render :partial => '/issues/templates/issue_detail_comment_form.hbs' -%>
<%= render :partial => '/issues/templates/issue_detail_rule.hbs' -%>
<%= render :partial => '/issues/templates/issue_detail_set_severity_form.hbs' -%>
+<%= render :partial => '/issues/templates/issue_detail_assign_form.hbs' -%>
<script>
_.templateSettings = {
@@ -30,6 +31,7 @@
};
_.extend(window.SS, {
+ currentUser: '<%= current_user.login if current_user -%>',
severities: <%= RulesConfigurationController::RULE_PRIORITIES.to_json.html_safe -%>,
statuses: <%= @options_for_statuses.to_json.html_safe -%>,
resolutions: <%= @options_for_resolutions.to_json.html_safe -%>,
@@ -91,8 +93,15 @@
moreCriteria: '<%= escape_javascript message('issue_filter.more_criteria') -%>',
unassigned: '<%= escape_javascript message('unassigned') -%>',
+ assignedToMe: '<%= escape_javascript message('assigned_to_me') -%>',
filtersList: '<%= escape_javascript message('issue_filter.filter_list') -%>',
commentConfirmDelete: '<%= escape_javascript message('issue.comment.delete_confirm_message') -%>',
+
+ select2: {
+ noMatches: '<%= escape_javascript message('select2.noMatches') -%>',
+ searching: '<%= escape_javascript message('select2.searching') -%>',
+ tooShort: '<%= escape_javascript message('select2.tooShort', :params => [2]) -%>'
+ }
}
});
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/templates/_issue_detail_assign_form.hbs.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/templates/_issue_detail_assign_form.hbs.erb
new file mode 100644
index 00000000000..4f495e08b71
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/templates/_issue_detail_assign_form.hbs.erb
@@ -0,0 +1,11 @@
+<script id="issue-detail-assign-form-template" type="text/x-handlebars-template">
+ <table class="width100 123">
+ <tr>
+ <td>
+ <input type="text" id="issue-assignee-select">
+ <input id="issue-assign-submit" type="submit" value="<%= message('issue.assign.submit') -%>">
+ <a id="issue-assign-cancel" class="link-action"><%= message('cancel') -%></a>
+ </td>
+ </tr>
+ </table>
+</script>
diff --git a/sonar-server/src/main/webapp/javascripts/navigator/issues.js b/sonar-server/src/main/webapp/javascripts/navigator/issues.js
index 299613f0c1b..29642bb33b4 100644
--- a/sonar-server/src/main/webapp/javascripts/navigator/issues.js
+++ b/sonar-server/src/main/webapp/javascripts/navigator/issues.js
@@ -489,6 +489,104 @@ jQuery(function() {
+ var IssueDetailAssignFormView = Backbone.Marionette.ItemView.extend({
+ template: Handlebars.compile(jQuery('#issue-detail-assign-form-template').html() || ''),
+
+
+ ui: {
+ select: '#issue-assignee-select'
+ },
+
+
+ events: {
+ 'click #issue-assign-cancel': 'cancel',
+ 'click #issue-assign-submit': 'submit'
+ },
+
+
+ onRender: function() {
+ var currentUser = window.SS.currentUser,
+ assignee = this.options.issue.get('assignee'),
+ additionalChoices = [];
+
+ if (!assignee || currentUser !== assignee) {
+ additionalChoices.push({
+ id: currentUser,
+ text: window.SS.phrases.assignedToMe
+ });
+ }
+
+ if (!!assignee) {
+ additionalChoices.push({
+ id: '',
+ text: window.SS.phrases.unassigned
+ });
+ }
+
+ var select2Options = {
+ allowClear: false,
+ width: '250px',
+ formatNoMatches: function() { return window.SS.phrases.select2.noMatches; },
+ formatSearching: function() { return window.SS.phrases.select2.searching; },
+ formatInputTooShort: function() { return window.SS.phrases.select2.tooShort; }
+ };
+
+ if (additionalChoices.length > 0) {
+ select2Options.minimumInputLength = 0;
+ select2Options.query = function(query) {
+ if (query.term.length == 0) {
+ query.callback({ results: additionalChoices });
+ } else if (query.term.length >= 2) {
+ jQuery.ajax({
+ url: baseUrl + '/api/users/search?f=s2',
+ data: { s: query.term },
+ dataType: 'jsonp'
+ }).done(function(data) {
+ query.callback(data);
+ });
+ }
+ }
+ } else {
+ select2Options.minimumInputLength = 2;
+ select2Options.ajax = {
+ quietMillis: 300,
+ url: baseUrl + '/api/users/search?f=s2',
+ data: function (term, page) {
+ return {s: term, p: page}
+ },
+ results: function (data) {
+ return { more: data.more, results: data.results }
+ }
+ };
+ }
+
+ this.ui.select.select2(select2Options).select2('open');
+ },
+
+
+ cancel: function() {
+ this.options.detailView.updateAfterAction(false);
+ },
+
+
+ submit: function() {
+ var that = this;
+
+ jQuery.ajax({
+ type: 'POST',
+ url: baseUrl + '/api/issues/assign',
+ data: {
+ issue: this.options.issue.get('key'),
+ assignee: this.ui.select.val()
+ }
+ }).done(function() {
+ that.options.detailView.updateAfterAction(true);
+ });
+ }
+ });
+
+
+
var IssueDetailRuleView = Backbone.Marionette.ItemView.extend({
template: Handlebars.compile(jQuery('#issue-detail-rule-template').html() || ''),
className: 'rule-desc',
@@ -514,7 +612,9 @@ jQuery(function() {
'click .issue-comment-edit': 'editComment',
'click .issue-comment-delete': 'deleteComment',
'click .issue-transition': 'transition',
- 'click #issue-set-severity': 'setSeverity'
+ 'click #issue-set-severity': 'setSeverity',
+ 'click #issue-assign': 'assign',
+ 'click #issue-assign-to-me': 'assignToMe'
},
@@ -538,6 +638,14 @@ jQuery(function() {
},
+ resetIssue: function(options) {
+ var key = this.model.get('key');
+ this.model.clear({ silent: true });
+ this.model.set({ key: key }, { silent: true });
+ return this.model.fetch(options);
+ },
+
+
fetchRule: function() {
this.rule.fetch();
},
@@ -554,7 +662,7 @@ jQuery(function() {
var that = this;
if (fetch) {
- jQuery.when(this.model.fetch()).done(function() {
+ jQuery.when(this.resetIssue()).done(function() {
that.formRegion.reset();
that.$('.code-issue-actions').show();
that.$('.code-issue-form').hide();
@@ -620,7 +728,7 @@ jQuery(function() {
transition: jQuery(e.target).data('transition')
}
}).done(function() {
- that.model.fetch();
+ that.resetIssue();
});
},
@@ -631,6 +739,30 @@ jQuery(function() {
detailView: this
});
this.showActionView(setSeverityFormView);
+ },
+
+
+ assign: function() {
+ var assignFormView = new IssueDetailAssignFormView({
+ issue: this.model,
+ detailView: this
+ });
+ this.showActionView(assignFormView);
+ },
+
+
+ assignToMe: function() {
+ var that = this;
+ jQuery.ajax({
+ type: 'POST',
+ url: baseUrl + '/api/issues/assign',
+ data: {
+ issue: this.model.get('key'),
+ assignee: window.SS.currentUser
+ }
+ }).done(function() {
+ that.resetIssue();
+ });
}
});