Fix bug and add sort number.

This commit is contained in:
BoHung Chiu 2023-04-12 11:33:32 +08:00
parent a4abfa0b6e
commit c99354fc76
20 changed files with 121 additions and 45 deletions

View File

@ -101,6 +101,7 @@ function setData(l, type, ol) {
_add_more: ["add_more_" +l, fields+"["+l+"]["+type+"][add_more]"], _add_more: ["add_more_" +l, fields+"["+l+"]["+type+"][add_more]"],
_calendar: ["calendar_" +l, fields+"["+l+"]["+type+"][calendar]"], _calendar: ["calendar_" +l, fields+"["+l+"]["+type+"][calendar]"],
_cross_lang: ["cross_lang_" +l, fields+"["+l+"]["+type+"][cross_lang]"], _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]"], _disabled: ["disabled_" +l, fields+"["+l+"][disabled]"],
_format: ["format_" +l, fields+"["+l+"]["+type+"][format]"], _format: ["format_" +l, fields+"["+l+"]["+type+"][format]"],
_initial: ["initial_" +l, fields+"["+l+"]["+type+"][initial]"], _initial: ["initial_" +l, fields+"["+l+"]["+type+"][initial]"],

View File

@ -101,6 +101,7 @@ function setData(l, type, ol) {
_add_more: ["add_more_" +l, fields+"["+l+"]["+type+"][add_more]"], _add_more: ["add_more_" +l, fields+"["+l+"]["+type+"][add_more]"],
_calendar: ["calendar_" +l, fields+"["+l+"]["+type+"][calendar]"], _calendar: ["calendar_" +l, fields+"["+l+"]["+type+"][calendar]"],
_cross_lang: ["cross_lang_" +l, fields+"["+l+"]["+type+"][cross_lang]"], _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]"], _disabled: ["disabled_" +l, fields+"["+l+"][disabled]"],
_format: ["format_" +l, fields+"["+l+"]["+type+"][format]"], _format: ["format_" +l, fields+"["+l+"]["+type+"][format]"],
_initial: ["initial_" +l, fields+"["+l+"]["+type+"][initial]"], _initial: ["initial_" +l, fields+"["+l+"]["+type+"][initial]"],

View File

@ -26,8 +26,8 @@ class SeminarsController < ApplicationController
seminars = seminars.map do |seminar| seminars = seminars.map do |seminar|
link_url = OrbitHelper.url_to_plugin_show(seminar.to_param, 'seminar') link_url = OrbitHelper.url_to_plugin_show(seminar.to_param, 'seminar')
registration_is_open = seminar.registration_status.present? 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_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_overdue = seminar.signup_end_date && time_now && (seminar.signup_end_date + 1.day <= time_now)
signup_is_full = seminar.signup_is_full? signup_is_full = seminar.signup_is_full?
seminar_url = (@custom_slug ? OrbitHelper.url_to_show(@custom_slug) : OrbitHelper.url_to_show(seminar.to_param)) seminar_url = (@custom_slug ? OrbitHelper.url_to_show(@custom_slug) : OrbitHelper.url_to_show(seminar.to_param))
if !registration_is_open if !registration_is_open
@ -330,8 +330,8 @@ class SeminarsController < ApplicationController
seminar = SeminarMain.find_by(uid: params[:uid]) seminar = SeminarMain.find_by(uid: params[:uid])
registration_is_open = seminar.registration_status.present? 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_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_overdue = seminar.signup_end_date && time_now && (seminar.signup_end_date + 1.day <= time_now)
signup_is_full = seminar.signup_is_full? signup_is_full = seminar.signup_is_full?
seminar_url = (@custom_slug ? OrbitHelper.url_to_show(@custom_slug) : OrbitHelper.url_to_show(seminar.to_param)) seminar_url = (@custom_slug ? OrbitHelper.url_to_show(@custom_slug) : OrbitHelper.url_to_show(seminar.to_param))
if !registration_is_open if !registration_is_open

