项目添加收藏功能
This commit is contained in:
parent
17743457e1
commit
e9a1582b71
|
@ -810,6 +810,12 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 项目收藏
|
||||
def store_mine
|
||||
member = Member.where(:project_id => params[:id], :user_id => User.current.id).first
|
||||
member.try(:is_collect) == 1 ? member.update_column(:is_collect, 0) : member.update_column(:is_collect, 1)
|
||||
end
|
||||
|
||||
#加入私有项目
|
||||
def join_project
|
||||
respond_to do |format|
|
||||
|
|
|
@ -341,53 +341,62 @@ module WatchersHelper
|
|||
link_to text, url, :remote => true, :method => method , :class => css
|
||||
end
|
||||
|
||||
def exit_project_link(project)
|
||||
link_to(l(:label_exit_project),exit_cur_project_path(project.id),
|
||||
:remote => true, :confirm => l(:lable_sure_exit_project),
|
||||
:class => "sy_btn_grey mr5" )
|
||||
end
|
||||
|
||||
#项目关注、取消关注
|
||||
#REDO:项目样式确定后方法需要对CSS变量进行改进
|
||||
def watcher_link_for_project(objects, user, options=[])
|
||||
return '' unless user && user.logged?
|
||||
objects = Array.wrap(objects)
|
||||
watched = objects.any? {|object| object.watched_by?(user)}
|
||||
@watch_flag = objects.first.instance_of?(Project)
|
||||
id = watcher_css(objects)
|
||||
text = @watch_flag ?
|
||||
(watched ? l(:button_unfollow) : l(:label_button_following)) : (watched ? l(:button_unwatch) : l(:label_button_following))
|
||||
url = watch_path(:object_type => objects.first.class.to_s.underscore,
|
||||
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort))
|
||||
method = watched ? 'delete' : 'post'
|
||||
link_to text, url, :remote => true, :method => method,
|
||||
:class => "pro_new_topbtn_left fl" ,:id=>id
|
||||
end
|
||||
|
||||
# 申请加入项目
|
||||
def join_in_project_link(project, user, options=[])
|
||||
applied = project.applied_projects.find_by_user_id(user.id)
|
||||
text = applied ? l(:label_unapply_project) : l(:label_apply_project)
|
||||
url = applied_join_project_path(:object_id => project.id)
|
||||
method = 'post'
|
||||
@applied_flag = project.instance_of?(Project)
|
||||
if applied
|
||||
link = "<a class ='sy_btn_pink mr5'>#{text}</a>"
|
||||
else
|
||||
link = link_to(text, url, :remote => true, :method => method, :id => "#{project.id}", :class => "sy_btn_pink mr5")
|
||||
end
|
||||
link.html_safe
|
||||
# if applied
|
||||
# appliedid = applied.id
|
||||
# end
|
||||
# id = applied_css(project)
|
||||
# url = appliedproject_path(
|
||||
# :id=>appliedid,
|
||||
# :user_id => user.id,
|
||||
# :project_id => project.id)
|
||||
# method = applied ? 'delete' : 'post'
|
||||
# link_to text, url, :remote => true, :method => method , :class => "pr_join_a",:id => id
|
||||
def exit_project_link(project)
|
||||
link_to(l(:label_exit_project),exit_cur_project_path(project.id),
|
||||
:remote => true, :confirm => l(:lable_sure_exit_project),
|
||||
:class => "pro_new_topbtn_left fl" )
|
||||
end
|
||||
|
||||
#项目关注、取消关注
|
||||
#REDO:项目样式确定后方法需要对CSS变量进行改进
|
||||
def watcher_link_for_project(objects, user, options=[])
|
||||
return '' unless user && user.logged?
|
||||
objects = Array.wrap(objects)
|
||||
watched = objects.any? {|object| object.watched_by?(user)}
|
||||
@watch_flag = objects.first.instance_of?(Project)
|
||||
id = watcher_css(objects)
|
||||
text = @watch_flag ?
|
||||
(watched ? l(:button_unfollow) : l(:label_button_following)) : (watched ? l(:button_unwatch) : l(:label_button_following))
|
||||
url = watch_path(:object_type => objects.first.class.to_s.underscore,
|
||||
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort))
|
||||
method = watched ? 'delete' : 'post'
|
||||
link_to text, url, :remote => true, :method => method,
|
||||
:class => "pro_new_topbtn_left fl" ,:id=>id
|
||||
end
|
||||
|
||||
def store_project_link project_id, user_id
|
||||
collected = Member.where(:project_id => project_id, :user_id => user_id).first.try(:is_collect)
|
||||
text = collected == 1 ? l(:label_project_collect) : l(:label_project_collect_cancel)
|
||||
url = store_mine_project_path(project_id)
|
||||
method = 'post'
|
||||
link = link_to(text, url, :remote => true, :method => method, :id => "#{project_id}", :class => "pro_new_topbtn_left fl")
|
||||
# link.html_safe
|
||||
end
|
||||
|
||||
# 申请加入项目
|
||||
def join_in_project_link(project, user, options=[])
|
||||
applied = project.applied_projects.find_by_user_id(user.id)
|
||||
text = applied ? l(:label_unapply_project) : l(:label_apply_project)
|
||||
url = applied_join_project_path(:object_id => project.id)
|
||||
method = 'post'
|
||||
@applied_flag = project.instance_of?(Project)
|
||||
if applied
|
||||
link = "<a class ='pro_new_topbtn_left fl'>#{text}</a>"
|
||||
else
|
||||
link = link_to(text, url, :remote => true, :method => method, :id => "#{project.id}", :class => "pro_new_topbtn_left fl")
|
||||
end
|
||||
link.html_safe
|
||||
# if applied
|
||||
# appliedid = applied.id
|
||||
# end
|
||||
# id = applied_css(project)
|
||||
# url = appliedproject_path(
|
||||
# :id=>appliedid,
|
||||
# :user_id => user.id,
|
||||
# :project_id => project.id)
|
||||
# method = applied ? 'delete' : 'post'
|
||||
# link_to text, url, :remote => true, :method => method , :class => "pr_join_a",:id => id
|
||||
end
|
||||
|
||||
def paginateHelper obj, pre_size=20
|
||||
@obj_count = obj.count
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
$("#join_in_project_applied").html('<%= escape_javascript( render :partial => 'projects/applied_status') %>');
|
|
@ -51,8 +51,10 @@ zh:
|
|||
label_project_ivite_code: "邀请码"
|
||||
|
||||
label_agree_join_project: 同意加入
|
||||
label_apply_project: "+加入"
|
||||
label_apply_project: "加入"
|
||||
label_button_following: "添加关注"
|
||||
label_project_collect: 收藏
|
||||
label_project_collect_cancel: 取消收藏
|
||||
label_exit_project: 退出项目
|
||||
label_apply_project_waiting: 已处理申请,请等待管理员审核
|
||||
label_member_of_project: 该用户已经是项目成员了!
|
||||
|
|
|
@ -745,6 +745,7 @@ RedmineApp::Application.routes.draw do
|
|||
get 'settings(/:tab)', :action => 'settings', :as => 'settings'
|
||||
#by young
|
||||
get 'member', :to => 'projects#member', :as => 'member'
|
||||
post 'store', :to => 'projects#store_mine', :as => 'store_mine'
|
||||
get 'file', :action => 'file', :as => 'file'
|
||||
get 'statistics', :action => 'statistics', :as => 'statistics'
|
||||
|
||||
|
@ -757,6 +758,7 @@ RedmineApp::Application.routes.draw do
|
|||
get 'send_mail_to_member', :action => 'send_mail_to_member'
|
||||
match 'user_watcherlist', :to => 'projects#watcherlist', :via => :get, :as => "watcherlist"
|
||||
#end
|
||||
|
||||
post 'modules'
|
||||
post 'archive'
|
||||
post 'unarchive'
|
||||
|
|
Loading…
Reference in New Issue