diff --git a/app/assets/javascripts/seminar-field-forms-submission.js b/app/assets/javascripts/seminar-field-forms-submission.js index 8259abf..15ff538 100644 --- a/app/assets/javascripts/seminar-field-forms-submission.js +++ b/app/assets/javascripts/seminar-field-forms-submission.js @@ -101,6 +101,7 @@ function setData(l, type, ol) { _add_more: ["add_more_" +l, fields+"["+l+"]["+type+"][add_more]"], _calendar: ["calendar_" +l, fields+"["+l+"]["+type+"][calendar]"], _cross_lang: ["cross_lang_" +l, fields+"["+l+"]["+type+"][cross_lang]"], + _sort_number: ["sort_number_" +l, fields+"["+l+"][sort_number]", l], _disabled: ["disabled_" +l, fields+"["+l+"][disabled]"], _format: ["format_" +l, fields+"["+l+"]["+type+"][format]"], _initial: ["initial_" +l, fields+"["+l+"]["+type+"][initial]"], diff --git a/app/assets/javascripts/seminar-field-forms.js b/app/assets/javascripts/seminar-field-forms.js index 8118423..3f4b401 100644 --- a/app/assets/javascripts/seminar-field-forms.js +++ b/app/assets/javascripts/seminar-field-forms.js @@ -101,6 +101,7 @@ function setData(l, type, ol) { _add_more: ["add_more_" +l, fields+"["+l+"]["+type+"][add_more]"], _calendar: ["calendar_" +l, fields+"["+l+"]["+type+"][calendar]"], _cross_lang: ["cross_lang_" +l, fields+"["+l+"]["+type+"][cross_lang]"], + _sort_number: ["sort_number_" +l, fields+"["+l+"][sort_number]", l], _disabled: ["disabled_" +l, fields+"["+l+"][disabled]"], _format: ["format_" +l, fields+"["+l+"]["+type+"][format]"], _initial: ["initial_" +l, fields+"["+l+"]["+type+"][initial]"], diff --git a/app/controllers/seminars_controller.rb b/app/controllers/seminars_controller.rb index 7d2ca1e..8a9f5a3 100644 --- a/app/controllers/seminars_controller.rb +++ b/app/controllers/seminars_controller.rb @@ -26,8 +26,8 @@ class SeminarsController < ApplicationController seminars = seminars.map do |seminar| link_url = OrbitHelper.url_to_plugin_show(seminar.to_param, 'seminar') registration_is_open = seminar.registration_status.present? - sign_up_not_yet = seminar.signup_start_date && @time_now && @seminar.signup_start_date > @time_now - sign_up_overdue = seminar.signup_end_date && @time_now && (@seminar.signup_end_date + 1.day <= @time_now) + sign_up_not_yet = seminar.signup_start_date && time_now && seminar.signup_start_date > time_now + sign_up_overdue = seminar.signup_end_date && time_now && (seminar.signup_end_date + 1.day <= time_now) signup_is_full = seminar.signup_is_full? seminar_url = (@custom_slug ? OrbitHelper.url_to_show(@custom_slug) : OrbitHelper.url_to_show(seminar.to_param)) if !registration_is_open @@ -330,8 +330,8 @@ class SeminarsController < ApplicationController seminar = SeminarMain.find_by(uid: params[:uid]) registration_is_open = seminar.registration_status.present? - sign_up_not_yet = seminar.signup_start_date && @time_now && @seminar.signup_start_date > @time_now - sign_up_overdue = seminar.signup_end_date && @time_now && (@seminar.signup_end_date + 1.day <= @time_now) + sign_up_not_yet = seminar.signup_start_date && time_now && seminar.signup_start_date > time_now + sign_up_overdue = seminar.signup_end_date && time_now && (seminar.signup_end_date + 1.day <= time_now) signup_is_full = seminar.signup_is_full? seminar_url = (@custom_slug ? OrbitHelper.url_to_show(@custom_slug) : OrbitHelper.url_to_show(seminar.to_param)) if !registration_is_open diff --git a/app/helpers/admin/seminars_field_helper.rb b/app/helpers/admin/seminars_field_helper.rb index d2cc36f..8e4f04e 100644 --- a/app/helpers/admin/seminars_field_helper.rb +++ b/app/helpers/admin/seminars_field_helper.rb @@ -10,13 +10,13 @@ module Admin::SeminarsFieldHelper include OrbitFormHelper - def block_helper(member,index,disable = false,attribute_type=nil,signup=nil, to_require=true) + def block_helper(seminar_main,index,disable = false,attribute_type=nil,signup=nil, to_require=true) unless self.disabled @index = index @require = to_require @markup_options = markup_options.merge(:disabled=>disable, :required => to_require) - @member = member - @attribute_value = @member.get_value_from_field_id(id,signup) + @seminar_main = seminar_main + @attribute_value = @seminar_main.get_value_from_field_id(id,signup) @attribute_type = attribute_type @new_attribute = @attribute_value.nil? @attribute_value = @attribute_value || signup.seminar_signup_values.build(seminar_signup_field_id: id) @@ -146,11 +146,11 @@ module Admin::SeminarsFieldHelper @prefiled_value ||=[] @prefiled_value = Array(@prefiled_value) control_group_wrapper_for_sm do - @member.summary_chioices.map.with_index do |value,key| + @seminar_main.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 if @seminar_main.enable_summary_choice end def render_select prompt = @panel_setting["initial"][I18n.locale.to_s] rescue nil @@ -168,7 +168,7 @@ module Admin::SeminarsFieldHelper key = can_muti_lang_input_for_sm? ? "#{key}" : I18n.locale place_holder= typeD["placeholder"][key] rescue '' name1 = can_muti_lang_input_for_sm? ? (get_field_name_base + "[#{key}]") : get_field_name_base - text_area_tag(name1, value,@markup_options.merge(:placeholder=>place_holder,:class=>'ckeditor input-medium form-control')) + text_area_tag(name1, value, @markup_options.merge(:placeholder=>place_holder,:class=>'ckeditor input-medium form-control')) end end @@ -178,7 +178,7 @@ module Admin::SeminarsFieldHelper key_field = can_muti_lang_input_for_sm? ? "#{key}" : I18n.locale place_holder= typeA["placeholder"][key_field] rescue '' name1 = can_muti_lang_input_for_sm? ? ([get_field_name_base,add_more_blank,"[#{key_field}]"].join) : ([get_field_name_base,add_more_blank].join) - text_field_tag(name1, value,@markup_options.merge(:placeholder=>place_holder,:class=>'input-medium form-control')) + text_field_tag(name1, value, @markup_options.merge(:placeholder=>place_holder,:class=>'input-medium form-control')) end end @@ -302,15 +302,13 @@ protected def controls_wrapper_for_sm(*add_more_params,&block) - result = Array.new - add_more_counter = "" - - if can_add_more - add_more_counter = add_more_params[0][:counter] - add_more_value = add_more_params[0][:value] - end - + result = Array.new + add_more_counter = "" + if can_add_more + add_more_counter = add_more_params[0][:counter] + add_more_value = add_more_params[0][:value] + end if can_muti_lang_input_for_sm? result << lang_panel_tabbable_wrapper(add_more_params,&block) @@ -326,8 +324,6 @@ protected value = @prefiled_value result << yield(nil,value) end - - end if self.markup == "address" result diff --git a/app/models/seminar_main.rb b/app/models/seminar_main.rb index b77d129..afc4886 100644 --- a/app/models/seminar_main.rb +++ b/app/models/seminar_main.rb @@ -89,6 +89,13 @@ class SeminarMain if self.signup_limit_changed? self.sync_signup_count end + if !(self.new_record?) && self.title_changed? + name_hash = {} + self.title_translations.each do |l, t| + name_hash["name.#{l}"] = t + end + Page.where(:parent_page_id=>self.id).update_all(name_hash) + end module_app_key = "seminar" add_module_app_member_ids = [] remove_module_app_member_ids = [] diff --git a/app/models/seminar_signup_field.rb b/app/models/seminar_signup_field.rb index c0d87f3..4f5ee8d 100644 --- a/app/models/seminar_signup_field.rb +++ b/app/models/seminar_signup_field.rb @@ -6,10 +6,11 @@ class SeminarSignupField include ::Admin::SeminarsFieldHelper field :key, type: String + field :sort_number, type: Integer # field :af_count field :title, type: String, localize: true field :markup, default: "text_field" - field :option_list, type: Hash,default: {} + field :option_list, type: Hash, default: {} field :markup_options, type: Hash field :built_in, type: Boolean, default: false field :disabled, type: Boolean, default: false @@ -26,6 +27,7 @@ class SeminarSignupField belongs_to :seminar_main has_many :seminar_signup_values, autosave: true, dependent: :destroy accepts_nested_attributes_for :seminar_signup_values, :allow_destroy => true + index({seminar_main_id: 1, sort_number: 1, _id: 1, disabled: -1}, { unique: false, background: false }) before_save :check_option_list before_save do |record| record.instance_variable_set(:@key_changed, record.key_changed?) diff --git a/app/models/seminar_submission_field.rb b/app/models/seminar_submission_field.rb index c86a56c..ea48ff1 100644 --- a/app/models/seminar_submission_field.rb +++ b/app/models/seminar_submission_field.rb @@ -6,10 +6,11 @@ class SeminarSubmissionField include ::Admin::SeminarsFieldHelper field :key, type: String + field :sort_number, type: Integer # field :af_count field :title, type: String, localize: true field :markup, default: "text_field" - field :option_list, type: Hash,default: {} + field :option_list, type: Hash, default: {} field :markup_options, type: Hash field :built_in, type: Boolean, default: false field :disabled, type: Boolean, default: false @@ -26,6 +27,7 @@ class SeminarSubmissionField belongs_to :seminar_main has_many :seminar_submission_values, autosave: true, dependent: :destroy accepts_nested_attributes_for :seminar_submission_values, :allow_destroy => true + index({seminar_main_id: 1, sort_number: 1, _id: 1, disabled: -1}, { unique: false, background: false }) before_save :check_option_list before_save do |record| record.instance_variable_set(:@key_changed, record.key_changed?) diff --git a/app/views/admin/seminar_signups/edit.html.erb b/app/views/admin/seminar_signups/edit.html.erb index 93a2955..a1f1682 100644 --- a/app/views/admin/seminar_signups/edit.html.erb +++ b/app/views/admin/seminar_signups/edit.html.erb @@ -166,7 +166,7 @@ <% end %> <% @form_index = 0 %> - <% @seminar.seminar_signup_fields.asc(:_id).each do |rf| %> + <% @seminar.seminar_signup_fields.where(:disabled=>false).asc(:sort_number, :_id).each do |rf| %>