View File

@ -10,13 +10,13 @@ module Admin::SeminarsFieldHelper
include OrbitFormHelper 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 unless self.disabled
@index = index @index = index
@require = to_require @require = to_require
@markup_options = markup_options.merge(:disabled=>disable, :required => to_require) @markup_options = markup_options.merge(:disabled=>disable, :required => to_require)
@member = member @seminar_main = seminar_main
@attribute_value = @member.get_value_from_field_id(id,signup) @attribute_value = @seminar_main.get_value_from_field_id(id,signup)
@attribute_type = attribute_type @attribute_type = attribute_type
@new_attribute = @attribute_value.nil? @new_attribute = @attribute_value.nil?
@attribute_value = @attribute_value || signup.seminar_signup_values.build(seminar_signup_field_id: id) @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 ||=[]
@prefiled_value = Array(@prefiled_value) @prefiled_value = Array(@prefiled_value)
control_group_wrapper_for_sm do 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 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")) 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.join.html_safe
end if @member.enable_summary_choice end if @seminar_main.enable_summary_choice
end end
def render_select def render_select
prompt = @panel_setting["initial"][I18n.locale.to_s] rescue nil prompt = @panel_setting["initial"][I18n.locale.to_s] rescue nil
@ -310,8 +310,6 @@ protected
add_more_value = add_more_params[0][:value] add_more_value = add_more_params[0][:value]
end end
if can_muti_lang_input_for_sm? if can_muti_lang_input_for_sm?
result << lang_panel_tabbable_wrapper(add_more_params,&block) result << lang_panel_tabbable_wrapper(add_more_params,&block)
result << gen_modal_dialog if self.markup == "address" result << gen_modal_dialog if self.markup == "address"
@ -326,8 +324,6 @@ protected
value = @prefiled_value value = @prefiled_value
result << yield(nil,value) result << yield(nil,value)
end end
end end
if self.markup == "address" if self.markup == "address"
result result

View File

@ -89,6 +89,13 @@ class SeminarMain
if self.signup_limit_changed? if self.signup_limit_changed?
self.sync_signup_count self.sync_signup_count
end 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" module_app_key = "seminar"
add_module_app_member_ids = [] add_module_app_member_ids = []
remove_module_app_member_ids = [] remove_module_app_member_ids = []

View File

@ -6,6 +6,7 @@ class SeminarSignupField
include ::Admin::SeminarsFieldHelper include ::Admin::SeminarsFieldHelper
field :key, type: String field :key, type: String
field :sort_number, type: Integer
# field :af_count # field :af_count
field :title, type: String, localize: true field :title, type: String, localize: true
field :markup, default: "text_field" field :markup, default: "text_field"
@ -26,6 +27,7 @@ class SeminarSignupField
belongs_to :seminar_main belongs_to :seminar_main
has_many :seminar_signup_values, autosave: true, dependent: :destroy has_many :seminar_signup_values, autosave: true, dependent: :destroy
accepts_nested_attributes_for :seminar_signup_values, :allow_destroy => true 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 :check_option_list
before_save do |record| before_save do |record|
record.instance_variable_set(:@key_changed, record.key_changed?) record.instance_variable_set(:@key_changed, record.key_changed?)

View File

@ -6,6 +6,7 @@ class SeminarSubmissionField
include ::Admin::SeminarsFieldHelper include ::Admin::SeminarsFieldHelper
field :key, type: String field :key, type: String
field :sort_number, type: Integer
# field :af_count # field :af_count
field :title, type: String, localize: true field :title, type: String, localize: true
field :markup, default: "text_field" field :markup, default: "text_field"
@ -26,6 +27,7 @@ class SeminarSubmissionField
belongs_to :seminar_main belongs_to :seminar_main
has_many :seminar_submission_values, autosave: true, dependent: :destroy has_many :seminar_submission_values, autosave: true, dependent: :destroy
accepts_nested_attributes_for :seminar_submission_values, :allow_destroy => true 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 :check_option_list
before_save do |record| before_save do |record|
record.instance_variable_set(:@key_changed, record.key_changed?) record.instance_variable_set(:@key_changed, record.key_changed?)

