From 73e510f840f68a637e8d51393df82ecc1eba0309 Mon Sep 17 00:00:00 2001 From: Bohung Date: Sat, 24 Apr 2021 18:41:50 +0800 Subject: [PATCH] Add preferred session field. Use preferred session to assign default session. Add review page. --- .../seminar_review_results_controller.rb | 53 +++ .../seminar_submission_values_controller.rb | 45 +++ app/controllers/admin/seminars_controller.rb | 139 ++++++-- app/helpers/admin/seminars_field_helper.rb | 13 +- app/helpers/admin/seminars_helper.rb | 2 + app/helpers/admin/seminars_values_helper.rb | 4 + app/models/seminar_main.rb | 306 ++++++++++-------- app/models/seminar_review.rb | 28 +- app/models/seminar_review_result.rb | 17 + app/models/seminar_session.rb | 9 +- app/models/seminar_signup.rb | 15 +- app/models/seminar_signup_contribute.rb | 32 +- app/models/seminar_signup_field.rb | 4 +- app/models/seminar_submission_field.rb | 4 +- app/models/seminar_submission_value.rb | 35 +- .../seminar_review_results/edit.html.erb | 132 ++++++++ .../seminar_submission_values/edit.html.erb | 5 + .../admin/seminars/_attribute_field.html.erb | 23 +- .../_attribute_submission_field.html.erb | 36 ++- .../seminars/_get_display_fields.html.erb | 23 +- .../_seminar_signup_dashboard.html.erb | 31 +- .../_seminar_signup_render_table.html.erb | 107 ++++-- ..._seminar_signup_session_dashboard.html.erb | 26 +- .../seminars/_seminar_signup_table.html.erb | 44 +-- .../admin/seminars/_sessions_filter.html.erb | 185 +++++++++++ .../seminars/_support_member_form_js.erb | 17 +- .../admin/seminars/get_hide_session.html.erb | 2 +- .../admin/seminars/get_session_block.html.erb | 3 +- .../admin/seminars/seminar_signup.html.erb | 51 ++- app/views/seminars/con_upload.html.erb | 7 + config/list.yml | 44 +++ config/locales/en.yml | 15 +- config/locales/zh_tw.yml | 14 +- config/routes.rb | 2 + seminar.gemspec | 3 +- 35 files changed, 1227 insertions(+), 249 deletions(-) create mode 100644 app/controllers/admin/seminar_review_results_controller.rb create mode 100644 app/controllers/admin/seminar_submission_values_controller.rb create mode 100644 app/models/seminar_review_result.rb create mode 100644 app/views/admin/seminar_review_results/edit.html.erb create mode 100644 app/views/admin/seminar_submission_values/edit.html.erb create mode 100644 app/views/admin/seminars/_sessions_filter.html.erb create mode 100644 config/list.yml diff --git a/app/controllers/admin/seminar_review_results_controller.rb b/app/controllers/admin/seminar_review_results_controller.rb new file mode 100644 index 0000000..3ba1d80 --- /dev/null +++ b/app/controllers/admin/seminar_review_results_controller.rb @@ -0,0 +1,53 @@ +# encoding: utf-8 +class Admin::SeminarReviewResultsController < OrbitAdminController + include Admin::SeminarsHelper + before_action ->(module_app = @app_title) { set_variables module_app } + before_action :set_seminar,:check_permission_for_seminar + def initialize + super + @app_title = "seminar" + end + def set_seminar + @seminar_signup_contribute = SeminarSignupContribute.find(params[:id]) rescue nil + @seminar_review_result = @seminar_signup_contribute.seminar_review_result rescue nil + @seminar_review_result = SeminarReviewResult.new if @seminar_review_result.nil? + @seminar = @seminar_signup_contribute.seminar_signup.seminar_main rescue nil + end + def check_manager_for_seminar + OrbitHelper.set_params(params,current_user) + access_level = OrbitHelper.user_access_level? + if (access_level.nil? || access_level == "user") + if (@seminar.organizer_id != current_user.member_profile_id rescue true) + render_401 + end + end + end + def check_permission_for_seminar + OrbitHelper.set_params(params,current_user) + access_level = OrbitHelper.user_access_level? + if (access_level.nil? || access_level == "user") + unless (@seminar.reviewer_ids.include?(current_user.member_profile_id.to_s) rescue false) || (@seminar.organizer_id == current_user.member_profile_id rescue false) + render_401 + else + @user_authenticated_categories = ['all'] + end + end + end + def edit + OrbitHelper.set_params(params,current_user) + @form_index = 0 + params[:controller] = "admin/seminars" + params[:action] = "edit_seminar_review" + end + + def update + @seminar_signup_contribute.update_attributes(seminar_signup_contribute_params) + redirect_to params[:referer_url] + end + + private + + def seminar_signup_contribute_params + params.require(:seminar_signup_contribute).permit! + end +end diff --git a/app/controllers/admin/seminar_submission_values_controller.rb b/app/controllers/admin/seminar_submission_values_controller.rb new file mode 100644 index 0000000..6537fa2 --- /dev/null +++ b/app/controllers/admin/seminar_submission_values_controller.rb @@ -0,0 +1,45 @@ +# encoding: utf-8 +class Admin::SeminarSubmissionValuesController < OrbitAdminController + include Admin::SeminarsHelper + before_action ->(module_app = @app_title) { set_variables module_app } + before_action :set_seminar,:check_manager_for_seminar + def initialize + super + @app_title = "seminar" + end + def set_seminar + @seminar_submission_value = SeminarSubmissionValue.find(params[:id]) rescue nil + @seminar_submission_field = @seminar_submission_value.seminar_submission_field rescue nil + @con = @seminar_submission_value.seminar_signup_contribute rescue nil + @seminar = @seminar_submission_value.seminar_submission_field.seminar_main rescue nil + end + def check_manager_for_seminar + OrbitHelper.set_params(params,current_user) + access_level = OrbitHelper.user_access_level? + if (access_level.nil? || access_level == "user") + if (@seminar.organizer_id != current_user.member_profile_id rescue true) + render_401 + end + end + end + def edit + OrbitHelper.set_params(params,current_user) + @form_index = 0 + render :layout =>false + end + + def update + begin + @seminar_submission_value.update_attributes(seminar_submission_value_params) + render :json => {:success=>true,:val=>@seminar_submission_value.get_value_by_locale(I18n.locale)} + rescue => e + render :json => {:success=>false,:error=>e.to_s} + end + end + + private + + def seminar_submission_value_params + params.require(:seminar_submission_values).permit!.values.first + end +end diff --git a/app/controllers/admin/seminars_controller.rb b/app/controllers/admin/seminars_controller.rb index f06b862..efe247c 100644 --- a/app/controllers/admin/seminars_controller.rb +++ b/app/controllers/admin/seminars_controller.rb @@ -124,16 +124,18 @@ class Admin::SeminarsController < OrbitAdminController if @seminar_signups.class != Array seminar_review = SeminarReview.where(:reviewer_id=>reviewer_id) seminar_signup_ids = seminar_review.pluck(:seminar_signup_ids).flatten + seminar_sessions = SeminarSession.where(:id.in=>seminar_review.pluck(:seminar_session_ids)) remove_seminar_signup_ids = seminar_review.pluck(:remove_seminar_signup_ids).flatten assign_ids = [] seminars = SeminarMain.where(:id.in => seminar_review.pluck(:seminar_main_id)) - final_assign_signup_ids = SeminarSession.where(:id.in=>seminar_review.pluck(:seminar_session_ids).flatten,:seminar_main_id.in=>seminars.where(:assign_mode=>1).pluck(:id)).pluck(:seminar_signup_ids).flatten + final_assign_signup_ids = SeminarSession.where(:id.in=>seminar_review.pluck(:seminar_session_ids).flatten,:seminar_main_id.in=>seminars.where(:assign_mode.in=>[1,2]).pluck(:id)).pluck(:seminar_signup_ids,:default_seminar_signup_ids).flatten default_seminar_signup_ids = seminar_review.where(:seminar_main_id.in=>seminars.where(:assign_mode=>0).pluck(:id)).pluck(:default_seminar_signup_ids).flatten all_seminar_signup_ids = seminar_signup_ids - remove_seminar_signup_ids + final_assign_signup_ids + default_seminar_signup_ids ids2 = SeminarSignup.where(:seminar_main_id.in=> SeminarMain.where(:organizer_id=>current_user.member_profile_id).pluck(:id)).pluck(:id) @seminar_signups = @seminar_signups.where(:id.in=>all_seminar_signup_ids + ids2).sort_ordered.page(params[:page]).per(10) + @preferred_sessions = seminar_review.pluck(:session_ids).flatten end end end @@ -145,7 +147,7 @@ class Admin::SeminarsController < OrbitAdminController @seminar = seminar_main @seminar_sessions = @seminar.seminar_sessions @hide_session_ids = (0...seminar_main.summary_chioices.count).to_a - Array(seminar_main.session_show_ids) - @hide_sessions = @hide_session_ids.zip(seminar_main.summary_chioices[Range.new(@hide_session_ids[0],@hide_session_ids[-1])]).to_h + @hide_sessions = @hide_session_ids.zip(@hide_session_ids.map{|idx| seminar_main.summary_chioices[idx]}).to_h render :layout => false end end @@ -162,6 +164,7 @@ class Admin::SeminarsController < OrbitAdminController end def get_session_block @session_id = params[:session_id].to_i + @seminar_session = @seminar.seminar_sessions.where(:key=>@session_id).first unless (@seminar.session_show_ids.include?(@session_id) rescue false) @seminar.session_show_ids << @session_id @seminar.save @@ -184,20 +187,58 @@ class Admin::SeminarsController < OrbitAdminController session_id = params[:session_id].to_i seminar_main.save seminar_session = @seminar.seminar_sessions.where(:key=>session_id).first + @seminar_submission_value = nil + extra_infos = {} + if params[:contribute_id].present? + seminar_signup_contribute = SeminarSignupContribute.find(params[:contribute_id]) + seminar_submission_field = seminar_main.seminar_submission_fields.where(:markup=>"seminar_preferred_session").last + if seminar_submission_field + @seminar_submission_value = seminar_signup_contribute.seminar_submission_values.where(:seminar_submission_field_id=>seminar_submission_field.id).last + end + end if params[:mode] == "append" - @seminar_signup.update(:final_session=>session_id) - seminar_session.seminar_signup_ids << @seminar_signup.id.to_s - @seminar_signup.update(:seminar_session_id=>seminar_session.id) - seminar_main.assign_mode = 1 - seminar_session.save - seminar_main.unassigned_mode_1_seminar_signup_ids.delete(@seminar_signup.id.to_s) + if @seminar_submission_value + @seminar_submission_value.val = session_id.to_s + @seminar_submission_value.save + extra_infos = {"edit" => {"target"=>"[data-id=\"#{@seminar_submission_value.id}\"]","text"=>@seminar_submission_value.get_value_by_locale(I18n.locale)}} + else + @seminar_signup.final_sessions << session_id + @seminar_signup.seminar_session_ids << seminar_session.id + @seminar_signup.seminar_session_ids = @seminar_signup.seminar_session_ids.uniq + @seminar_signup.save + seminar_session.seminar_signup_contribute_ids.append(params[:contribute_id]) + seminar_signup_contribute.update(:final_session=>session_id) rescue nil + seminar_session.seminar_signup_ids << @seminar_signup.id.to_s + seminar_main.assign_mode = 1 if seminar_main.assign_mode != 2 + seminar_session.save + seminar_main.unassigned_mode_1_seminar_signup_ids.delete(@seminar_signup.id.to_s) + end + elsif params[:mode] == "remove_contribute" + if @seminar_submission_value + @seminar_submission_value.val = nil + @seminar_submission_value.save + extra_infos = {"edit" => {"target"=>"[data-id=\"#{@seminar_submission_value.id}\"]","text"=>""}} + else + seminar_session.seminar_signup_contribute_ids.delete(params[:contribute_id]) + seminar_signup_contribute.update(:final_session=>nil) rescue nil + seminar_session.save + end elsif params[:mode] == "remove" - @seminar_signup.update(:final_session=>nil) - seminar_session.seminar_signup_ids.delete(@seminar_signup.id.to_s) - @seminar_signup.update(:seminar_session_id=>nil) - seminar_session.save - seminar_main.assign_mode = 0 if seminar_main.seminar_sessions.where(:seminar_signup_ids.ne=>[]).count == 0 - seminar_main.unassigned_mode_1_seminar_signup_ids << @seminar_signup.id.to_s + if @seminar_submission_value + @seminar_submission_value.val = nil + @seminar_submission_value.save + extra_infos = {"edit" => {"target"=>"[data-id=\"#{@seminar_submission_value.id}\"]","text"=>""}} + else + @seminar_signup.final_sessions.delete(session_id) + @seminar_signup.seminar_session_ids.delete(seminar_session.id) + seminar_session.seminar_signup_ids.delete(@seminar_signup.id.to_s) + seminar_session.seminar_signup_contribute_ids.delete(params[:contribute_id]) + seminar_signup_contribute.update(:final_session=>nil) rescue nil + @seminar_signup.save + seminar_session.save + seminar_main.assign_mode = 0 if seminar_main.seminar_sessions.where(:seminar_signup_ids.ne=>[]).count == 0 && seminar_main.assign_mode != 2 + seminar_main.unassigned_mode_1_seminar_signup_ids << @seminar_signup.id.to_s + end elsif params[:mode] == "hide" if seminar_main.session_show_ids.nil? seminar_main.session_show_ids = (0...seminar_main.summary_chioices.count).to_a[0..1] @@ -209,7 +250,7 @@ class Admin::SeminarsController < OrbitAdminController render :json => {:success => false} and return end seminar_main.save - render :json => {:success => true} + render :json => {:success => true}.merge(extra_infos) end end def update_seminar_review @@ -222,11 +263,24 @@ class Admin::SeminarsController < OrbitAdminController @seminar_review.remove_seminar_signup_ids.delete(params[:signup_id]) seminar_main.unassigned_seminar_signup_ids.delete(params[:signup_id]) seminar_main.unassigned_mode_1_seminar_signup_ids.delete(params[:signup_id]) + if(params[:contribute_id].present?) + @seminar_review.seminar_signup_contribute_ids << params[:contribute_id] + @seminar_review.remove_seminar_signup_contribute_ids.delete(params[:contribute_id]) + end elsif params[:mode] == "remove" @seminar_review.seminar_signup_ids.delete(params[:signup_id]) @seminar_review.remove_seminar_signup_ids << params[:signup_id] seminar_main.unassigned_seminar_signup_ids << params[:signup_id] seminar_main.unassigned_mode_1_seminar_signup_ids << params[:signup_id] + if(params[:contribute_id].present?) + @seminar_review.seminar_signup_contribute_ids.delete(params[:contribute_id]) + @seminar_review.remove_seminar_signup_contribute_ids << params[:contribute_id] + end + elsif params[:mode] == "remove_contribute" + if(params[:contribute_id].present?) + @seminar_review.seminar_signup_contribute_ids.delete(params[:contribute_id]) + @seminar_review.remove_seminar_signup_contribute_ids << params[:contribute_id] + end elsif params[:mode] == "hide" if seminar_main.reviewer_show_ids.nil? seminar_main.reviewer_show_ids = seminar_main.reviewer_ids[0..1] @@ -377,13 +431,14 @@ class Admin::SeminarsController < OrbitAdminController def edit @seminar_items = SeminarItem.all @seminar = SeminarMain.where(id: params[:id]).first + except_attributes = ["final_sessions","preferred_sessions","seminar_session_ids","preferred_session","final_session","sort_number","abstract_number","presentation_type"] @seminar.seminar_signup_field_sets.each do |signup_field_set| - if !(SeminarSignup.attribute_names.include? signup_field_set.field_name) && signup_field_set.field_name != 'recaptcha' + if (!(SeminarSignup.attribute_names.include? signup_field_set.field_name) && signup_field_set.field_name != 'recaptcha') || except_attributes.include?(signup_field_set.field_name) signup_field_set.delete end end @seminar.seminar_submission_field_sets.each do |submission_field_set| - if !(SeminarSignupContribute.attribute_names.include? submission_field_set.field_name) + if (!(SeminarSignupContribute.attribute_names.include? submission_field_set.field_name)) || except_attributes.include?(submission_field_set.field_name) submission_field_set.delete end end @@ -432,6 +487,32 @@ class Admin::SeminarsController < OrbitAdminController end flash.now[:notice] = "Updated Fields" @seminar.seminar_submission_fields.each{|t| t.destroy if t["to_delete"] == true} + if @seminar.seminar_submission_fields.select{|sf| sf.markup == "seminar_preferred_session"}.count != 0 + @seminar.update(:assign_mode => 2) + default_sort_number = SeminarSignup.fields['sort_number'].options[:default] + SeminarSignup.where(:sort_number=>nil).update_all(:sort_number=>default_sort_number) + SeminarSignupContribute.where(:sort_number=>nil).update_all(:sort_number=>default_sort_number) + preferred_session_field = @seminar.seminar_submission_fields.select{|sf| sf.markup == "seminar_preferred_session"}.first + if preferred_session_field.seminar_submission_values.count != 0 + seminar_submission_values = preferred_session_field.seminar_submission_values.to_a + seminar_submission_values.each do |v| + next if v.val.to_i.to_s != v.val + seminar_session = @seminar.seminar_sessions.where(:key=>v.val.to_i).first + seminar_session.default_seminar_signup_ids << v.seminar_signup_contribute.seminar_signup_id.to_s + seminar_session.default_seminar_signup_ids = seminar_session.default_seminar_signup_ids.uniq + seminar_session.save + end + Thread.new do + SeminarMain.where(:update_old_flag=>false).each{|s| s.fix_old_data} + end + end + else + if seminar_main.seminar_sessions.where(:seminar_signup_ids.ne=>[]).count == 0 + @seminar.update(:assign_mode => 0) + else + @seminar.update(:assign_mode => 1) + end + end redirect_to admin_seminars_path else @@ -485,6 +566,12 @@ class Admin::SeminarsController < OrbitAdminController def seminar_signup @seminar_signups = [] + @filter_fields = {} + @summary_chioices = @seminar.enable_summary_choice ? @seminar.summary_chioices : [] + @enable_review_result = @seminar.enable_review_result + if @enable_review_result + @filter_fields["seminar.assigned_session"] = @summary_chioices.map.with_index{|summary_chioice,i| {:title=>summary_chioice, :id=>i}} rescue [] + end if params[:type] == "table" if params[:search].to_i != 0 @seminar_signups = @seminar.seminar_signups.where(:serial_number=>params[:search].to_i) @@ -492,10 +579,11 @@ class Admin::SeminarsController < OrbitAdminController @seminar_signups = @seminar.seminar_signups.where(:name=>/#{params[:search]}/) end elsif params[:type] == "session" - @seminar_signups = @seminar.seminar_signups.where(:final_session => nil, :name=>/#{params[:search]}/) + assigned_seminar_signups = @seminar.seminar_sessions.pluck(:seminar_signup_ids,:default_seminar_signup_ids).flatten + @seminar_signups = @seminar.seminar_signups.where(:id.nin=>assigned_seminar_signups) else unassigned_seminar_signup_ids = @seminar.unassigned_seminar_signup_ids - if @seminar.assign_mode == 1 + if @seminar.assign_mode != 0 unassigned_seminar_signup_ids = @seminar.unassigned_mode_1_seminar_signup_ids end @seminar_signups = @seminar.seminar_signups.where(:id.in => unassigned_seminar_signup_ids, :name=>/#{params[:search]}/) @@ -512,6 +600,16 @@ class Admin::SeminarsController < OrbitAdminController unless @can_edit @seminar_review = @seminar.seminar_reviews.where(:reviewer_id => current_user.member_profile_id.to_s).first @seminar_signups = @seminar.seminar_signups.where(:id.in=>@seminar_review.get_all_seminar_signup_ids) + @preferred_sessions = @seminar_review.session_ids + if @enable_review_result + @filter_fields["seminar.assigned_session"] = @filter_fields["seminar.assigned_session"].select{|h| @preferred_sessions.include?(h[:id])} rescue [] + end + @append_contribute_ids = @seminar_review.seminar_signup_contribute_ids + @remove_contribute_ids = @seminar_review.remove_seminar_signup_contribute_ids + end + if params[:filters] && params[:filters][:assigned_session].present? + @preferred_sessions = params[:filters][:assigned_session].map{|s| s.to_i} + @seminar_signups = @seminar_signups.where(:preferred_sessions.in=> @preferred_sessions) end @seminar_signups = @seminar_signups.sort_ordered.page(params[:page]).per(10) if request.xhr? @@ -574,7 +672,9 @@ class Admin::SeminarsController < OrbitAdminController params.require(:seminar_main).permit! end def create_set (save_flag) + except_attributes = ["final_sessions","preferred_sessions","seminar_session_ids","preferred_session","final_session","sort_number","abstract_number","presentation_type"] SeminarSignup.attribute_names.each do |attr_signup| + next if except_attributes.include?(attr_signup) if !(['_id', 'created_at', 'updated_at','seminar_main_id','final_session','seminar_session_id'].include? attr_signup) signup_set = @seminar.seminar_signup_field_sets.select{|v| v.field_name==attr_signup } if signup_set.length==0 @@ -619,6 +719,7 @@ class Admin::SeminarsController < OrbitAdminController end end SeminarSignupContribute.attribute_names.each do |attr_submission| + next if except_attributes.include?(attr_submission) if !(['_id', 'created_at', 'updated_at','seminar_signup_id'].include? attr_submission) signup_set = @seminar.seminar_submission_field_sets.select{|v| v.field_name==attr_submission } if signup_set.length==0 diff --git a/app/helpers/admin/seminars_field_helper.rb b/app/helpers/admin/seminars_field_helper.rb index 3ac3c1e..5d100d9 100644 --- a/app/helpers/admin/seminars_field_helper.rb +++ b/app/helpers/admin/seminars_field_helper.rb @@ -142,7 +142,16 @@ module Admin::SeminarsFieldHelper end.join.html_safe end end - + def render_seminar_preferred_session + @prefiled_value ||=[] + @prefiled_value = Array(@prefiled_value) + control_group_wrapper do + @member.summary_chioices.map.with_index do |value,key| + key = key.to_s + label_tag("#{get_basic_field_name_org}_#{self.id}_#{key}",radio_button_tag(get_field_name_base, key , ((@prefiled_value.include?(key) || @prefiled_value.include?(key.to_i)) ? true : false), {:required=>@require,:id=>"#{get_basic_field_name_org}_#{self.id}_#{key}"})+value,@markup_options.merge(:class=>"radio inline")) + end.join.html_safe + end if @member.enable_summary_choice + end def render_select prompt = @panel_setting["initial"][I18n.locale.to_s] rescue nil @markup_options.merge!(:prompt => prompt) unless prompt.nil? @@ -449,7 +458,7 @@ protected if self.markup == "address" return true else - LIST[:markups][markup]["muti_lang_input_supprt"] and !(get_data["cross_lang"] == "true") + $seminar_list[:markups][markup]["muti_lang_input_supprt"] and !(get_data["cross_lang"] == "true") end end diff --git a/app/helpers/admin/seminars_helper.rb b/app/helpers/admin/seminars_helper.rb index 15f3dfd..d49a841 100644 --- a/app/helpers/admin/seminars_helper.rb +++ b/app/helpers/admin/seminars_helper.rb @@ -1,4 +1,6 @@ module Admin::SeminarsHelper + data = File.open(File.join(File.dirname(__FILE__), '../../../config', 'list.yml')).read + $seminar_list = YAML::load(ERB.new(data).result(binding)).symbolize_keys def display_format_string(num, str_length) return format("%0#{str_length}d", num % (10^str_length)) end diff --git a/app/helpers/admin/seminars_values_helper.rb b/app/helpers/admin/seminars_values_helper.rb index 7743617..f076cd2 100644 --- a/app/helpers/admin/seminars_values_helper.rb +++ b/app/helpers/admin/seminars_values_helper.rb @@ -1,4 +1,8 @@ module Admin::SeminarsValuesHelper + def show_seminar_type_panel(attribute_field,type) + markup = attribute_field.markup + $seminar_list[:markups][markup]["panel"] == type ? type : [type,'hide'].join(" ") + end def show_west_calender(from_to=nil) case from_to when :to diff --git a/app/models/seminar_main.rb b/app/models/seminar_main.rb index 92f60e9..10373dc 100644 --- a/app/models/seminar_main.rb +++ b/app/models/seminar_main.rb @@ -45,7 +45,8 @@ class SeminarMain field :review_start_date, :type => Date field :review_end_date, :type => Date field :last_serial_number, :type => Integer, :default => 0 - field :assign_mode, :type => Integer, :default => 0 # 0 => 用default signup ids來分配 ,1 => 用final_session來分配 + field :assign_mode, :type => Integer, :default => 0 # 0 => 用default signup ids來分配 ,1 => 用final_session來分配, 2 => 用final_session來分配(當有preffered session欄位時) + field :update_old_flag, :type => Boolean, :default => false belongs_to :seminar_item belongs_to :organizer , :class_name=>"MemberProfile", :foreign_key => :organizer_id has_many :seminar_sessions, :autosave => true, :dependent => :destroy @@ -178,6 +179,13 @@ class SeminarMain if self["reviewer_ids"].nil? self["reviewer_ids"] = seminar_reviews.pluck(:reviewer_id).flatten.select{|s| !s.nil?}.to_a save_flag = true + else + self["reviewer_ids"].each do |reviewer_id| + seminar_review_to_destroy = seminar_reviews.where(:reviewer_id=>reviewer_id)[1] + if seminar_review_to_destroy + seminar_review_to_destroy.destroy + end + end end if seminar_reviews.count != 0 && self.review_start_date.nil? && self.review_end_date.nil? review_start_date = seminar_reviews.pluck(:review_start_date).select{|t| t.present?}.first.to_datetime rescue nil @@ -264,12 +272,12 @@ class SeminarMain self.unassigned_seminar_signup_ids = map_seminar_signup_ids(clone_target.unassigned_seminar_signup_ids) self.unassigned_mode_1_seminar_signup_ids = map_seminar_signup_ids(clone_target.unassigned_mode_1_seminar_signup_ids) - need_change_seminar_signups = self.seminar_signups.where(:seminar_session_id.ne=>nil).to_a + need_change_seminar_signups = self.seminar_signups.where(:seminar_session_ids.nin=>[nil,[]]).to_a count_array = (0...need_change_seminar_signups.count).to_a count_array.each do |i| seminar_signup = need_change_seminar_signups[i] - if seminar_signup.seminar_session_id.present? - seminar_signup.seminar_session_id = @records_all["seminar_session_ids"][seminar_signup.seminar_session_id] rescue nil + if seminar_signup.seminar_session_ids.present? + seminar_signup.seminar_session_ids = seminar_signup.seminar_session_ids.map{|id| @records_all["seminar_session_ids"][id]} rescue [] end end count_array = (0...self.seminar_reviews.to_a.count).to_a @@ -293,118 +301,114 @@ class SeminarMain end seminar end -end -def map_seminar_signup_ids(old_seminar_signup_ids) - if @records_all["seminar_signup_ids"].present? - old_seminar_signup_ids.map{|seminar_signup_id| @records_all["seminar_signup_ids"][BSON::ObjectId(seminar_signup_id)].to_s rescue ""}.select{|t| t.present?} - else - [] - end -end -def clone_new_for_object(object,clone_target=nil,clone_mode=false) - if clone_mode - new_object = object - clone_target = object.class.find(object.copy_id) rescue nil if clone_target.nil? - else - clone_target = object if clone_target.nil? - new_object = object.dup - end - return if self.except_clone_relations.to_s.include?(new_object.class.to_s.underscore) - @records_all["#{new_object.class.to_s.underscore.singularize}_ids"] = {} if @records_all["#{new_object.class.to_s.underscore.singularize}_ids"].nil? - begin - @records_all["#{new_object.class.to_s.underscore.singularize}_ids"][clone_target.id] = object.id - rescue - nil - end - if !clone_target.nil? && !new_object.nil? - initialize_fields = ["uid","created_at","updated_at"] - initialize_fields.each do |f| - new_object.send("#{f}=",nil) if new_object.fields.keys.include?(f) + def map_seminar_signup_ids(old_seminar_signup_ids) + if @records_all["seminar_signup_ids"].present? + old_seminar_signup_ids.map{|seminar_signup_id| @records_all["seminar_signup_ids"][BSON::ObjectId(seminar_signup_id)].to_s rescue ""}.select{|t| t.present?} + else + [] end - relations_fields = clone_target.relations.except("impressions").keys - all_fields = clone_target.fields.keys - relations_fields - all_fields = all_fields - relations_fields.map{|k| "#{k}_id"} - all_fields = all_fields - relations_fields.map{|k| "#{k.singularize}_ids"} - new_object_class_name = new_object.class.to_s.underscore - relations_fields = clone_target.relations.except("impressions").keys - unsort_relation_keys = clone_target.relations.keys - unless @parent_level - fields_to_delete = [new_object_class_name] - tmp_relations_fields = [new_object_class_name] - while relations_fields.count > 0 - tmp_singularize_relations_fields = tmp_relations_fields.map{|f| f.singularize} - approve_append = nil - relations_fields.each do |k| - belongs_to_class = clone_target.relations[k].class_name.constantize.relations.select{|k,v| v.macro == :belongs_to}.keys - has_many_class = clone_target.relations[k].class_name.constantize.relations.select{|k,v| v.macro == :has_many}.keys - if (belongs_to_class - tmp_singularize_relations_fields).count == 0 - other_has_many_class = (has_many_class - unsort_relation_keys) - if other_has_many_class.count == 0 + end + def clone_new_for_object(object,clone_target=nil,clone_mode=false) + if clone_mode + new_object = object + clone_target = object.class.find(object.copy_id) rescue nil if clone_target.nil? + else + clone_target = object if clone_target.nil? + new_object = object.dup + end + return if self.except_clone_relations.to_s.include?(new_object.class.to_s.underscore) + @records_all["#{new_object.class.to_s.underscore.singularize}_ids"] = {} if @records_all["#{new_object.class.to_s.underscore.singularize}_ids"].nil? + begin + @records_all["#{new_object.class.to_s.underscore.singularize}_ids"][clone_target.id] = object.id + rescue + nil + end + if !clone_target.nil? && !new_object.nil? + initialize_fields = ["uid","created_at","updated_at"] + initialize_fields.each do |f| + new_object.send("#{f}=",nil) if new_object.fields.keys.include?(f) + end + relations_fields = clone_target.relations.except("impressions").keys + all_fields = clone_target.fields.keys - relations_fields + all_fields = all_fields - relations_fields.map{|k| "#{k}_id"} + all_fields = all_fields - relations_fields.map{|k| "#{k.singularize}_ids"} + new_object_class_name = new_object.class.to_s.underscore + relations_fields = clone_target.relations.except("impressions").keys + unsort_relation_keys = clone_target.relations.keys + unless @parent_level + fields_to_delete = [new_object_class_name] + tmp_relations_fields = [new_object_class_name] + while relations_fields.count > 0 + tmp_singularize_relations_fields = tmp_relations_fields.map{|f| f.singularize} + approve_append = nil + relations_fields.each do |k| + belongs_to_class = clone_target.relations[k].class_name.constantize.relations.select{|k,v| v.macro == :belongs_to}.keys + has_many_class = clone_target.relations[k].class_name.constantize.relations.select{|k,v| v.macro == :has_many}.keys + if (belongs_to_class - tmp_singularize_relations_fields).count == 0 + other_has_many_class = (has_many_class - unsort_relation_keys) + if other_has_many_class.count == 0 + tmp_relations_fields << k + else + result = other_has_many_class.map do |k| + belongs_to_class = k.classify.constantize.relations.select{|kk,v| v.macro == :belongs_to}.keys + has_many_class = k.classify.constantize.relations.select{|kk,v| v.macro == :has_many}.keys + if (belongs_to_class - tmp_singularize_relations_fields).count == 0 + true + else + fields_to_delete = fields_to_delete.concat(belongs_to_class) + tmp_relations_fields.concat(belongs_to_class) + false + end + end + if result.select{|t| !t}.count == 0 + if (fields_to_delete.map{|f| f.pluralize} - tmp_relations_fields).count == 0 + tmp_relations_fields << k + elsif clone_target.relations[k].class_name.constantize.fields.keys.include?("key") + tmp_relations_fields << k + elsif (clone_target.relations[k].class_name.constantize.relations.keys.map{|f| f.singularize} & fields_to_delete).count != 0 + approve_append = k + end + end + end + elsif !unsort_relation_keys.include?(clone_target.relations[k].class_name.underscore) && !unsort_relation_keys.include?(clone_target.relations[k].class_name.underscore.pluralize) tmp_relations_fields << k - else - result = other_has_many_class.map do |k| - belongs_to_class = k.classify.constantize.relations.select{|kk,v| v.macro == :belongs_to}.keys - has_many_class = k.classify.constantize.relations.select{|kk,v| v.macro == :has_many}.keys - if (belongs_to_class - tmp_singularize_relations_fields).count == 0 - true - else - fields_to_delete = fields_to_delete.concat(belongs_to_class) - tmp_relations_fields.concat(belongs_to_class) - false - end - end - if result.select{|t| !t}.count == 0 - if (fields_to_delete.map{|f| f.pluralize} - tmp_relations_fields).count == 0 - tmp_relations_fields << k - elsif clone_target.relations[k].class_name.constantize.fields.keys.include?("key") - tmp_relations_fields << k - elsif (clone_target.relations[k].class_name.constantize.relations.keys.map{|f| f.singularize} & fields_to_delete).count != 0 - approve_append = k - end - end end - elsif !unsort_relation_keys.include?(clone_target.relations[k].class_name.underscore) && !unsort_relation_keys.include?(clone_target.relations[k].class_name.underscore.pluralize) - tmp_relations_fields << k + end + tmp_relations_fields << approve_append if approve_append.present? + approve_append = nil + relations_fields = relations_fields - tmp_relations_fields + end + relations_fields = tmp_relations_fields + fields_to_delete.each{|f| relations_fields.delete(f)} + @clone_mode = clone_mode + end + @parent_level = true + if clone_mode + all_fields.each do |f| + next if f == "uid" + unless new_object.send("#{f}_changed?") && new_object.send("#{f}_changed_from_default?") + new_object.send("#{f}=",clone_target.send(f)) end end - tmp_relations_fields << approve_append if approve_append.present? - approve_append = nil - relations_fields = relations_fields - tmp_relations_fields end - relations_fields = tmp_relations_fields - fields_to_delete.each{|f| relations_fields.delete(f)} - @clone_mode = clone_mode - end - @parent_level = true - if clone_mode - all_fields.each do |f| - next if f == "uid" - unless new_object.send("#{f}_changed?") && new_object.send("#{f}_changed_from_default?") - new_object.send("#{f}=",clone_target.send(f)) + relations_fields.each do |f| + no_dup_flag = false + if clone_target.relations[f].macro == :belongs_to || clone_target.relations[f].macro == :has_one + no_dup_flag = new_object.send(f).present? + elsif clone_target.relations[f].macro == :has_many + no_dup_flag = new_object.send(f).to_a.count != 0 end - end - end - relations_fields.each do |f| - no_dup_flag = false - if clone_target.relations[f].macro == :belongs_to - no_dup_flag = new_object.send(f).present? - elsif clone_target.relations[f].macro == :has_many - no_dup_flag = new_object.send(f).to_a.count != 0 - end - if clone_target.relations[f].macro == :belongs_to || clone_target.relations[f].class_name == "MemberProfile" - if @records_all["#{f}_ids"].nil? - new_object.send("#{f}_id=",clone_target.send("#{f}_id")) - else - new_object.send("#{f}_id=",(@records_all["#{f}_ids"][clone_target.send("#{f}_id")])) - end - elsif clone_target.relations[f].macro == :has_many - next if self.except_clone_relations.to_s.include?(f) - clone_relations = [] - need_clone_relations = clone_target.send(f).asc(:_id).to_a - file_flag = false - need_clone_relations.each_with_index do |r,i| - clone_relation = new_object.send(f)[i] - clone_relation = r.dup if clone_relation.nil? + if clone_target.relations[f].macro == :belongs_to || clone_target.relations[f].class_name == "MemberProfile" + if @records_all["#{f}_ids"].nil? + new_object.send("#{f}_id=",clone_target.send("#{f}_id")) + else + new_object.send("#{f}_id=",(@records_all["#{f}_ids"][clone_target.send("#{f}_id")])) + end + elsif clone_target.relations[f].macro == :has_one + next if self.except_clone_relations.to_s.include?(f) + need_clone_relation = clone_target.send(f) + clone_relation = new_object.send(f) + clone_relation = need_clone_relation.dup if clone_relation.nil? initialize_fields.each do |f| clone_relation.send("#{f}=",nil) if clone_relation.fields.keys.include?(f) end @@ -425,28 +429,76 @@ def clone_new_for_object(object,clone_target=nil,clone_mode=false) file_flag = true end end - clone_relations << clone_relation - end - if !no_dup_flag || (no_dup_flag && file_flag) - new_object_relations = new_object.send(f).to_a - if new_object_relations.count != 0 - if clone_relations.count > new_object_relations.count - clone_relations = clone_relations[0...new_object_relations.count] - else - clone_relations = clone_relations.concat(new_object.send(f)[clone_relations.count...new_object_relations.count]) + new_object.send("#{f}=",clone_relation) + elsif clone_target.relations[f].macro == :has_many + next if self.except_clone_relations.to_s.include?(f) + clone_relations = [] + need_clone_relations = clone_target.send(f).asc(:_id).to_a + file_flag = false + need_clone_relations.each_with_index do |r,i| + clone_relation = new_object.send(f)[i] + clone_relation = r.dup if clone_relation.nil? + initialize_fields.each do |f| + clone_relation.send("#{f}=",nil) if clone_relation.fields.keys.include?(f) end - new_object.send("#{f}=",clone_relations) - else - new_object.send("#{f}=",clone_relations) + check_fields = clone_relation.fields.except(initialize_fields) + check_fields.keys.each do |f| + if (clone_relation.send(f).class.to_s.match(/uploader/i) rescue false) + if clone_relation[f].blank? && (clone_relation.send(f).file.nil? rescue true) + clone_relation[f] = r[f] + source_filepath = r.send(f).file.file + if @clone_mode + dest_filepath = clone_relation.send(f).file.file + FileUtils.mkdir_p(File.dirname(dest_filepath)) + FileUtils.cp(source_filepath,dest_filepath) + end + elsif (clone_relation.send(f).file rescue nil) + clone_relation[f] = File.basename(clone_relation.send(f).file.file.to_s) + end + file_flag = true + end + end + clone_relations << clone_relation + end + if !no_dup_flag || (no_dup_flag && file_flag) + new_object_relations = new_object.send(f).to_a + if new_object_relations.count != 0 + if clone_relations.count > new_object_relations.count + clone_relations = clone_relations[0...new_object_relations.count] + else + clone_relations = clone_relations.concat(new_object.send(f)[clone_relations.count...new_object_relations.count]) + end + new_object.send("#{f}=",clone_relations) + else + new_object.send("#{f}=",clone_relations) + end + end + count_array = (0...new_object.send(f).to_a.count).to_a + count_array.each do |i| + clone_new_for_object(new_object.send(f)[i],need_clone_relations[i],true) end end - count_array = (0...new_object.send(f).to_a.count).to_a - count_array.each do |i| - clone_new_for_object(new_object.send(f)[i],need_clone_relations[i],true) - end end + new_object.copy_id = clone_target.id if new_object.fields.keys.include?("copy_id") + return new_object, clone_target end - new_object.copy_id = clone_target.id if new_object.fields.keys.include?("copy_id") - return new_object, clone_target + end + def fix_old_data + unless self.update_old_flag + self.seminar_signups.each do |ss| + ss.final_sessions = Array(ss.final_session) + ss.seminar_session_ids = Array(ss.seminar_session_id) + if ss.final_session + ss.seminar_signup_contributes.update_all(:final_session=>final_session) + SeminarSubmissionValue.where(:seminar_signup_contribute_id.in=> ss.seminar_signup_contributes.pluck(:id)).each{|ssv| ssv.save} + end + ss.save + end + self.seminar_sessions.each{|ss| ss.fix_seminar_signup_contribute_ids} + self.update(:update_old_flag=>true) + end + end + def enable_review_result + self.assign_mode == 2 end end \ No newline at end of file diff --git a/app/models/seminar_review.rb b/app/models/seminar_review.rb index 1f98da5..14d52e9 100644 --- a/app/models/seminar_review.rb +++ b/app/models/seminar_review.rb @@ -10,6 +10,8 @@ class SeminarReview field :reviewer_id field :seminar_signup_ids, :type => Array, :default => [] field :remove_seminar_signup_ids, :type => Array, :default => [] + field :seminar_signup_contribute_ids, :type => Array, :default => [] + field :remove_seminar_signup_contribute_ids, :type => Array, :default => [] field :default_seminar_signup_ids, :type => Array, :default => [] field :default_topics, :type => Array, :default => [] field :default_topics_values, :type => Array, :default => [] @@ -72,9 +74,11 @@ class SeminarReview MemberProfile.find(self.reviewer_id) rescue nil end def get_all_seminar_signup_ids(mode = nil) - if (self.default_topics.include?("seminar_signup_contributes.description") && self.seminar_main.assign_mode == 1) || mode == 1 + if (self.default_topics.include?("seminar_signup_contributes.description") && self.seminar_main.assign_mode != 0) || mode != 0 final_assign_signup_ids = SeminarSession.where(:id.in=>self.seminar_session_ids).pluck(:seminar_signup_ids).flatten.map{|id| id.to_s} rescue [] - result = final_assign_signup_ids + self.seminar_signup_ids - self.remove_seminar_signup_ids + default_seminar_signup_ids = SeminarSession.where(:id.in=>self.seminar_session_ids).pluck(:default_seminar_signup_ids).flatten + default_seminar_signup_ids = SeminarSignup.where(:seminar_session_id=>nil,:id.in=>default_seminar_signup_ids).pluck(:id).map{|id| id.to_s} rescue [] + result = final_assign_signup_ids + default_seminar_signup_ids + self.seminar_signup_ids - self.remove_seminar_signup_ids result = result.uniq else result = all_seminar_signup_ids @@ -91,4 +95,24 @@ class SeminarReview self.default_seminar_signup_ids << sid end end + def fix_assign + seminar_signups = SeminarSignup.where(:id.in=>self.seminar_signup_ids) + self.seminar_signup_ids = seminar_signups.pluck(:id).map{|id| id.to_s} + seminar_signups = seminar_signups.to_a + self.seminar_signup_contribute_ids = seminar_signups.map{|ss| ss.seminar_signup_contribute_ids}.flatten.map{|id| id.to_s} + + remove_seminar_signups = SeminarSignup.where(:id.in=>self.remove_seminar_signup_ids) + self.remove_seminar_signup_ids = remove_seminar_signups.pluck(:id).map{|id| id.to_s} + remove_seminar_signups = remove_seminar_signups.to_a + self.remove_seminar_signup_contribute_ids = remove_seminar_signups.map{|ss| ss.seminar_signup_contribute_ids}.flatten.map{|id| id.to_s} + + self.save + end + def clear_all_assign + self.seminar_signup_ids = [] + self.remove_seminar_signup_ids = [] + self.seminar_signup_contribute_ids = [] + self.remove_seminar_signup_contribute_ids = [] + self.save + end end diff --git a/app/models/seminar_review_result.rb b/app/models/seminar_review_result.rb new file mode 100644 index 0000000..2d69a8f --- /dev/null +++ b/app/models/seminar_review_result.rb @@ -0,0 +1,17 @@ +class SeminarReviewResult + + include Mongoid::Document + include Mongoid::Timestamps + PRESENTATION_TYPES = ["oral" , "poster"] + field :sort_number , type: Integer , default: -1 + field :abstract_number , type: String , default: "" + field :presentation_type , type: String , default: "" #oral , poster + belongs_to :seminar_signup_contribute + before_save do + self.sort_number = self.abstract_number.match(/[-]{0,1}\d+/)[0].to_i rescue -1 + end + after_save do + SeminarSignupContribute.where(:id=>self.seminar_signup_contribute_id).update_all(:sort_number=>self.sort_number,:abstract_number=>self.abstract_number,:presentation_type=>self.presentation_type) + SeminarSignup.where(:id.in=>SeminarSignupContribute.where(:id=>self.seminar_signup_contribute_id).pluck(:seminar_signup_id)).update_all(:sort_number=>self.sort_number) + end +end \ No newline at end of file diff --git a/app/models/seminar_session.rb b/app/models/seminar_session.rb index c31521e..883cbca 100644 --- a/app/models/seminar_session.rb +++ b/app/models/seminar_session.rb @@ -7,7 +7,14 @@ class SeminarSession field :key belongs_to :seminar_main field :seminar_signup_ids, :type => Array, :default => [] + field :seminar_signup_contribute_ids, :type => Array, :default => [] + field :default_seminar_signup_ids, :type => Array, :default => [] def seminar_signups - SeminarSignup.where(:id.in=>seminar_signup_ids) + SeminarSignup.any_of({:id.in=>self.seminar_signup_ids},{:preferred_sessions=>self.key,:seminar_session_ids.in=>[[],nil]}) + end + def fix_seminar_signup_contribute_ids + @seminar_signup_ids = SeminarSignup.where(:id.in=>self.seminar_signup_ids).pluck(:id).map{|id| id.to_s} + self.seminar_signup_contribute_ids = SeminarSignupContribute.where(:seminar_signup_id.in=>@seminar_signup_ids).pluck(:id).map{|id| id.to_s} + self.save end end diff --git a/app/models/seminar_signup.rb b/app/models/seminar_signup.rb index 5bfa754..89ab028 100644 --- a/app/models/seminar_signup.rb +++ b/app/models/seminar_signup.rb @@ -4,6 +4,8 @@ class SeminarSignup include Mongoid::Document include Mongoid::Timestamps + field :sort_number , type: Integer, default: 10000 + field :status field :name # become Last Name for TICC field :tel, type: String # become First Name for TICC @@ -15,15 +17,18 @@ class SeminarSignup field :password field :note, localize: true field :serial_number - field :final_session + field :final_session #only store old data , not used + field :final_sessions + field :preferred_sessions, type: Array, default: [] belongs_to :seminar_main - field :seminar_session_id + field :seminar_session_id #only store old data , not used + field :seminar_session_ids, type: Array, default: [] has_many :seminar_signup_values, :autosave => true, :dependent => :destroy has_many :seminar_signup_contributes, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :seminar_signup_values, allow_destroy: true accepts_nested_attributes_for :seminar_signup_contributes, allow_destroy: true - scope :sort_ordered, ->{ order_by(:created_at=>1) } + scope :sort_ordered, ->{ order_by(:sort_number=>1,:created_at=>1) } before_create do unit = self.unit_translations.values.select{|v| v.present?}.first @@ -64,4 +69,8 @@ class SeminarSignup def display_format_string(num, str_length) return format("%0#{str_length}d", num) end + def set_preferred_sessions + self.preferred_sessions = self.seminar_signup_contributes.pluck(:preferred_session) + self.save + end end diff --git a/app/models/seminar_signup_contribute.rb b/app/models/seminar_signup_contribute.rb index b282142..6ebb194 100644 --- a/app/models/seminar_signup_contribute.rb +++ b/app/models/seminar_signup_contribute.rb @@ -4,10 +4,40 @@ class SeminarSignupContribute include Mongoid::Timestamps field :title + field :abstract_number , type: String , default: "" + field :presentation_type , type: String , default: "" + field :sort_number , type: Integer, default: 10000 mount_uploader :file, AssetUploader field :description - + field :preferred_session + field :final_session belongs_to :seminar_signup + has_one :seminar_review_result, dependent: :destroy + accepts_nested_attributes_for :seminar_review_result has_many :seminar_submission_values, autosave: true, dependent: :destroy accepts_nested_attributes_for :seminar_submission_values, :allow_destroy => true + scope :sort_ordered, ->{ order_by(:sort_number=>1,:created_at=>1) } + after_destroy do + seminar_signup = self.seminar_signup.reload rescue nil + seminar_signup_id = seminar_signup.id.to_s + seminar_submission_field_ids = seminar_signup.seminar_main.seminar_submission_fields.where(:markup=>"seminar_preferred_session").pluck(:id) rescue [] + if seminar_signup && seminar_submission_field_ids.count != 0 + seminar_signup_contribute_ids = seminar_signup.seminar_signup_contributes.pluck(:id) + seminar_submission_values = SeminarSubmissionValue.where(:seminar_signup_contribute_id.in=>seminar_signup_contribute_ids,:seminar_submission_field_id.in=>seminar_submission_field_ids).to_a + seminar_sessions = seminar_signup.seminar_main.seminar_sessions.to_a + seminar_sessions.each do |ss| + ss.default_seminar_signup_ids.delete(seminar_signup_id) + ss.save(:validate=>false) + end + seminar_submission_value = seminar_submission_values.last + val = seminar_submission_value["val"].to_i rescue nil + unless val.nil? + seminar_session = seminar_sessions.select{|ss| ss.key == val}.first + if seminar_session + seminar_session.default_seminar_signup_ids << seminar_signup_id + seminar_session.save(:validate=>false) + end + end + end + end end \ No newline at end of file diff --git a/app/models/seminar_signup_field.rb b/app/models/seminar_signup_field.rb index ca6c3fb..60ff2d1 100644 --- a/app/models/seminar_signup_field.rb +++ b/app/models/seminar_signup_field.rb @@ -22,7 +22,7 @@ class SeminarSignupField field :typeC, type: Hash, default: {calendar: "west_calendar", format: "format3"} field :typeD, type: Hash, default: {cross_lang: false} field :typeE, type: Hash, default: {} - + field :typeF, type: Hash, default: {} belongs_to :seminar_main has_many :seminar_signup_values, autosave: true, dependent: :destroy accepts_nested_attributes_for :seminar_signup_values, :allow_destroy => true @@ -71,7 +71,7 @@ class SeminarSignupField end def panel - panel = LIST[:markups][self[:markup]]["panel"] + panel = $seminar_list[:markups][self[:markup]]["panel"] end def get_data diff --git a/app/models/seminar_submission_field.rb b/app/models/seminar_submission_field.rb index 07e8e5a..cd6968d 100644 --- a/app/models/seminar_submission_field.rb +++ b/app/models/seminar_submission_field.rb @@ -22,7 +22,7 @@ class SeminarSubmissionField field :typeC, type: Hash, default: {calendar: "west_calendar", format: "format3"} field :typeD, type: Hash, default: {cross_lang: false} field :typeE, type: Hash, default: {} - + field :typeF, type: Hash, default: {cross_lang: "true"} belongs_to :seminar_main has_many :seminar_submission_values, autosave: true, dependent: :destroy accepts_nested_attributes_for :seminar_submission_values, :allow_destroy => true @@ -96,7 +96,7 @@ class SeminarSubmissionField end def panel - panel = LIST[:markups][self[:markup]]["panel"] + panel = $seminar_list[:markups][self[:markup]]["panel"] end def get_data diff --git a/app/models/seminar_submission_value.rb b/app/models/seminar_submission_value.rb index 5119fce..46b7989 100644 --- a/app/models/seminar_submission_value.rb +++ b/app/models/seminar_submission_value.rb @@ -6,12 +6,34 @@ class SeminarSubmissionValue include ::Admin::SeminarsValuesHelper field :key, type: String - + field :val belongs_to :seminar_submission_field belongs_to :seminar_signup_contribute before_save :check_key before_save :data_proc - + after_save do + if (self.seminar_submission_field.markup == "seminar_preferred_session" rescue false) + val_change = self.val_change + self.seminar_signup_contribute.update(:preferred_session=>val.to_i) + self.seminar_signup_contribute.seminar_signup.set_preferred_sessions + unless val_change.nil? + old_val = val_change[0] + new_val = val_change[1] + seminar_signup_id = self.seminar_signup_contribute.seminar_signup_id.to_s + seminar_sessions = self.seminar_submission_field.seminar_main.seminar_sessions.to_a + old_seminar_session = seminar_sessions.select{|ss| ss.key.to_s == old_val}.first + if old_seminar_session + old_seminar_session.default_seminar_signup_ids.delete seminar_signup_id + old_seminar_session.save + end + new_seminar_session = seminar_sessions.select{|ss| ss.key.to_s == new_val}.first + if new_seminar_session + new_seminar_session.default_seminar_signup_ids << seminar_signup_id + new_seminar_session.save + end + end + end + end def add_more_counter index_max = self["val"].count rescue 0 index_max == 0 ? 1 : index_max @@ -26,7 +48,7 @@ class SeminarSubmissionValue else self.seminar_submission_field.get_data["cross_lang"] =="true" ? self["val"] : Hash[site.valid_locales.collect{|lang| [lang,self[lang.to_sym]]}] end - when 'select','radio_button','address' + when 'select','radio_button','address','seminar_preferred_session' self["val"] when 'date' if !self["val"].blank? and !self["val"]['(1i)'].blank? @@ -54,6 +76,8 @@ class SeminarSubmissionValue end elsif (seminar_submission_field.markup.eql?("select") || seminar_submission_field.markup.eql?("radio_button")) field_value = seminar_submission_field.markup_value["#{self.value}"][I18n.locale] rescue nil + elsif seminar_submission_field.markup.eql?("seminar_preferred_session") + field_value = seminar_submission_field.seminar_main.summary_chioices[self.value.to_i] rescue nil elsif seminar_submission_field.markup.eql?("address") field_value = rf[:address_key][I18n.locale].map{|k,v| v}.delete_if(&:blank?).join(', ') elsif seminar_submission_field.markup.eql?("date") @@ -129,7 +153,8 @@ class SeminarSubmissionValue when "radio_button" markup_values = seminar_submission_field.markup_value markup_values[self.value][locale.to_s] - + when "seminar_preferred_session" + seminar_submission_field.seminar_main.summary_chioices[self.value.to_i] rescue nil when "checkbox" markup_values = seminar_submission_field.markup_value self.value.collect{|key| markup_values["#{key}"][I18n.locale]}.join(",") @@ -195,7 +220,7 @@ end end end # of self.seminar_submission_field.add_more - when 'select','date','radio_button' + when 'select','date','radio_button','seminar_preferred_session' self["val"] = self[:temp_data] when 'checkbox' self["val"] = self[:temp_data].keys diff --git a/app/views/admin/seminar_review_results/edit.html.erb b/app/views/admin/seminar_review_results/edit.html.erb new file mode 100644 index 0000000..8839c84 --- /dev/null +++ b/app/views/admin/seminar_review_results/edit.html.erb @@ -0,0 +1,132 @@ + +<%= form_for @seminar_signup_contribute, url: admin_seminar_review_result_path(@seminar_signup_contribute), html: {class: "form-horizontal main-forms"} do |f| %> + <% seminar_signup = @seminar_signup_contribute.seminar_signup %> + <% referer_url = request.referer %> +
+ <% render :partial => "admin/seminars/get_display_fields" %> + <% @field_name_translations.each_with_index do |trans,i|%> + <% next unless @display_field.include?(@field_names[i]) %> +
+
<%=trans%>
+
+ <% val = "" %> + <% names = @field_names[i].split(".") %> + <% if names[0] == "seminar_signup_field_set" %> + <% if names[1] == "name" %> + <% val = seminar_signup.name %> + <% elsif names[1] == 'status' %> + <% val = t("seminar.registration_status_#{seminar_signup.status}") if !seminar_signup.status.blank? %> + <% elsif names[1] != 'recaptcha' %> + <% val = seminar_signup.send("#{names[1]}") %> + <% end %> + <% elsif names[0] == "default" %> + <% if names[2] == "name" %> + <% val = seminar_signup.name %> + <% elsif names[2] == "tel" %> + <% val = seminar_signup.tel %> + <% elsif names[2] == "registration_status" %> + <% val = t("seminar.registration_status_#{seminar_signup.status}") if !seminar_signup.status.blank? %> + <% end %> + <% elsif names[0] == "seminar_signup_field_custom" || names[0] == "seminar_signup_fields" %> + <% val = seminar_signup.seminar_signup_values.where(:key=>names[1]).first.get_value_by_locale(I18n.locale) rescue "" %> + <% elsif names[0] == "seminar_signup_contributes" %> + <% if names[1] == "file" %> + <% seminar_signup_contribute = @seminar_signup_contribute %> + <% description = seminar_signup_contribute.description.to_s %> + <% if @seminar.enable_summary_choice + if (seminar_signup_contribute.description.to_s.to_i.to_s == seminar_signup_contribute.description) + description = @seminar.summary_chioices[seminar_signup_contribute.description.to_i] rescue seminar_signup_contribute.description + else + description = seminar_signup_contribute.description.map{|i| @seminar.summary_chioices[i.to_i] rescue "" }.join("
") rescue seminar_signup_contribute.description + end + end %> + <% file_path = seminar_signup_contribute.file.path %> + <% file_title = (seminar_signup_contribute.title.blank? ? File.basename(seminar_signup_contribute.file.path) : seminar_signup_contribute.title) %> + <% file_url = seminar_signup_contribute.file.url %> + <% file_extname = File.extname(file_path) %> + <% if (file_extname.match(/pdf/i) rescue false) %> + <% val = " + #{file_title} + + " %> + <% elsif (file_extname.match(/(jpg|jpeg|png|gif|bmp)/i) rescue false) %> + <% val = "" %> + <% else %> + <% file_content = File.read(file_path) rescue "" %> + <% if file_content.is_utf8? %> + <% file_content = file_content.gsub(/(\r\n|\n)/,"
")%> + <% val = "
#{t(:download)}

#{file_title}

#{file_content}
"%> + <% else %> + <% val = link_to( file_title, file_url , {:target => '_blank', :title => Nokogiri::HTML(description.gsub("
"," , ")).text} ) if seminar_signup_contribute.file.file %> + <% end %> + <% end %> + <% else %> + <% if names[1] == "description" %> + <% description = @seminar_signup_contribute.send(names[1]) %> + <% if @seminar.enable_summary_choice + if (description.to_s.to_i.to_s == description) + description = @seminar.summary_chioices[description.to_i] rescue description + else + description = description.map{|i| @seminar.summary_chioices[i.to_i] rescue "" }.join("
") rescue description + end + end %> + <% val = description %> + <% else %> + <% val = @seminar_signup_contribute.send(names[1]).to_s %> + <% end %> + <% end %> + <% elsif names[0] == "seminar_submission_fields" %> + <% val = @seminar_signup_contribute.seminar_submission_values.where(:key=>names[1]).first.get_value_by_locale(I18n.locale) rescue "" %> + <% seminar_submission_field = seminar_signup.seminar_main.seminar_submission_fields.where(:key=>names[1]).first %> + <% if seminar_submission_field && seminar_submission_field.markup == "seminar_preferred_session" + seminar_submission_value = @seminar_signup_contribute.seminar_submission_values.where(:key=>names[1]).first + val = "#{(seminar_submission_value.get_value_by_locale(I18n.locale) rescue "")}" + end %> + <% elsif names[0] == "seminar_signup" %> + <% val = (seminar_signup.send("display_"+names[1]) rescue seminar_signup.send(names[1])) rescue nil %> + <% elsif names[0] == "seminar_review_result" %> + <% val = @seminar_signup_contribute.send(names[1]) rescue "" %> + <% end %> + <%= val.html_safe %> +
+
+ <% end %> + +
+ <%= f.fields_for :seminar_review_result,@seminar_review_result do |f| %> +
+ <%= f.label :abstract_number,:class=>"control-label" %> +
<%= f.text_field :abstract_number %>
+
+
+ <%= f.label :presentation_type,:class=>"control-label" %> +
+ <% SeminarReviewResult::PRESENTATION_TYPES.each do |v| %> + + <% end %> +
+
+ <% end %> +
+ <%= hidden_field_tag :referer_url, referer_url %> + +
+ <%= f.submit t('submit'), class: 'btn btn-primary' %> + <%= link_to t('cancel'), referer_url, :class=>"btn" %> +
+
+<% end %> \ No newline at end of file diff --git a/app/views/admin/seminar_submission_values/edit.html.erb b/app/views/admin/seminar_submission_values/edit.html.erb new file mode 100644 index 0000000..65d6101 --- /dev/null +++ b/app/views/admin/seminar_submission_values/edit.html.erb @@ -0,0 +1,5 @@ +<%= form_for @seminar_submission_value, url: admin_seminar_submission_value_path(@seminar_submission_value), html: {class: "form-horizontal main-forms",id: "jquery_form"} do |f| %> +
+ <%= @seminar_submission_field.block_helper(@seminar,0,false,"seminar_signup_contribute",@con, @seminar_submission_field.to_require,@seminar_submission_field) %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/seminars/_attribute_field.html.erb b/app/views/admin/seminars/_attribute_field.html.erb index bf3ceb7..c71dd8a 100644 --- a/app/views/admin/seminars/_attribute_field.html.erb +++ b/app/views/admin/seminars/_attribute_field.html.erb @@ -39,7 +39,8 @@
> - <%LIST[:markups].each do |key,val|%> + <%$seminar_list[:markups].each do |key,val|%> + <% next if val["display_only"] && val["display_only"] != "seminar_submission_field" %> <% if key != 'address' %> <% end %> @@ -51,7 +52,7 @@
- <%= content_tag :div,:class=>"field-type default fade in #{show_type_panel(attribute_submission_field,"typeA")}" do%> + <%= content_tag :div,:class=>"field-type default fade in #{show_seminar_type_panel(attribute_submission_field,"typeA")}" do%>
@@ -66,9 +67,9 @@
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_submission_field["typeA"]["placeholder"],:field_name=>"#{@field_name}[seminar_submission_fields][#{@af_counter}][typeA][placeholder]"}%> - <% end if show_type_panel(attribute_submission_field,"typeA") != 'typeA hide' %> + <% end if show_seminar_type_panel(attribute_submission_field,"typeA") != 'typeA hide' %> - <%= content_tag :div,:class=>"field-type default fade in #{show_type_panel(attribute_submission_field,"typeB")}" do %> + <%= content_tag :div,:class=>"field-type default fade in #{show_seminar_type_panel(attribute_submission_field,"typeB")}" do %> <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:label_ext=>t(:initial),:values=>attribute_submission_field["typeB"]["initial"],:field_name=>"#{@field_name}[seminar_submission_fields][#{@af_counter}][typeB][initial]"}%> <% if attribute_submission_field.self_defined_markup_options?%> @@ -77,9 +78,9 @@ <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_submission_field["option_list"],:field_name=> "#{@field_name}[seminar_submission_fields][#{@af_counter}][typeB][option_list]"} %> <% end #of self_defined_markup_options?%> - <% end if show_type_panel(attribute_submission_field,"typeB") != 'typeB hide' %> + <% end if show_seminar_type_panel(attribute_submission_field,"typeB") != 'typeB hide' %> - <%= content_tag :div,:class=>"field-type default fade in #{show_type_panel(attribute_submission_field,"typeC")}" do %> + <%= content_tag :div,:class=>"field-type default fade in #{show_seminar_type_panel(attribute_submission_field,"typeC")}" do %>
@@ -108,9 +109,9 @@
- <% end if show_type_panel(attribute_submission_field,"typeC") != 'typeC hide' %> + <% end if show_seminar_type_panel(attribute_submission_field,"typeC") != 'typeC hide' %> - <%= content_tag :div,:class=>"field-type default fade in #{show_type_panel(attribute_submission_field,"typeD")}" do%> + <%= content_tag :div,:class=>"field-type default fade in #{show_seminar_type_panel(attribute_submission_field,"typeD")}" do%>
@@ -121,12 +122,23 @@
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:field_name=>"#{@field_name}[seminar_submission_fields][#{@af_counter}][typeD][placeholder]",:values=>attribute_submission_field["typeD"]["placeholder"]} %> - <% end if show_type_panel(attribute_submission_field,"typeD") != 'typeD hide' %> + <% end if show_seminar_type_panel(attribute_submission_field,"typeD") != 'typeD hide' %> - <%= content_tag :div,:class=>"field-type default fade in #{show_type_panel(attribute_submission_field,"typeE")}" do%> + <%= content_tag :div,:class=>"field-type default fade in #{show_seminar_type_panel(attribute_submission_field,"typeE")}" do%> <%= render :partial=>"shared/attribute_field/list_block",:locals=>{:field_name=>"#{@field_name}[seminar_submission_fields][#{@af_counter}][typeE][option_list]",:values=>attribute_submission_field["typeE"]["option_list"]}%> - <% end if show_type_panel(attribute_submission_field,"typeE") != 'typeE hide' %> - + <% end if show_seminar_type_panel(attribute_submission_field,"typeE") != 'typeE hide' %> + <%= content_tag :div,:class=>"field-type default fade in #{show_seminar_type_panel(attribute_submission_field,"typeF")}" do%> +
+ +
+ <% if @attribute.enable_summary_choice %> + <% @attribute.summary_chioices.each do |v| %> +
<%=v%>
+ <% end %> + <% end %> +
+
+ <% end if show_seminar_type_panel(attribute_submission_field,"typeF") != 'typeF hide' %> <%= hidden_field "#{@field_name}[seminar_submission_fields][#{@af_counter}]","id",:value=>attribute_submission_field.id%>
\ No newline at end of file diff --git a/app/views/admin/seminars/_get_display_fields.html.erb b/app/views/admin/seminars/_get_display_fields.html.erb index f66e307..8c4ebb9 100644 --- a/app/views/admin/seminars/_get_display_fields.html.erb +++ b/app/views/admin/seminars/_get_display_fields.html.erb @@ -61,12 +61,29 @@ <% @field_name_translations << t('seminar_signup.description') %> <% @seminar.seminar_submission_fields.each do |s| %> <% @field_names << "seminar_submission_fields.#{s.key}" %> - <% @field_name_translations << s.title %> + <% if s.markup != "seminar_preferred_session" + @field_name_translations << s.title + else + @field_name_translations << t("seminar.assigned_session") + end %> <% end %> - <% @display_field = @seminar_signup_admin_setting.display_field %> + <% @display_field = @seminar_signup_admin_setting.display_field rescue [] %> <% if @display_field.blank? - @display_field = @field_names - default_hidden + @display_field = @field_names - default_hidden end %> + <% if @enable_review_result + @field_names.insert(1,"seminar_review_result.review") + @field_name_translations.insert(1,t("seminar.review")) + @display_field.insert(1,"seminar_review_result.review") + + @field_names << "seminar_review_result.abstract_number" + @field_name_translations << t("helpers.label.seminar_review_result.abstract_number") + @display_field << "seminar_review_result.abstract_number" + + @field_names << "seminar_review_result.presentation_type" + @field_name_translations << t("helpers.label.seminar_review_result.presentation_type") + @display_field << "seminar_review_result.presentation_type" + end%> <% else %> <% @field_names = [] %> <% @field_name_translations = [] %> diff --git a/app/views/admin/seminars/_seminar_signup_dashboard.html.erb b/app/views/admin/seminars/_seminar_signup_dashboard.html.erb index 571a652..342684e 100644 --- a/app/views/admin/seminars/_seminar_signup_dashboard.html.erb +++ b/app/views/admin/seminars/_seminar_signup_dashboard.html.erb @@ -20,7 +20,10 @@ <% @seminar_signups = SeminarSignup.where(:id.in=>seminar_review.get_all_seminar_signup_ids).sort_ordered %> <% @seminar_signups = @seminar_signups.page(params["page_no#{count}"]).per(5) %> <% @seminar_signups = @seminar_signups.page(0) if @seminar_signups.to_a.count == 0 %> - <%= render :partial => "seminar_signup_render_table",:locals=>{:@seminar_signups=>@seminar_signups,:@drag => true,:@include_blank=>true,:@reviewer_id=>seminar_review.id.to_s} %> + <% org_seminar_signups = org_seminar_signups.where(:id.nin=>@seminar_signups.map{|ss| ss.id})%> + <% @append_contribute_ids = seminar_review.seminar_signup_contribute_ids %> + <% @remove_contribute_ids = seminar_review.remove_seminar_signup_contribute_ids %> + <%= render :partial => "seminar_signup_render_table",:locals=>{:@seminar_signups=>@seminar_signups,:@drag => true,:@include_blank=>true,:@reviewer_id=>seminar_review.id.to_s,:@preferred_sessions=>seminar_review.session_ids} %> <% pagination_html = content_tag :div, class: "bottomnav clearfix", style: "position: static;" do content_tag :div, paginate(@seminar_signups), class: "pagination pagination-centered" @@ -40,6 +43,9 @@ <% @seminar_signups = org_seminar_signups @include_blank = false @reviewer_id = nil + @append_contribute_ids = nil + @remove_contribute_ids = nil + @preferred_sessions = nil %>
@@ -227,16 +233,29 @@ var mode = ""; var id = target.data("id"); var signup_id = ui.item.data("id"); - if(target.find("tr[data-id=\""+signup_id+"\"]").length != 0){ + var contribute_id = ui.item.data("contribute_id"); + var target_filter = "tr[data-id=\""+signup_id+"\"]"; + if(contribute_id){ + target_filter += "[data-contribute_id=\""+contribute_id+"\"]"; + }else if(contribute_id == undefined){ + contribute_id = ""; + } + if(target.find(target_filter).length != 0){ mode = "append"; - if(target.find("tr[data-id=\""+signup_id+"\"]").length > 1){ - var target_signups= target.find("tr[data-id=\""+signup_id+"\"]"); + if(target.find(target_filter).length > 1){ + var target_signups= target.find(target_filter); for(var i=1;i",{id: id,mode: mode,signup_id: signup_id}).done(function(data){ + $.post("<%=admin_seminar_update_seminar_review_path%>",{id: id,mode: mode,signup_id: signup_id,contribute_id: contribute_id}).done(function(data){ }) } } diff --git a/app/views/admin/seminars/_seminar_signup_render_table.html.erb b/app/views/admin/seminars/_seminar_signup_render_table.html.erb index cfc0758..06d63be 100644 --- a/app/views/admin/seminars/_seminar_signup_render_table.html.erb +++ b/app/views/admin/seminars/_seminar_signup_render_table.html.erb @@ -1,4 +1,4 @@ - +
<% render :partial => "get_display_fields" %> @@ -18,12 +18,27 @@ <% display_title = @seminar.nil? %> <% @seminar_signups.each do |seminar_signup| %> <% @seminar = seminar_signup.seminar_main if display_title %> - <% len = seminar_signup.seminar_signup_contributes.count %> - <% rowspan = "rowspan=#{len==0? 1 : len}" %> <% vals = [] %> - + <% edit_urls = {} %> + <% contribute_ids = seminar_signup.seminar_signup_contribute_ids.map{|id| id.to_s} %> + <% @append_contribute_ids = @append_contribute_ids.to_a + @remove_contribute_ids = @remove_contribute_ids.to_a + %> + <% intersection_contribute_ids = @append_contribute_ids & contribute_ids rescue [] %> + <% if intersection_contribute_ids.count != 0 + contribute_ids = intersection_contribute_ids + else + if @preferred_sessions + contribute_ids = seminar_signup.seminar_signup_contributes.any_of({:preferred_session.in=>@preferred_sessions,:final_session=>nil},{:final_session.in=>@preferred_sessions}).pluck(:id).map{|id| id.to_s} + end + end %> + <% contribute_ids = contribute_ids - @remove_contribute_ids + seminar_signup_contributes = seminar_signup.seminar_signup_contributes.where(:id.in=>contribute_ids).sort_ordered.to_a + contribute_ids = seminar_signup_contributes.map{|s| s.id} + %> + <% if @drag%> - + <% end %> <% vals << seminar_signup.seminar_main.title if display_title %> <% @display_field.each_with_index do |fn,i|%> @@ -34,7 +49,7 @@ <% val = seminar_signup.name val += "
    " - if can_edit_or_delete?(seminar_signup) + if @can_edit val += "
  • #{t(:edit)}
  • #{t(:delete_)}
  • " end @@ -51,7 +66,7 @@ <% val = seminar_signup.name val += "
      " - if can_edit_or_delete?(seminar_signup) + if @can_edit val += "
    • #{t(:edit)}
    • #{t(:delete_)}
    • " end @@ -67,10 +82,10 @@ <% val = seminar_signup.seminar_signup_values.where(:key=>names[1]).first.get_value_by_locale(I18n.locale) rescue "" %> <% elsif names[0] == "seminar_signup_contributes" %> <% if names[1] == "file" %> - <% val = seminar_signup.seminar_signup_contributes.to_a %> + <% val = seminar_signup_contributes %> <% else %> <% if names[1] == "description" %> - <% descriptions = seminar_signup.seminar_signup_contributes.collect{|s| s.send(names[1])} %> + <% descriptions = seminar_signup_contributes.collect{|s| s.send(names[1])} %> <% if @seminar.enable_summary_choice descriptions = descriptions.map do |description| if (description.to_s.to_i.to_s == description) @@ -82,13 +97,30 @@ end %> <% val = descriptions %> <% else %> - <% val = seminar_signup.seminar_signup_contributes.collect{|s| s.send(names[1]).to_s} %> + <% val = seminar_signup_contributes.collect{|s| s.send(names[1]).to_s} %> <% end %> <% end %> <% elsif names[0] == "seminar_submission_fields" %> - <% val = seminar_signup.seminar_signup_contributes.collect{|s| (s.seminar_submission_values.where(:key=>names[1]).first.get_value_by_locale(I18n.locale) rescue "")} %> + <% val = seminar_signup_contributes.collect{|s| (s.seminar_submission_values.where(:key=>names[1]).first.get_value_by_locale(I18n.locale) rescue "")} %> + <% seminar_submission_field = seminar_signup.seminar_main.seminar_submission_fields.where(:key=>names[1]).first %> + <% if seminar_submission_field && seminar_submission_field.markup == "seminar_preferred_session" + val = seminar_signup_contributes.collect{|s| + seminar_submission_value = s.seminar_submission_values.where(:key=>names[1]).first + "#{(seminar_submission_value.get_value_by_locale(I18n.locale) rescue "")}"} + edit_urls[i] = [] + seminar_submission_values = seminar_signup_contributes.collect{|s| s.seminar_submission_values.where(:key=>names[1]).first } + edit_urls[i] = seminar_submission_values.map{|seminar_submission_value| edit_admin_seminar_submission_value_path(seminar_submission_value.id) rescue "#"} + end %> <% elsif names[0] == "seminar_signup" %> <% val = (seminar_signup.send("display_"+names[1]) rescue seminar_signup.send(names[1])) rescue nil %> + <% elsif names[0] == "seminar_review_result" %> + <% if names[1] == "review" %> + <% val = contribute_ids.map{|contribute_id| "#{t("seminar.review")}"} %> + <% elsif names[1] == "presentation_type" %> + <% val = seminar_signup_contributes.map{|seminar_signup_contribute| seminar_signup_contribute.presentation_type} %> + <% elsif names[1] == "abstract_number" %> + <% val = seminar_signup_contributes.map{|seminar_signup_contribute| seminar_signup_contribute.abstract_number} %> + <% end %> <% end %> <% vals << val %> <% end %> @@ -113,17 +145,38 @@ <% else %> <%= val[0].html_safe.to_s rescue "" %> <% end %> + <% if edit_urls[i].present? %> +
      + +
      + <% end %> <% else %> -
+ <% end %> <% end %> <% (1...count+1).each do |i|%> - - <% indices.each do |index| %> - + <% if @drag%> + + <% end %> + <% (0...vals.count).each do |index| %> + <% if indices.include?(index) + extra_class= "" + val = vals[index][i] + else + extra_class = "repeated" + val = vals[index] + end %> + <% end %> @@ -153,4 +217,9 @@ <% end %> -
>><%= val.to_s.html_safe %><%= val.to_s.html_safe %>
- <% if vals[index][i].class == SeminarSignupContribute #File %> - <% seminar_signup_contribute = vals[index][i] %> +
+ <% if (val.class == SeminarSignupContribute rescue false) #File %> + <% seminar_signup_contribute = val %> <% description = seminar_signup_contribute.description.to_s %> <% if @seminar.enable_summary_choice if (seminar_signup_contribute.description.to_s.to_i.to_s == seminar_signup_contribute.description) @@ -134,7 +187,18 @@ end %> <%= link_to (seminar_signup_contribute.title.blank? ? File.basename(seminar_signup_contribute.file.path) : seminar_signup_contribute.title) , seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(description.gsub("
"," , ")).text} if seminar_signup_contribute.file.file %> <% else %> - <%= vals[index][i].html_safe.to_s rescue "" %> + <%= val.html_safe.to_s rescue "" %> + <% end %> + <% if (edit_urls[index][i].present? rescue false) %> +
+ +
<% end %>
\ No newline at end of file + + \ No newline at end of file diff --git a/app/views/admin/seminars/_seminar_signup_session_dashboard.html.erb b/app/views/admin/seminars/_seminar_signup_session_dashboard.html.erb index ea7428c..a8563d2 100644 --- a/app/views/admin/seminars/_seminar_signup_session_dashboard.html.erb +++ b/app/views/admin/seminars/_seminar_signup_session_dashboard.html.erb @@ -21,7 +21,7 @@ <% @seminar_signups = seminar_session.seminar_signups.sort_ordered %> <% @seminar_signups = @seminar_signups.page(params["page_no#{count}"]).per(5) %> <% @seminar_signups = @seminar_signups.page(0) if @seminar_signups.to_a.count == 0 %> - <%= render :partial => "seminar_signup_render_table",:locals=>{:@seminar_signups=>@seminar_signups,:@drag => true,:@include_blank=>true,:@reviewer_id=>session_id} %> + <%= render :partial => "seminar_signup_render_table",:locals=>{:@seminar_signups=>@seminar_signups,:@drag => true,:@include_blank=>true,:@reviewer_id=>session_id,:@preferred_sessions=>[session_id.to_i]} %> <% pagination_html = content_tag :div, class: "bottomnav clearfix", style: "position: static;" do content_tag :div, paginate(@seminar_signups), class: "pagination pagination-centered" @@ -38,9 +38,10 @@ <% end %> <% end %>
-<% @seminar_signups = org_seminar_signups +<% @seminar_signups = org_seminar_signups.where(:preferred_sessions.in=>[[],nil]) @include_blank = false @reviewer_id = nil + @preferred_sessions = nil %>
@@ -212,26 +213,39 @@ stop: function(event, ui){ $(".session_block").css("overflow",""); ui.item.css("background",""); - console.log("stop") }, update: function(event, ui) { var target = $(event.target); var mode = ""; var session_id = target.data("id"); var signup_id = ui.item.data("id"); + var contribute_id = ui.item.data("contribute_id"); if(ui.item.parent().data("id") == session_id){ mode = "append"; - }else{ - mode = "remove"; + ui.item.find(".repeated").css("visibility","visible"); + }else if(target.find("tr[data-id=\""+signup_id+"\"]").length != 0){ + mode = "remove_contribute"; + target.find("tr[data-id=\""+signup_id+"\"]").find(".repeated").css("visibility",""); } + else{ + mode = "remove"; + ui.item.find(".repeated").css("visibility",""); + } + if(contribute_id == undefined){ + contribute_id = ""; + } + console.log(mode); if(target.find("tr").not(".blank_tr").length == 0){ target.find(".blank_tr").css("display",""); }else{ target.find(".blank_tr").css("display","none"); } if(session_id != undefined){ - $.post("<%=update_seminar_session_admin_seminar_path(params[:id])%>",{session_id: session_id,mode: mode,signup_id: signup_id}).done(function(data){ + $.post("<%=update_seminar_session_admin_seminar_path(params[:id])%>",{session_id: session_id,mode: mode,signup_id: signup_id, contribute_id: contribute_id}).done(function(data){ console.log(data); + if(data["edit"]){ + $(data["edit"]["target"]).text(data["edit"]["text"]); + } }) } } diff --git a/app/views/admin/seminars/_seminar_signup_table.html.erb b/app/views/admin/seminars/_seminar_signup_table.html.erb index 29387f1..050267b 100644 --- a/app/views/admin/seminars/_seminar_signup_table.html.erb +++ b/app/views/admin/seminars/_seminar_signup_table.html.erb @@ -1,22 +1,30 @@ -
-
- - -
-
+<% if request.xhr? %> +
+ <%= render :partial => "seminar_signup_render_table" %> +
+<% else %> +
+
+ + +
+
+ <%= render :partial => "sessions_filter", :locals =>{:fields => @filter_fields.to_h, :search_dom_id=>"index_table", :quick_new=>false} %> -

<%= @seminar.title %>

+

<%= @seminar.title %>

+
+ <%= render :partial => "seminar_signup_render_table" %> +
-<%= render :partial => "seminar_signup_render_table" %> +
+ + <% if @can_edit %> +
+ <%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t("seminar.field_display_setting"), seminar_signup_admin_setting_admin_seminar_path(params[:id]) + "?page=table", :class => 'btn btn-primary' %> +
+ <% end %> +
-
- - <% if @can_edit %> -
- <%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t("seminar.field_display_setting"), seminar_signup_admin_setting_admin_seminar_path(params[:id]) + "?page=table", :class => 'btn btn-primary' %> -
- <% end %> -
- -<%= render 'layouts/delete_modal', delete_options: @delete_options %> \ No newline at end of file + <%= render 'layouts/delete_modal', delete_options: @delete_options %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/seminars/_sessions_filter.html.erb b/app/views/admin/seminars/_sessions_filter.html.erb new file mode 100644 index 0000000..1a3686b --- /dev/null +++ b/app/views/admin/seminars/_sessions_filter.html.erb @@ -0,0 +1,185 @@ +<% content_for :right_nav do %> + +
+ <% fields.keys.each do |field| %> + <% org_field = field %> + <% field = field.to_s.split(".").last %> +
+
+ <% if fields[org_field].class == String %> + <%= fields[org_field].html_safe %> + <% else %> + <% fields[org_field].each do |val| %> + <%= link_to (val[:title].blank? ? "" : val[:title]), "#", :onclick => "filter.addFilter('filters[#{field}][]=#{val[:id]}');$(this).toggleClass('active');return false;", :class => "btn btn-small #{is_filter_active?(field, val[:id])}", :id => "filter_#{val[:id]}" %> + <% end %> + <% end %> +
+ +
+ <% end %> +
+<% end %> + \ No newline at end of file diff --git a/app/views/admin/seminars/_support_member_form_js.erb b/app/views/admin/seminars/_support_member_form_js.erb index c90efb7..6205f84 100644 --- a/app/views/admin/seminars/_support_member_form_js.erb +++ b/app/views/admin/seminars/_support_member_form_js.erb @@ -52,7 +52,8 @@
diff --git a/app/views/admin/seminars/get_session_block.html.erb b/app/views/admin/seminars/get_session_block.html.erb index 528989b..fd3643e 100644 --- a/app/views/admin/seminars/get_session_block.html.erb +++ b/app/views/admin/seminars/get_session_block.html.erb @@ -2,7 +2,8 @@
<%= @seminar.summary_chioices[@session_id] %>
- - <% @seminar_signups = @seminar.seminar_signups.where(:final_session=>@session_id).sort_ordered %> + <% @seminar_signups = @seminar_session.seminar_signups.sort_ordered %> + <% @preferred_sessions = [@session_id] %> <%= render :partial => "seminar_signup_render_table",:locals=>{:@seminar_signups=>@seminar_signups.page(params[:page]).per(5),:@drag => true,:@include_blank=>true} %> <%= content_tag :div, class: "bottomnav clearfix", style: "position: static;" do diff --git a/app/views/admin/seminars/seminar_signup.html.erb b/app/views/admin/seminars/seminar_signup.html.erb index 439114a..c0a7cd7 100644 --- a/app/views/admin/seminars/seminar_signup.html.erb +++ b/app/views/admin/seminars/seminar_signup.html.erb @@ -1,7 +1,11 @@ - - +
+
+
+
+
<% if @can_edit %> <% if params[:type].blank?%> @@ -30,3 +34,46 @@ list-style: none; } + \ No newline at end of file diff --git a/app/views/seminars/con_upload.html.erb b/app/views/seminars/con_upload.html.erb index 52532ef..44fd22e 100644 --- a/app/views/seminars/con_upload.html.erb +++ b/app/views/seminars/con_upload.html.erb @@ -15,6 +15,7 @@ name1 = data1['name'][I18n.locale] name2 = data2['name'][I18n.locale] name3 = data3['name'][I18n.locale] + seminar_submission_field = @seminar.seminar_submission_fields.where(:markup=>"seminar_preferred_session").first %> <% if @seminar.contribute_start_date <= @time_now and ( @seminar.contribute_end_date.nil? or @seminar.contribute_end_date+1 >= @time_now ) %> <% begin %> @@ -37,6 +38,9 @@ <% if show3 %> <%= name3 %> <% end %> + <% if seminar_submission_field %> + <%= seminar_submission_field.title %> + <% end %> <%= t(:action) %> @@ -56,6 +60,9 @@ end %> <%= description.html_safe %> <%= link_to File.basename(seminar_signup_contribute.file.path), seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(description.gsub("
"," , ")).text} if seminar_signup_contribute.file.file %> + <% if seminar_submission_field %> + <%= seminar_signup_contribute.seminar_submission_values.where(:seminar_submission_field=>seminar_submission_field).first.get_value_by_locale(I18n.locale) %> + <% end %> <%= link_to t(:edit), OrbitHelper.url_to_show(@seminar.to_param) + '?method=edit_file&con_no=' + seminar_signup_contribute.id, :class => 'btn btn-primary' %>
diff --git a/config/list.yml b/config/list.yml new file mode 100644 index 0000000..90ea26a --- /dev/null +++ b/config/list.yml @@ -0,0 +1,44 @@ +forbidden_item_names: + - admin + - panel + - appfront + +#NO_MULTI_TAG = ["select","date","radio_button","checkbox","date_durnation"] + +markups: + text_field: + muti_lang_input_supprt: true + ext_support: true + panel: typeA + select: + muti_lang_input_supprt: false + ext_support: false + panel: typeB + date: + muti_lang_input_supprt: false + ext_support: false + panel: typeC + text_area: + muti_lang_input_supprt: true + ext_support: false + panel: typeD + radio_button: + muti_lang_input_supprt: false + ext_support: false + panel: typeE + checkbox: + muti_lang_input_supprt: false + ext_support: false + panel: typeE + address: + muti_lang_input_supprt: true + ext_support: true + member_relationship: + muti_lang_input_supprt: false + ext_support: false + panel: member_relations + seminar_preferred_session: + muti_lang_input_supprt: false + ext_support: false + panel: typeF + display_only: seminar_submission_field diff --git a/config/locales/en.yml b/config/locales/en.yml index c24a376..331b8b2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3,8 +3,11 @@ en: simple_captcha: placeholder: "" label: "" - + lists: + markups: + seminar_preferred_session: Preferred Session restful_actions: + edit_seminar_review: Review copy: Copy act_signup: Sign Up Info #報名資料 seminar_submission_field: Seminar Submission Field @@ -18,8 +21,16 @@ en: recaptcha: errors: verification_failed: Verification Failed #驗證碼錯誤 - + helpers: + label: + seminar_review_result: + abstract_number: Abstract number + presentation_type: Presentation seminar: + view_original_image: View original image + assigned_session: Assigned Session + abstract_number: Abstract number + review: Review copy_mode_on: Copy mode on clone_signups: Clone Signups copy: Copy diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 1f63e25..74acb13 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -3,8 +3,12 @@ zh_tw: simple_captcha: placeholder: "" label: "" + lists: + markups: + seminar_preferred_session: Preferred Session restful_actions: + edit_seminar_review: 審查 copy: 複製 act_signup: 報名資料 seminar_submission_field: 上傳介面欄位 @@ -18,8 +22,16 @@ zh_tw: recaptcha: errors: verification_failed: 驗證碼錯誤 - + helpers: + label: + seminar_review_result: + abstract_number: 摘要編號 + presentation_type: 發表方式 seminar: + view_original_image: 查看原圖 + assigned_session: Assigned Session + abstract_number: 摘要編號 + review: 審查 copy_mode_on: 啟用複製模式 clone_signups: 複製報名人 copy: 複製 diff --git a/config/routes.rb b/config/routes.rb index 89043e9..27f69c1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,6 +35,8 @@ Rails.application.routes.draw do end resources :seminar_agreements resources :seminar_signups + resources :seminar_submission_values + resources :seminar_review_results resources :seminar_item_contents end diff --git a/seminar.gemspec b/seminar.gemspec index ce414e5..7ed95d3 100644 --- a/seminar.gemspec +++ b/seminar.gemspec @@ -1,6 +1,7 @@ # -*- encoding: utf-8 -*- # stub: seminar 0.0.1 ruby lib - +data = File.open(File.join(File.dirname(__FILE__), 'config', 'list.yml')).read +$seminar_list = YAML::load(ERB.new(data).result(binding)).symbolize_keys Gem::Specification.new do |s| s.name = "seminar" s.version = "0.0.1"