diff --git a/app/controllers/admin/experiences_controller.rb b/app/controllers/admin/experiences_controller.rb index 5e2a30c..5b8c1aa 100644 --- a/app/controllers/admin/experiences_controller.rb +++ b/app/controllers/admin/experiences_controller.rb @@ -23,14 +23,50 @@ class Admin::ExperiencesController < OrbitMemberController end def create - @member = MemberProfile.find(experience_params['member_profile_id']) rescue nil - @experience = Experience.new(experience_params) - @experience.save - if params[:desktop] == "true" - render json: {"data" => get_paper_list}.to_json - else + + if !experience_params['member_profile_id'].blank? + + @member = MemberProfile.find(experience_params['member_profile_id']) rescue nil + @experience = Experience.new(experience_params) + @experience.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| + + experience_params['member_profile_id'] = author_member + @experience = Experience.new(experience_params) + @experience.save + + if params[:desktop] == "true" + render json: {"data" => get_paper_list}.to_json + end + + end + redirect_to params['referer_url'] + + else + + experience_params['member_profile_id'] = User.find(current_user.id).member_profile_id + + @experience = Experience.new(experience_params) + @experience.save + + if params[:desktop] == "true" + render json: {"data" => get_paper_list}.to_json + end + + redirect_to params['referer_url'] + end + end def edit diff --git a/app/models/experience.rb b/app/models/experience.rb index 7862749..8a787b5 100644 --- a/app/models/experience.rb +++ b/app/models/experience.rb @@ -57,7 +57,7 @@ class Experience pd_data = [] fields_to_show.collect do |t| if t == "organizationt_title" - pd_data << { "data_title" => "#{p.send(t)}" } + pd_data << { "data_title" => "#{p.send(t)}" } elsif t == "duration" if !p.send('start_date').nil? or !p.send('end_date').nil? diff --git a/app/views/admin/experiences/_form.html.erb b/app/views/admin/experiences/_form.html.erb index 8c651da..496c317 100644 --- a/app/views/admin/experiences/_form.html.erb +++ b/app/views/admin/experiences/_form.html.erb @@ -85,13 +85,26 @@
+ <% if !@member.nil? %> +
<%= @member.name rescue ''%> - <%= f.hidden_field :member_profile_id, :value => @member.id if !@member.nil? %> + <%= f.hidden_field :member_profile_id, :value => @member.id %>
-
+
+ + <% else %> + +
+ +
+ <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'author_members[]', email_members:[]} %> +
+
+ + <% end %>
diff --git a/app/views/admin/experiences/index.html.erb b/app/views/admin/experiences/index.html.erb index 3e589ed..f945752 100644 --- a/app/views/admin/experiences/index.html.erb +++ b/app/views/admin/experiences/index.html.erb @@ -15,6 +15,7 @@
+ <%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:new_), new_admin_experience_path, :class => 'btn btn-primary' %> <%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_experience_setting_path, :class => 'btn btn-primary pull-right' %>