View File

@ -166,7 +166,7 @@
<% end %> <% end %>
<% @form_index = 0 %> <% @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| %>
<div class="control-group"> <div class="control-group">

View File

@ -3,8 +3,9 @@
@af_counter = attribute_field_counter @af_counter = attribute_field_counter
%> %>
<div class="attributes-header clearfix"> <div class="attributes-header clearfix">
<%= hidden_field "#{@field_name}[seminar_signup_fields_attributes][#{@af_counter}]", "sort_number", :value=> @af_counter, :class=>"sort_number" %>
<div class="toggle-control" style="float: right;"> <div class="toggle-control" style="float: right;">
<div class="togglebox <%= attribute_field.disabled ? 'disabled' : ''%>"> <div class="togglebox <%= attribute_field.disabled ? 'disabled disable' : ''%>">
<%= hidden_field "#{@field_name}[seminar_signup_fields_attributes][#{@af_counter}]", "disabled", :value=>attribute_field.disabled, :class=>"toggle-check", :data=>{:deploy=> "right"} %> <%= hidden_field "#{@field_name}[seminar_signup_fields_attributes][#{@af_counter}]", "disabled", :value=>attribute_field.disabled, :class=>"toggle-check", :data=>{:deploy=> "right"} %>
<label><b></b></label> <label><b></b></label>
</div> </div>

View File

@ -3,8 +3,9 @@
@af_counter = attribute_submission_field_counter @af_counter = attribute_submission_field_counter
%> %>
<div class="attributes-header clearfix"> <div class="attributes-header clearfix">
<%= hidden_field "#{@field_name}[seminar_submission_fields_attributes][#{@af_counter}]", "sort_number", :value=> @af_counter, :class=>"sort_number" %>
<div class="toggle-control" style="float: right;"> <div class="toggle-control" style="float: right;">
<div class="togglebox <%= attribute_submission_field.disabled ? 'disabled' : ''%>"> <div class="togglebox <%= attribute_submission_field.disabled ? 'disabled disable' : ''%>">
<%= hidden_field "#{@field_name}[seminar_submission_fields_attributes][#{@af_counter}]", "disabled", :value=>attribute_submission_field.disabled, :class=>"toggle-check", :data=>{:deploy=> "right"} %> <%= hidden_field "#{@field_name}[seminar_submission_fields_attributes][#{@af_counter}]", "disabled", :value=>attribute_submission_field.disabled, :class=>"toggle-check", :data=>{:deploy=> "right"} %>
<label><b></b></label> <label><b></b></label>
</div> </div>

View File

