add data can select member

This commit is contained in:
spen 2015-01-20 14:47:03 +08:00
parent 4cfaf42ea6
commit 79c1701b64
4 changed files with 58 additions and 8 deletions

View File

@ -22,14 +22,50 @@ class Admin::ProjectsController < OrbitMemberController
end end
def create def create
@member = MemberProfile.find(project_params['member_profile_id']) rescue nil
@project = Project.new(project_params) if !project_params['member_profile_id'].blank?
@project.save
if params[:desktop] == "true" @member = MemberProfile.find(project_params['member_profile_id']) rescue nil
render json: {"data" => get_paper_list}.to_json @project = Project.new(project_params)
else @project.save
if params[:desktop] == "true"
render json: {"data" => get_paper_list}.to_json
else
redirect_to params['referer_url']
end
elsif !params[:author_members].blank?
params[:author_members].each do |author_member|
project_params['member_profile_id'] = author_member
@project = Project.new(project_params)
@project.save
if params[:desktop] == "true"
render json: {"data" => get_paper_list}.to_json
end
end
redirect_to params['referer_url'] redirect_to params['referer_url']
else
project_params['member_profile_id'] = User.find(current_user.id).member_profile_id
@project = Project.new(project_params)
@project.save
if params[:desktop] == "true"
render json: {"data" => get_paper_list}.to_json
end
redirect_to params['referer_url']
end end
end end
def edit def edit

View File

@ -60,7 +60,7 @@ class Project
pd_data = [] pd_data = []
fields_to_show.collect do |t| fields_to_show.collect do |t|
if t == "project_title" if t == "project_title"
pd_data << { "data_title" => "<a href='#{OrbitHelper.url_to_plugin_show(p.to_param,'personal_project')}'>#{p.send(t)}" } pd_data << { "data_title" => "<a href='#{OrbitHelper.url_to_plugin_show(p.to_param,'personal_project')}' target='_blank'>#{p.send(t)}" }
elsif t == "period" elsif t == "period"
if !p.send('period_start_date').nil? or !p.send('period_end_date').nil? if !p.send('period_start_date').nil? or !p.send('period_end_date').nil?

View File

@ -125,14 +125,27 @@
<!-- Basic Module --> <!-- Basic Module -->
<div class="tab-pane fade in active" id="basic"> <div class="tab-pane fade in active" id="basic">
<% if !@member.nil? %>
<div class="control-group big-group"> <div class="control-group big-group">
<label class="control-label muted"><%= t("personal_plugins.author") %></label> <label class="control-label muted"><%= t("personal_plugins.author") %></label>
<div class="controls"> <div class="controls">
<%= @member.name rescue ''%> <%= @member.name rescue ''%>
<%= f.hidden_field :member_profile_id, :value => @member.id if !@member.nil? %> <%= f.hidden_field :member_profile_id, :value => @member.id %>
</div> </div>
</div> </div>
<% else %>
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
<div class="controls">
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'author_members[]', email_members:[]} %>
</div>
</div>
<% end %>
<!-- year --> <!-- year -->
<div class="control-group"> <div class="control-group">
<label class="control-label muted"><%= t("personal_project.year") %></label> <label class="control-label muted"><%= t("personal_project.year") %></label>

View File

@ -16,6 +16,7 @@
<div class="bottomnav clearfix"> <div class="bottomnav clearfix">
<div class="action pull-right"> <div class="action pull-right">
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:new_), new_admin_project_path, :class => 'btn btn-primary' %>
<%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_project_setting_path, :class => 'btn btn-primary pull-right' %> <%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_project_setting_path, :class => 'btn btn-primary pull-right' %>
</div> </div>
<div class="pagination pagination-centered"> <div class="pagination pagination-centered">