完成项目邀请及公共弹框的封装
This commit is contained in:
parent
c6bc5c9cb8
commit
4a9eec0cce
|
@ -2,9 +2,8 @@ class AppliedProjectController < ApplicationController
|
|||
|
||||
#申请加入项目
|
||||
def applied_join_project
|
||||
|
||||
@project = Project.find_by_id(params[:object_id])
|
||||
# @user_id = params[:user_id]
|
||||
# @project = Project.find_by_id(params[:project_id])
|
||||
# if params[:project_join]
|
||||
# if @project
|
||||
# user = User.find @user_id
|
||||
|
@ -51,13 +50,16 @@ class AppliedProjectController < ApplicationController
|
|||
@flag = 1
|
||||
elsif User.current.member_of?(@project)
|
||||
@flag = 2
|
||||
elsif params[:member_manager] != "on" || params[:member_developer] != "on" || params[:member_reporter] != "on"
|
||||
elsif params[:member].nil?
|
||||
@flag = 3
|
||||
else
|
||||
@flag = 4
|
||||
end
|
||||
if @flag == 4
|
||||
|
||||
applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => params[:project_id])
|
||||
# 申请成功则给项目管理员发送邮件及发送消息
|
||||
Mailer.run.applied_project(appliedproject)
|
||||
@project.managers.each do |member|
|
||||
AppliedMessage.create(:user_id => member.user_id, :status => true, :applied_id => applied_project.id, :applied_type => "AppliedProject", :viewed => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -368,13 +368,13 @@ module WatchersHelper
|
|||
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 ? unapplied_join_project_path(:object_id => project.id) : applied_join_project_path(:object_id => project.id)
|
||||
method = applied ? 'delete' : 'post'
|
||||
url = applied_join_project_path(:object_id => project.id)
|
||||
method = 'post'
|
||||
@applied_flag = project.instance_of?(Project)
|
||||
if applied
|
||||
link = link_to(text, url, :remote => true, :method => method, :class => "sy_btn_grey fl", :id => "#{project.id}")
|
||||
link = "<a class ='pr_join_a'>text</a>"
|
||||
else
|
||||
link = link_to(text, url, :remote => true, :method => method, :id => "#{project.id}", :class => "sy_btn_grey fl")
|
||||
link = link_to(text, url, :remote => true, :method => method, :id => "#{project.id}", :class => "pr_join_a")
|
||||
end
|
||||
link.html_safe
|
||||
# if applied
|
||||
|
|
|
@ -268,6 +268,11 @@ class Project < ActiveRecord::Base
|
|||
notified.collect(&:mail)
|
||||
end
|
||||
|
||||
# 返回为member类型数组
|
||||
def managers
|
||||
self.members.includes(:roles).select{|member| member.roles[0].try(:name) == "Manager"}
|
||||
end
|
||||
|
||||
def initialize(attributes=nil, *args)
|
||||
super
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<div class="sy_popup_top">
|
||||
<h3 class="fl">欢迎加入项目</h3>
|
||||
<a href="javascript:void(0);" class="sy_icons_close fr"></a>
|
||||
<a href="javascript:void(0);" class="sy_icons_close fr" onclick="hideModal()"></a>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="sy_popup_con" style="width:370px;">
|
||||
<%= form_tag( url_for(:controller => 'applied_project', :action => 'applied_project_info', :project_id => @project.id), :id => 'project_applied_form') do %>
|
||||
<%= form_tag( url_for(:controller => 'applied_project', :action => 'applied_project_info', :project_id => @project.id), :remote => true, :id => 'project_applied_form') do %>
|
||||
<ul class="sy_popup_add ">
|
||||
<li>
|
||||
<label >项目邀请码:</label>
|
||||
|
@ -13,9 +13,9 @@
|
|||
</li>
|
||||
<li>
|
||||
<label >身份:</label>
|
||||
<input name="member_manager" type="radio" class="ml5 mr5 " /><span class="mr10">管理人员</span>
|
||||
<input name="member_developer" type="radio" class="ml5 mr5 " /><span class="mr10">开发人员</span>
|
||||
<input name="member_reporter" type="radio" class="ml5 mr5 " /><span class="mr10">报告人员</span>
|
||||
<input name="member" value="member_manager" type="radio" class="ml5 mr5 " /><span class="mr10">管理人员</span>
|
||||
<input name="member" value="member_developer" type="radio" class="ml5 mr5 " /><span class="mr10">开发人员</span>
|
||||
<input name="member" value="member_reporter" type="radio" class="ml5 mr5 " /><span class="mr10">报告人员</span>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li>
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<div id="sy_popup_box" style="width:380px;">
|
||||
<div class="sy_popup_top sy_popup_top_tishi">
|
||||
<h3 class="fl">提示</h3>
|
||||
<a href="javascript:void(0);" class="sy_icons_close02 fr" onclick="hideModal()"></a>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="sy_popup_con02" >
|
||||
<ul class="sy_popup_tishi ">
|
||||
<li>
|
||||
<% if @flag == 1 %>
|
||||
<p>您输入的邀请码错误</p>
|
||||
<% elsif @flag == 2 %>
|
||||
<p>您已经是该项目成员</p>
|
||||
<% elsif @flag == 3 %>
|
||||
<p>请选择一个角色</p>
|
||||
<% elsif @flag == 4 %>
|
||||
<p>您的申请已提交,请等待项目管理员审批</p>
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
<a href="javascript:void(0);" class="sy_btn_blue " onclick="hideModal()">知道了</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
|
@ -1,5 +1,3 @@
|
|||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'applied_join_project', locals: { }) %>');
|
||||
showModal('ajax-modal', '500px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').parent().css({"top":"40%","left":"50%","transform":"translate(-50%,-50%)","padding":"0","border":"none"});
|
||||
$('#ajax-modal').css({"padding":"0"});
|
||||
var htmlvalue = "<%= escape_javascript(render :partial => 'applied_join_project', locals: {:project_id => @project.id}) %>";
|
||||
pop_box_new(htmlvalue,460,40,50);
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
var htmlvalue = "<%= escape_javascript(render :partial => 'applied_project/applied_project_tip', locals: {:project_id => @project.id}) %>";
|
||||
pop_box_new(htmlvalue,380,40,50);
|
|
@ -56,7 +56,7 @@ zh:
|
|||
label_exit_project: 退出项目
|
||||
label_apply_project_waiting: 已处理申请,请等待管理员审核
|
||||
label_member_of_project: 该用户已经是项目成员了!
|
||||
label_unapply_project: 取消申请
|
||||
label_unapply_project: 等待审批
|
||||
lable_sure_exit_project: 是否确认退出该项目
|
||||
label_friend_organization: 圈子模式
|
||||
label_research_group: 研讨模式
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddQrcodeToProject < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :projects, :qrcode, :string
|
||||
end
|
||||
end
|
14
db/schema.rb
14
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160725062343) do
|
||||
ActiveRecord::Schema.define(:version => 20160728041943) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -74,6 +74,16 @@ ActiveRecord::Schema.define(:version => 20160725062343) do
|
|||
t.integer "session_expire_delay", :default => 10080, :null => false
|
||||
end
|
||||
|
||||
create_table "applied_messages", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "applied_id"
|
||||
t.string "applied_type"
|
||||
t.integer "viewed", :default => 0
|
||||
t.integer "status", :default => 0
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "applied_projects", :force => true do |t|
|
||||
t.integer "project_id", :null => false
|
||||
t.integer "user_id", :null => false
|
||||
|
@ -89,6 +99,7 @@ ActiveRecord::Schema.define(:version => 20160725062343) do
|
|||
t.integer "status", :default => 0
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "user_id"
|
||||
end
|
||||
|
||||
create_table "apply_homeworks", :force => true do |t|
|
||||
|
@ -1848,6 +1859,7 @@ ActiveRecord::Schema.define(:version => 20160725062343) do
|
|||
t.integer "visits", :default => 0
|
||||
t.integer "hot", :default => 0
|
||||
t.string "invite_code"
|
||||
t.string "qrcode"
|
||||
end
|
||||
|
||||
add_index "projects", ["lft"], :name => "index_projects_on_lft"
|
||||
|
|
|
@ -1493,21 +1493,23 @@ function pop_up_box(value,tWidth,tTop,tLeft){
|
|||
}
|
||||
|
||||
// 公共弹框样式
|
||||
// title
|
||||
function pop_box_new(value, tWidth, tTop, tLeft){
|
||||
function pop_box_new(value, Width, Top, Left){
|
||||
$("#ajax-modal").html(value);
|
||||
showModal('ajax-modal', tWidth + "px");
|
||||
showModal('ajax-modal', Width + 'px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-right: 5px; margin-top:-10px;right:0;' class='sy_icons_close fr'></a>");
|
||||
$('#ajax-modal').parent().css("top", tTop+"%").css("left", tLeft+"%").css("padding-top", "10px").css("position", "fixed");
|
||||
$('#ajax-modal').parent().addClass("resourceUploadPopup");
|
||||
$('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px");
|
||||
|
||||
function hideModal(){
|
||||
$('#ajax-modal').hide();
|
||||
}
|
||||
$('#ajax-modal').parent().css({"top": Top+"%","left": Left+"%","transform":"translate(-50%,-50%)","padding":"0","border":"none"});
|
||||
$('#ajax-modal').css({"padding":"0"});
|
||||
}
|
||||
|
||||
// 公共提示弹框样式
|
||||
//function pop_box_tip_new(value, Width, Top, Left){
|
||||
// $("#ajax-modal").html(value);
|
||||
// showModal('ajax-modal', Width + 'px');
|
||||
// $('#ajax-modal').siblings().remove();
|
||||
// $('#ajax-modal').parent().css({"top": Top+"%","left": Left+"%","transform":"translate(-50%,-50%)","padding":"0","border":"none"});
|
||||
// $('#ajax-modal').css({"padding":"0"});
|
||||
//}
|
||||
|
||||
//显示的时候根据当前网址是http 还是https 选择视频显示方式直接显示还是弹框
|
||||
function autoMedia(id){
|
||||
var rootPath = getRootPath();
|
||||
|
|
|
@ -371,11 +371,11 @@ a.sy_icons_close{
|
|||
width:20px;
|
||||
height:20px;
|
||||
display:block;
|
||||
background: url(../images/sy/sy_icons_close.png) 0 0px no-repeat;
|
||||
background: url(/images/sy/sy_icons_close.png) 0 0px no-repeat;
|
||||
margin:8px 10px 0 0;
|
||||
}
|
||||
a:hover.sy_icons_close{
|
||||
background: url(../images/sy/sy_icons_close.png) -40px 0px no-repeat;
|
||||
background: url(/images/sy/sy_icons_close.png) -40px 0px no-repeat;
|
||||
}
|
||||
.sy_popup_con{
|
||||
margin:30px auto 0;
|
||||
|
@ -418,9 +418,11 @@ a.sy_icons_close02{
|
|||
width:20px;
|
||||
height:20px;
|
||||
display:block;
|
||||
background: url(../images/sy/sy_icons_close02.png) 0 0px no-repeat;
|
||||
background: url(/images/sy/sy_icons_close02.png) 0 0px no-repeat;
|
||||
margin:8px 10px 0 0;
|
||||
border: none;
|
||||
outline: none;
|
||||
}
|
||||
a:hover.sy_icons_close02{
|
||||
background: url(../images/sy/sy_icons_close02.png) -40px 0px no-repeat;
|
||||
background: url(/images/sy/sy_icons_close02.png) -40px 0px no-repeat;
|
||||
}
|
Loading…
Reference in New Issue