issue刷新

This commit is contained in:
huang 2016-01-22 14:21:17 +08:00
parent 4f7d4bb4aa
commit edd198e91f
5 changed files with 65 additions and 35 deletions

View File

@ -81,6 +81,7 @@ class IssuesController < ApplicationController
@priority_id = params[:priority_id]
@status_id = params[:status_id]
@subject = params[:subject]
@done_ratio = parmas[:done_ratio]
@issue_count = @query.issue_count
@issue_pages = Paginator.new @issue_count, @limit, params['page']
params[:page] = (params[:page] || 1).to_i + 1 #页码需要加1
@ -220,19 +221,27 @@ class IssuesController < ApplicationController
end
def update
return unless update_issue_from_params
@issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
saved = false
begin
@saved = @issue.save_issue_with_child_records(params, @time_entry)
rescue ActiveRecord::StaleObjectError
@conflict = true
if params[:last_journal_id]
@conflict_journals = @issue.journals_after(params[:last_journal_id]).all
@conflict_journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
if params[:issue_detail]
issue = Issue.find(params[:issue_id])
issue = update_user_issue_detail(issue, params)
@saved = update_user_issue_detail(issue, params)
return
else
return unless update_issue_from_params
@issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
saved = false
begin
@saved = @issue.save_issue_with_child_records(params, @time_entry)
rescue ActiveRecord::StaleObjectError
@conflict = true
if params[:last_journal_id]
@conflict_journals = @issue.journals_after(params[:last_journal_id]).all
@conflict_journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
end
end
end
if @saved
#修改界面增加跟踪者
watcherlist = @issue.watcher_users
@ -278,6 +287,19 @@ class IssuesController < ApplicationController
end
end
def update_user_issue_detail(issue, params)
case params[:type]
when "status"
issue.update_attribute(:status_id, params[:status_id])
when "assigned"
issue.update_attribute(:assigned_to_id, params[:assigned_to_id])
when "ratio"
issue.update_attribute(:done_ratio, params[:done_ratio])
when "prior"
issue.update_attribute(:priority_id, params[:priority_id])
end
end
# Updates the issue form when changing the project, status or tracker
# on issue creation/update
def update_form

View File

@ -85,6 +85,11 @@ module UsersHelper
end
end
def link_to_user_version(version, options = {})
return '' unless version && version.is_a?(Version)
link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, :class => " f16 fb c_dblue "
end
# 统计未读消息数
def unviewed_message(user)
course_count = CourseMessage.where("user_id =? and viewed =?", user, 0).count

View File

@ -1,6 +1,7 @@
<% if @issue_id %> //issue详情中回复
$("#reply_div_<%= @issue_id %>").html("<%= escape_javascript(render :partial => 'issues/issue_replies', :locals => {:issue => Issue.find( @issue_id),:replies_all_i=>0}) %>");
$("#div_issue_attachment_<%=@issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_attachments', :locals => {:issue => Issue.find( @issue_id)}) %>");
// $("#div_user_issue_detail_<%#=@issue.id %>").html("<%#= escape_javascript(render :partial => 'users/project_issue_detail', :locals => {:issue => Issue.find( @issue_id), :activity => Issue.find( @issue_id)}) %>");
$("#issue_edit").replaceWith('<%= escape_javascript(render :partial => 'issues/edit') %>')
sd_create_editor_from_data(<%= @issue.id%>, null, "100%");
issue_desc_editor = KindEditor.create('#issue_description',
@ -17,6 +18,7 @@
"uploadJson":"/kindeditor/upload",
"fileManagerJson":"/kindeditor/filemanager"});
// $("#issue_test_<%#= @issue.id %>").html("<%#= escape_javascript(render :partial => 'issues/edit', :locals => {:issue => Issue.find( @issue_id)}) %>");
$(".homepagePostReplyBannerCount").html('回复(<%= Issue.find( @issue_id).journals.count %>)')
sd_create_editor_from_data(<%= @issue.id %>, null, "100%");
<%else%>

View File

@ -52,7 +52,9 @@
</div>
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
<%# 局部刷新修改xissue属性 %>
<%= render :partial => 'users/project_issue_detail', :locals => {:activity => activity} %>
<div id="div_user_issue_detail_<%=activity.id %>">
<%= render :partial => 'users/project_issue_detail', :locals => {:activity => activity} %>
</div>
<div class="cl"></div>
<div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div>
<div id="intro_content_hide_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div>
@ -136,8 +138,8 @@
<div class="homepagePostReplyContainer borderBottomNone minHeight48">
<div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= user_activity_id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %></div>
<div class="homepagePostReplyInputContainer mb10">
<div nhname='new_message_<%= user_activity_id%>' style="display:none;">
<%= form_for('new_form',:url => add_journal_issue_path(activity.id),:method => "post", :remote => true) do |f|%>
<div nhname='new_message_<%= user_activity_id %>' style="display:none;">
<%= form_for('new_form',:url => add_journal_issue_path(activity.id),:method => "post", :remote => true) do |f| %>
<input type="hidden" name="user_activity_id" value="<%=user_activity_id%>">
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="notes"></textarea>
<div nhname='toolbar_container_<%= user_activity_id%>' style="float:left;padding-top:3px; margin-left: 5px;"></div>

View File