@ -35,7 +35,7 @@
<% default_hidden << "seminar_signup_fields.#{s.key}" if (field_set.hidden) %> <% default_hidden << "seminar_signup_fields.#{s.key}" if (field_set.hidden) %>
<% end %> <% end %>
<% end %> <% end %>
<% @seminar.seminar_signup_fields.each do |s| %> <% @seminar.seminar_signup_fields.where(:disabled=>false).asc(:sort_number, :_id).each do |s| %>
<% next if s.title.blank? %> <% next if s.title.blank? %>
<% default_hidden << "seminar_signup_fields.#{s.key}" %> <% default_hidden << "seminar_signup_fields.#{s.key}" %>
<% @field_names << "seminar_signup_fields.#{s.key}" %> <% @field_names << "seminar_signup_fields.#{s.key}" %>
@ -63,7 +63,7 @@
<% default_hidden << "seminar_signup_contributes.description" if !show3 %> <% default_hidden << "seminar_signup_contributes.description" if !show3 %>
<% @field_names << 'seminar_signup_contributes.description' %> <% @field_names << 'seminar_signup_contributes.description' %>
<% @field_name_translations << t('seminar_signup.description') %> <% @field_name_translations << t('seminar_signup.description') %>
<% @seminar.seminar_submission_fields.each do |s| %> <% @seminar.seminar_submission_fields.where(:disabled=>false).asc(:sort_number, :_id).each do |s| %>
<% @field_names << "seminar_submission_fields.#{s.key}" %> <% @field_names << "seminar_submission_fields.#{s.key}" %>
<% if s.markup != "seminar_preferred_session" <% if s.markup != "seminar_preferred_session"
@field_name_translations << s.title @field_name_translations << s.title
@ -111,7 +111,7 @@
<% @field_name_translations << t(th) %> <% @field_name_translations << t(th) %>
<% end %> <% end %>
<% end %> <% end %>
<% seminar_signup_fields = SeminarSignupField.where(:key.nin=>["", nil]).uniq{|s| s.key} %> <% seminar_signup_fields = SeminarSignupField.where(:key.nin=>["", nil], :disabled=>false).asc(:seminar_main_id, :sort_number, :_id).uniq{|s| s.key} %>
<% seminar_signup_field_customs = SeminarSignupFieldCustom.where(:seminar_signup_field_id.in=> seminar_signup_fields.map(&:id)).to_a %> <% seminar_signup_field_customs = SeminarSignupFieldCustom.where(:seminar_signup_field_id.in=> seminar_signup_fields.map(&:id)).to_a %>
<% if seminar_signup_field_customs.count != 0 %> <% if seminar_signup_field_customs.count != 0 %>
<% seminar_signup_field_customs.each do |field_set| %> <% seminar_signup_field_customs.each do |field_set| %>
@ -141,7 +141,7 @@
<% default_show << "seminar_signup_contributes.description" if show3 %> <% default_show << "seminar_signup_contributes.description" if show3 %>
<% @field_names << 'seminar_signup_contributes.description' %> <% @field_names << 'seminar_signup_contributes.description' %>
<% @field_name_translations << t('seminar_signup.description') %> <% @field_name_translations << t('seminar_signup.description') %>
<% seminar_submission_fields = SeminarSubmissionField.where(:key.nin=>["", nil]).uniq{|s| s.key} %> <% seminar_submission_fields = SeminarSubmissionField.where(:key.nin=>["", nil], :disabled=>false).asc(:seminar_main_id, :sort_number, :_id).uniq{|s| s.key} %>
<% seminar_submission_fields.each do |s| %> <% seminar_submission_fields.each do |s| %>
<% next if s.title.blank? %> <% next if s.title.blank? %>
<% @field_names << "seminar_submission_fields.#{s.key}" %> <% @field_names << "seminar_submission_fields.#{s.key}" %>

View File

