From: Stas Vilchik Date: Tue, 28 Jan 2014 06:50:58 +0000 (+0600) Subject: New Issues Page: plan X-Git-Tag: 4.2~432 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=42be7abc9e58b392d9fd4a890474a169de368ae4;p=sonarqube.git New Issues Page: plan --- 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 9db76769384..ed069c846a7 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 @@ -22,6 +22,7 @@ <%= 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' -%> +<%= render :partial => '/issues/templates/issue_detail_plan_form.hbs' -%> diff --git a/sonar-server/src/main/webapp/javascripts/navigator/issues.js b/sonar-server/src/main/webapp/javascripts/navigator/issues.js index 29642bb33b4..f617c3b3fae 100644 --- a/sonar-server/src/main/webapp/javascripts/navigator/issues.js +++ b/sonar-server/src/main/webapp/javascripts/navigator/issues.js @@ -130,6 +130,21 @@ jQuery(function() { + var ActionPlans = Backbone.Collection.extend({ + + url: function() { + return baseUrl + '/api/action_plans/search'; + }, + + + parse: function(r) { + return r.actionPlans; + } + + }); + + + var IssueView = Backbone.Marionette.ItemView.extend({ template: Handlebars.compile(jQuery('#issue-template').html() || ''), tagName: 'li', @@ -587,6 +602,68 @@ jQuery(function() { + var IssueDetailPlanFormView = Backbone.Marionette.ItemView.extend({ + template: Handlebars.compile(jQuery('#issue-detail-plan-form-template').html() || ''), + + + collectionEvents: { + 'reset': 'render' + }, + + + ui: { + select: '#issue-detail-plan-select' + }, + + + events: { + 'click #issue-plan-cancel': 'cancel', + 'click #issue-plan-submit': 'submit' + }, + + + onRender: function() { + this.ui.select.select2({ + width: '250px', + minimumResultsForSearch: 100 + }); + + this.$('.error a') + .prop('href', baseUrl + '/action_plans/index/' + this.options.issue.get('project')); + }, + + + cancel: function() { + this.options.detailView.updateAfterAction(false); + }, + + + submit: function() { + var that = this; + + jQuery.ajax({ + type: 'POST', + url: baseUrl + '/api/issues/plan', + data: { + issue: this.options.issue.get('key'), + plan: this.ui.select.val() + } + }).done(function() { + that.options.detailView.updateAfterAction(true); + }); + }, + + + serializeData: function() { + return { + items: this.collection.toJSON(), + issue: this.options.issue.toJSON() + } + } + }); + + + var IssueDetailRuleView = Backbone.Marionette.ItemView.extend({ template: Handlebars.compile(jQuery('#issue-detail-rule-template').html() || ''), className: 'rule-desc', @@ -614,7 +691,8 @@ jQuery(function() { 'click .issue-transition': 'transition', 'click #issue-set-severity': 'setSeverity', 'click #issue-assign': 'assign', - 'click #issue-assign-to-me': 'assignToMe' + 'click #issue-assign-to-me': 'assignToMe', + 'click #issue-plan': 'plan' }, @@ -763,6 +841,25 @@ jQuery(function() { }).done(function() { that.resetIssue(); }); + }, + + + plan: function() { + var that = this, + actionPlans = new ActionPlans(), + planFormView = new IssueDetailPlanFormView({ + collection: actionPlans, + issue: this.model, + detailView: this + }); + + actionPlans.fetch({ + reset: true, + data: { project: this.model.get('project') }, + success: function() { + that.showActionView(planFormView); + } + }); } });