From e9cf61e0f484add972fa46057d75003523952d1f Mon Sep 17 00:00:00 2001 From: whimlex Date: Thu, 16 Apr 2015 17:56:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=BA=E9=99=B7=E7=8A=B6=E6=80=81=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E5=AE=8C=E6=88=90=E5=BA=A6=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/issues/_attributes.html.erb | 6 +++-- public/javascripts/project.js | 35 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/app/views/issues/_attributes.html.erb b/app/views/issues/_attributes.html.erb index 7a93668d0..4ce029217 100644 --- a/app/views/issues/_attributes.html.erb +++ b/app/views/issues/_attributes.html.erb @@ -8,7 +8,8 @@ <% if @issue.safe_attribute?('status_id') && @allowed_statuses.present? %> <%= f.select :status_id, (@allowed_statuses.collect { |p| [p.name, p.id] }), - {:onchange => "updateIssueFrom('#{escape_javascript project_issue_form_path(@project, :id => @issue, :format => 'js')}')", :no_label => true}, + {:no_label => true}, + :onchange => "updateIssueFrom('#{escape_javascript project_issue_form_path(@project, :id => @issue, :format => 'js')}')", :class => "w150" %> <% else %> <%= h(@issue.status.name) %> @@ -92,7 +93,8 @@
  • <% if @issue.safe_attribute?('done_ratio') && @issue.leaf? && Issue.use_field_for_done_ratio? %> <%= f.select :done_ratio, ((0..10).to_a.collect { |r| ["#{r*10} %", r*10] }), - {:required => @issue.required_attribute?('done_ratio'), :no_label => true, :onchange => "PrecentChange(this.value)"}, + {:required => @issue.required_attribute?('done_ratio'), :no_label => true}, + :onchange => "PrecentChange(this.value)", :class => "w150" %> <% end %>
  • diff --git a/public/javascripts/project.js b/public/javascripts/project.js index 6f043c0a3..3085769ba 100644 --- a/public/javascripts/project.js +++ b/public/javascripts/project.js @@ -239,4 +239,39 @@ function showAndScrollTo(id, focus) { $('#'+focus).focus(); } $('html, body').animate({scrollTop: $('#'+id).offset().top}, 400); + + + + /*缺陷完成度决定缺陷状态*/ +function PrecentChange(obj){ + var _v= obj; + if(_v==100) + { + //var select=$("select[id='issue_status_id']"); + $("select[id='issue_status_id']").find("option[value='3']").attr("selected","selected"); + } + else if(_v==0) + { + //alert(1); + $("select[id='issue_status_id']").find("option[value='1']").attr("selected","selected"); + } + else if(_v!=100&&_v!=0) + { + // alert(2); + $("select[id='issue_status_id']").find("option[value='2']").attr("selected","selected"); + } +} + +// Can't use Rails' remote select because we need the form data +// 根据缺陷状态值改变完成度状态 +function updateIssueFrom(url) { + + $.ajax({ + url: url, + type: 'post', + data: $('#issue-form').serialize() + }); + +} + } \ No newline at end of file