Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
huang 2016-10-28 18:05:02 +08:00
commit df07914fbc
4 changed files with 36 additions and 8 deletions

View File

@ -39,9 +39,17 @@ class WatchersController < ApplicationController
else
end
respond_to do |format|
format.html { redirect_to_referer_or {render :text => (true ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'add',:list => @list,:action_name=>params[:action_name],:page=>params[:page],:count=>@obj_count} }
if params[:object_type] == 'project'
@project = Project.find(params[:object_id])
respond_to do |format|
format.js
end
else
respond_to do |format|
format.html { redirect_to_referer_or {render :text => (true ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'add',:list => @list,:action_name=>params[:action_name],:page=>params[:page],:count=>@obj_count} }
end
end
rescue Exception => e
if e.message == "404"
@ -71,9 +79,16 @@ class WatchersController < ApplicationController
@action = 'fans'
else
end
respond_to do |format|
format.html { redirect_to_referer_or {render :text => (false ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'delete',:list=>@list,:action_name=>params[:action_name],:page=>params[:page],:count=>@obj_count} }
if params[:object_type] == 'project'
@project = Project.find(params[:object_id])
respond_to do |format|
format.js
end
else
respond_to do |format|
format.html { redirect_to_referer_or {render :text => (false ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'delete',:list=>@list,:action_name=>params[:action_name],:page=>params[:page],:count=>@obj_count} }
end
end
rescue Exception => e
if e.message == "404"

View File

@ -3,7 +3,7 @@
<!--关注项目-->
<li class="mr5 fl">
<%= watcher_link_for_project(@project, User.current) %>
<%= link_to "#{@project.watcher_users.count}", {:controller=>"projects", :action=>"watcherlist", :id => @project.id}, :class => 'pro_new_topbtn fl' %>
<%= link_to "#{@project.watcher_users.count}", {:controller=>"projects", :action=>"watcherlist", :id => @project.id},:id=>"fans_num", :class => 'pro_new_topbtn fl' %>
</li>
<!--加入项目-->
<li class="mr5 fl">

View File

@ -0,0 +1,7 @@
<% if @project %>
$('#fans_num').html('<%= @project.watcher_users.count %>');
// $('#project-'+'<%=@project.id%>'+'-watcher').html('添加关注');
$('#project-'+'<%=@project.id%>'+'-watcher').replaceWith("<%= escape_javascript watcher_link_for_project(@project, User.current)%>");
<% else %>
$('#fans_num').html('<%= j(@user.watcher_users.count) %>');
<% end %>

View File

@ -1 +1,7 @@
$('#fans_num').html('<%= j(@user.watcher_users.count) %>')
<% if @project %>
$('#fans_num').html('<%= @project.watcher_users.count %>');
// $('#project-'+'<%=@project.id%>'+'-watcher').html('取消关注');
$('#project-'+'<%=@project.id%>'+'-watcher').replaceWith("<%= escape_javascript watcher_link_for_project(@project, User.current)%>");
<% else %>
$('#fans_num').html('<%= j(@user.watcher_users.count) %>');
<% end %>