@ -37,7 +37,12 @@
<div class="cl"></div>
<div class="proInfoBox2 mb10 mt10">
<ul class="fl">
<%= form_tag({:controller => 'issues', :action => 'update', :project_id => activity.project},:remote=>'true', :method => :put, :id=>"issue_query_form_#{activity.id}", :class => 'query_form') do %>
<%#= labelled_fields_for :issue, @issue do |f| %>
<%#= f.select :status_id, ([["新增",1],["正在解决",2],["已解决",3],["反馈",4],["关闭",5],["拒绝",6]].unshift(["状态",0])),
{:include_blank => false, :selected => @status_id ? @status_id : 0 },
{:onchange=>"remote_function('#issue_query_form_#{activity.id}');",:id=>"status_id",:name=>"status_id",:class=>"w70 undis issueEdit"} %>
<%# end %>
<%= form_tag({:controller => 'issues', :action => 'update', :issue_id => activity.id, :issue_detail => true, :type => "status"},:remote=>'true', :method => :put, :id=>"issue_query_form_#{activity.id}", :class => 'query_form') do %>
<li>
<p class="label03">&nbsp;状态&nbsp;&nbsp;:&nbsp;</p>
<p class="proInfoP"><span><%= activity.status.name %></span> <a href="javascript:void(0)" class="pic_edit2 ml5"></a></p>
@ -47,48 +52,42 @@
)
%>
</li>
<% end %>
<div class="cl"></div>
<%= form_tag({:controller => 'issues', :action => 'update', :issue_id => activity.id, :issue_detail => true, :type => "assigned"},:remote=>'true', :method => :put, :id=>"issue_query_assign_form_#{activity.id}", :class => 'query_form') do %>
<li>
<p class="label03">&nbsp;指派&nbsp;&nbsp;:&nbsp;</p>
<span class="pro_info_p">
<%= link_to activity.try(:assigned_to), user_path(activity.assigned_to_id), :class => "linkBlue hidden", :style => "max-width:50px; display:inline-block;" %>
<a href="javascript:void(0)" class="pic_edit2 ml5" style="vertical-align:top;"></a></span>
<%= select( :issue, :user_id, principals_options_for_isuue_list(activity.project),
{ :include_blank => false,:selected=>@assign_to_id ? @assign_to_id : 0
},
{:onchange=>"remote_function();",:id=>"assigned_to_id", :name => "assigned_to_id",:class=>"w70 undis issueEdit"}
)
%>
{ :include_blank => false,:selected => @assign_to_id ? @assign_to_id : 0},
{:onchange=>"remote_function('#issue_query_assign_form_#{activity.id}');", :id =>"assigned_to_id", :name => "assigned_to_id",:class=>"w70 undis issueEdit"}) %>
</li>
<% end %>
<div class="cl"></div>
</ul>
<ul class="fl">
<%= form_tag({:controller => 'issues', :action => 'update', :issue_id => activity.id, :issue_detail => true, :type => "prior"},:remote=>'true', :method => :put, :id=>"issue_query_prior_form_#{activity.id}", :class => 'query_form') do %>
<li>
<p class="label03">&nbsp;优先级&nbsp;&nbsp;:&nbsp;</p>
<span class="proInfoP" style="width:70px;"><span><%= activity.priority.name %></span> <a href="javascript:void(0)" class="pic_edit2 ml5"></a> </span>
<%= select( :issue,:prior, [["低",1],["正常",2],["高",3],["紧急",4],["立刻",5]].unshift(["优先级",0]),
{ :include_blank => false,:selected=>@priority_id ? @priority_id : 0
},
{:onchange=>"remote_function();",:id=>"priority_id",:name=>"priority_id",:class=>"w70 undis issueEdit"}
)
%>
{:include_blank => false,:selected=>@priority_id ? @priority_id : 0},
{:onchange=>"remote_function('#issue_query_prior_form_#{activity.id}');",:id=>"priority_id",:name=>"priority_id",:class=>"w70 undis issueEdit"}) %>
</li>
<% end %>
<div class="cl"></div>
<%= form_tag({:controller => 'issues', :action => 'update', :issue_id => activity.id, :issue_detail => true, :type => "ratio"},:remote=>'true', :method => :put, :id=>"issue_query_done_form_#{activity.id}", :class => 'query_form') do %>
<li>
<p class="label03">&nbsp;完成度&nbsp;&nbsp;:&nbsp;</p>
<span class="proInfoP" style="width:70px;"><span><%= activity.done_ratio %>%</span> <a href="javascript:void(0)" class="pic_edit2 ml5"></a> </span>
<%= select( :issue,:done_ratio, ((0..10).to_a.collect { |r| ["#{r*10} %", r*10] }),
{ :include_blank => false, :selected => @priority_id ? @priority_id : 0
},
{:onchange=>"remote_function();",:id=>"priority_id",:name=>"priority_id",:class=>"w70 undis issueEdit"}
)
%>
<%#= 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)",
:class => "w150" %>
</li>
{:include_blank => false, :selected => @done_ratio ? @done_ratio : 0},
{:onchange=>"remote_function('#issue_query_done_form_#{activity.id}');",:id=>"done_ratio",:name=>"done_ratio",:class=>"w70 undis issueEdit"}) %>
<% end %>
</li>
<div class="cl"></div>
</ul>
<ul class="fl ">
@ -109,7 +108,7 @@
<div class="cl"></div>
<li>
<p class="label03">&nbsp;目标版本&nbsp;&nbsp;:&nbsp;</p>
<span class="proInfoP" style="width:120px;"><%= (activity.fixed_version ? link_to_version(activity.fixed_version) : "--") %> </span> </li>
<span class="proInfoP" style="width:120px;"><%= (activity.fixed_version ? link_to_user_version(activity.fixed_version) : "--") %> </span> </li>
<div class="cl"></div>
</ul>
<!--pro_info_box end-->