@ -27,7 +27,7 @@
<%= link_to content_tag(:i, nil, class: "icon-eye-open"), (link_url.split('/').last.include?("?") ? "#{link_url}&editmode=on" : "#{link_url}?editmode=on" ), class: "view-page open-slide tip", title: t("structure.view"), data: {title: node.name} if node.page_type.eql?('page') %> <%= link_to content_tag(:i, nil, class: "icon-eye-open"), (link_url.split('/').last.include?("?") ? "#{link_url}&editmode=on" : "#{link_url}?editmode=on" ), class: "view-page open-slide tip", title: t("structure.view"), data: {title: node.name} if node.page_type.eql?('page') %>
<%#= link_to content_tag(:i, nil, class: "icons-mobile"), (node.root? ? "/?editmode=on&mobile=1" : "/" + I18n.locale.to_s + node.url + "?editmode=on&mobile=1"), class: "view-page open-slide tip mobile-view-btn", title: "Edit Mobile Page", data: {title: "Edit Mobile Page"} if node.page_type.eql?("page") && current_site.mobile_on && node.enabled_for_mobile %> <%#= link_to content_tag(:i, nil, class: "icons-mobile"), (node.root? ? "/?editmode=on&mobile=1" : "/" + I18n.locale.to_s + node.url + "?editmode=on&mobile=1"), class: "view-page open-slide tip mobile-view-btn", title: "Edit Mobile Page", data: {title: "Edit Mobile Page"} if node.page_type.eql?("page") && current_site.mobile_on && node.enabled_for_mobile %>
<% unless name.eql? "sitemap" %> <% unless name.eql? "sitemap" %>
<%= link_to content_tag(:i, nil, class: "icon-edit"), edit_page_path(node.id,:type => node.page_type), class: "open-slide tip page edit", title: t("structure.edit_#{node.page_type}"), data: {title: t("structure.edit_#{node.page_type}")} if node.class.to_s.downcase.eql?("page") && !(node.root?) %> <%= link_to content_tag(:i, nil, class: "icon-edit"), edit_page_path(node.id,:type => node.page_type), class: "open-slide tip page edit", title: t("structure.edit_#{node.page_type}"), data: {title: t("structure.edit_#{node.page_type}")} if node.class.to_s.downcase.eql?("page") %>
<%= link_to content_tag(:i, nil, class: "icons-link"), new_page_path(:parent_page => node.id.to_s,:type => "link"), class: "open-slide tip link", title: t("structure.add_link"), data: {title: t("structure.add_link"), id: 'new', parent: node.id.to_s} if node.class.to_s.eql?('Page') && level < 3 %> <%= link_to content_tag(:i, nil, class: "icons-link"), new_page_path(:parent_page => node.id.to_s,:type => "link"), class: "open-slide tip link", title: t("structure.add_link"), data: {title: t("structure.add_link"), id: 'new', parent: node.id.to_s} if node.class.to_s.eql?('Page') && level < 3 %>
<%= link_to content_tag(:i, nil, class: "icons-newspaper"), new_page_path(:parent_page => node.id.to_s,:type => "page"), class: "open-slide tip page", title: t("structure.add_page"), data: {title: t("structure.add_page"), id: 'new', parent: node.id.to_s} if node.class.to_s.eql?('Page') && level < 3 %> <%= link_to content_tag(:i, nil, class: "icons-newspaper"), new_page_path(:parent_page => node.id.to_s,:type => "page"), class: "open-slide tip page", title: t("structure.add_page"), data: {title: t("structure.add_page"), id: 'new', parent: node.id.to_s} if node.class.to_s.eql?('Page') && level < 3 %>
<%= link_to content_tag(:i, nil, class: "icons-retweet"), "/pages/#{node.id}/import_widgets",:method => :post, :remote => true, "data-confirm" => "This will override your current widgets and widget settings. Do you wish to continue?.", class: "import-widgets tip", title: t("structure.import_widgets"), data: {title: t("structure.import_widgets")} if level > 1 && node.page_type != "link" %> <%= link_to content_tag(:i, nil, class: "icons-retweet"), "/pages/#{node.id}/import_widgets",:method => :post, :remote => true, "data-confirm" => "This will override your current widgets and widget settings. Do you wish to continue?.", class: "import-widgets tip", title: t("structure.import_widgets"), data: {title: t("structure.import_widgets")} if level > 1 && node.page_type != "link" %>

View File

