From e018e301ef40b6577a73ac9f79e757298881dd19 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 28 Oct 2016 17:47:21 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=85=B3=E6=B3=A8BUG?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/watchers_controller.rb | 27 ++++++++++++++++----- app/views/projects/_applied_status.html.erb | 2 +- app/views/watchers/unwatch.js.erb | 7 ++++++ app/views/watchers/watch.js.erb | 8 +++++- 4 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 app/views/watchers/unwatch.js.erb diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb index 6e7f0adc6..304ba10a2 100644 --- a/app/controllers/watchers_controller.rb +++ b/app/controllers/watchers_controller.rb @@ -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" diff --git a/app/views/projects/_applied_status.html.erb b/app/views/projects/_applied_status.html.erb index 414449eb8..e5a8eae05 100644 --- a/app/views/projects/_applied_status.html.erb +++ b/app/views/projects/_applied_status.html.erb @@ -3,7 +3,7 @@