@ -3,6 +3,7 @@
<script id="template-attributes" type="text/x-tmpl"> <script id="template-attributes" type="text/x-tmpl">
<div class="attributes"> <div class="attributes">
<div class="attributes-header clearfix"> <div class="attributes-header clearfix">
<input class="sort_number" id="${_sort_number[0]}" name="${_sort_number[1]}" type="hidden" value="${_sort_number[2]}">
<input class="toggle-check" data-deploy="right" id="${_disabled[0]}" name="${_disabled[1]}" type="hidden" value="false"> <input class="toggle-check" data-deploy="right" id="${_disabled[0]}" name="${_disabled[1]}" type="hidden" value="false">
<a class="btn btn-mini pull-right btn-danger delete" href="#"><i class="icon-trash"></i> Delete</a> <a class="btn btn-mini pull-right btn-danger delete" href="#"><i class="icon-trash"></i> Delete</a>
<a class="btn btn-mini pull-right btn-inverse reply hide" href="#"><i class="icons-reply"></i> Reply</a> <a class="btn btn-mini pull-right btn-inverse reply hide" href="#"><i class="icons-reply"></i> Reply</a>

View File

@ -24,7 +24,9 @@ wb.add_worksheet(name: (@seminar.title.to_s[0..27]+'...')) do |sheet|
row << t('seminar_signup.note') row << t('seminar_signup.note')
@seminar.seminar_signup_fields.asc(:_id).each do |rf| seminar_signup_fields = @seminar.seminar_signup_fields.where(:disabled=>false).asc(:sort_number, :_id).to_a
seminar_signup_fields.each do |rf|
if rf.can_muti_lang_input? if rf.can_muti_lang_input?
@site_in_use_locales.each do |l| @site_in_use_locales.each do |l|
row << rf.title + " (#{t(l.to_s)})" row << rf.title + " (#{t(l.to_s)})"
@ -56,7 +58,7 @@ wb.add_worksheet(name: (@seminar.title.to_s[0..27]+'...')) do |sheet|
row2 << "#{signup.address} " row2 << "#{signup.address} "
row2 << "#{signup[:email]} " row2 << "#{signup[:email]} "
row2 << "#{signup.note} " row2 << "#{signup.note} "
@seminar.seminar_signup_fields.asc(:_id).each do |rf| seminar_signup_fields.each do |rf|
if rf.can_muti_lang_input? if rf.can_muti_lang_input?
@site_in_use_locales.each do |l| @site_in_use_locales.each do |l|
row2 << (@seminar.get_attribute_value(rf,signup.id).get_value_by_locale(l) rescue '') row2 << (@seminar.get_attribute_value(rf,signup.id).get_value_by_locale(l) rescue '')

View File

@ -18,8 +18,8 @@
<h3><%= @attribute.title %></h3> <h3><%= @attribute.title %></h3>
<fieldset> <fieldset>
<div id="attributes-area" class="input-area"> <div id="attributes-area" class="input-area sortable">
<%= render partial: "attribute_field",collection: @attribute.seminar_signup_fields.asc(:_id)%> <%= render partial: "attribute_field",collection: @attribute.seminar_signup_fields.asc(:sort_number, :_id)%>
</div> </div>
<div class="form-actions"> <div class="form-actions">
@ -35,3 +35,33 @@
<% content_for :page_specific_javascript do -%> <% content_for :page_specific_javascript do -%>
<%= render 'support_member_form_js' %> <%= render 'support_member_form_js' %>
<% end -%> <% end -%>
<style type="text/css">
#attributes-area h4:before {
content: "\e096";
font-family: 'entypo';
cursor: pointer;
}
</style>
<script>
function update_key(ele){
var ui_child=$(ele).parents('.sortable.ui-sortable').find('.attributes');
for (var i=0;i<ui_child.length;i++){
var now_ele = ui_child.eq(i);
var new_i = i + 1;
now_ele.find('.sort_number').val(i);
now_ele.find('h4 span').text(new_i);
}
}
$('.sortable').ready(function(){
$( ".sortable" ).sortable({
axis: "y",
revert: true,
placeholder: "sortable-placeholder",
handle: ".attributes-header",
update: function(event, ui) {
update_key(ui.item)
}
});
$('.sortable').disableSelection();
})
</script>

View File

@ -17,8 +17,8 @@
<h3><%= @attribute.title %></h3> <h3><%= @attribute.title %></h3>
<fieldset> <fieldset>
<div id="attributes-area" class="input-area"> <div id="attributes-area" class="input-area sortable">
<%= render partial: "attribute_submission_field",collection: @attribute.seminar_submission_fields.asc(:_id)%> <%= render partial: "attribute_submission_field",collection: @attribute.seminar_submission_fields.asc(:sort_number, :_id)%>
</div> </div>
<div class="form-actions"> <div class="form-actions">
@ -34,3 +34,33 @@
<% content_for :page_specific_javascript do -%> <% content_for :page_specific_javascript do -%>
<%= render 'support_member_form_js' %> <%= render 'support_member_form_js' %>
<% end -%> <% end -%>
<style type="text/css">
#attributes-area h4:before {
content: "\e096";
font-family: 'entypo';
cursor: pointer;
}
</style>
<script>
function update_key(ele){
var ui_child=$(ele).parents('.sortable.ui-sortable').find('.attributes');
for (var i=0;i<ui_child.length;i++){
var now_ele = ui_child.eq(i);
var new_i = i + 1;
now_ele.find('.sort_number').val(i);
now_ele.find('h4 span').text(new_i);
}
}
$('.sortable').ready(function(){
$( ".sortable" ).sortable({
axis: "y",
revert: true,
placeholder: "sortable-placeholder",
handle: ".attributes-header",
update: function(event, ui) {
update_key(ui.item)
}
});
$('.sortable').disableSelection();
})
</script>

View File

@ -83,7 +83,7 @@
</div> </div>
</div> </div>
<% end %> <% end %>
<% @seminar.seminar_submission_fields.asc(:_id).each do |rf| %> <% @seminar.seminar_submission_fields.where(:disabled=>false).asc(:sort_number, :_id).each do |rf| %>
<div class="form-group" style="<%= rf.markup=='text_area' ? 'display: flex;justify-content: flex-end;text-align: right;' : '' %>"> <div class="form-group" style="<%= rf.markup=='text_area' ? 'display: flex;justify-content: flex-end;text-align: right;' : '' %>">
<%= rf.block_helper(@seminar,@form_index,false,"seminar_signup_contribute",@con, rf.to_require,rf) %> <%= rf.block_helper(@seminar,@form_index,false,"seminar_signup_contribute",@con, rf.to_require,rf) %>
</div> </div>

View File

@ -18,7 +18,7 @@
end end
end end
end end
seminar_submission_fields = @seminar.seminar_submission_fields.where(:disabled=>false) seminar_submission_fields = @seminar.seminar_submission_fields.where(:disabled=>false).asc(:sort_number, :_id)
%> %>
<h3><%= @seminar.title rescue nil %></h3> <h3><%= @seminar.title rescue nil %></h3>
<table id="signup_infos"> <table id="signup_infos">

View File

@ -203,7 +203,7 @@
</div> </div>
<% end %> <% end %>
<% @seminar.seminar_signup_fields.asc(:_id).each do |rf| %> <% @seminar.seminar_signup_fields.where(:disabled=>false).asc(:sort_number, :_id).each do |rf| %>
<div class="form-group"> <div class="form-group">
@ -278,7 +278,7 @@
} }
<% <%
@seminar.seminar_signup_fields.asc(:_id).each do |rf| @seminar.seminar_signup_fields.where(:disabled=>false).asc(:sort_number, :_id).each do |rf|
if rf.markup == 'checkbox' if rf.markup == 'checkbox'
%> %>

View File

@ -33,6 +33,8 @@ Rails.application.routes.draw do
end end
end end
end end
SeminarSignupField.create_indexes
SeminarSubmissionField.create_indexes
end end
locales = Site.first.in_use_locales rescue I18n.available_locales locales = Site.first.in_use_locales rescue I18n.available_locales