fix error

This commit is contained in:
chiu 2019-11-28 12:39:36 +08:00
parent 454723887d
commit 28b824f018
5 changed files with 35 additions and 18 deletions

View File

@ -145,7 +145,6 @@ class Admin::SeminarsController < OrbitAdminController
end end
flash.now[:notice] = "Updated Fields" flash.now[:notice] = "Updated Fields"
@seminar.seminar_submission_fields.each{|t| t.destroy if t["to_delete"] == true} @seminar.seminar_submission_fields.each{|t| t.destroy if t["to_delete"] == true}
redirect_to admin_seminars_path redirect_to admin_seminars_path
else else

View File

@ -171,10 +171,17 @@ class SeminarsController < ApplicationController
update_params = seminar_signup_contribute_params.merge('seminar_submission_values'=>params['seminar_submission_values']) update_params = seminar_signup_contribute_params.merge('seminar_submission_values'=>params['seminar_submission_values'])
flag = true flag = true
update_params.permit! update_params.permit!
update_params['seminar_submission_values']['0']['value'].each do |key,value| if update_params['seminar_submission_values']['0']['value'].class==String
value = update_params['seminar_submission_values']['0']['value']
if !value.to_s.blank? if !value.to_s.blank?
flag = false flag = false
end end
else
update_params['seminar_submission_values']['0']['value'].each do |key,value|
if !value.to_s.blank?
flag = false
end
end
end end
if flag if flag
update_params['seminar_submission_values']['0']['value']['en'] = ' ' update_params['seminar_submission_values']['0']['value']['en'] = ' '

View File

@ -4,8 +4,9 @@ class SeminarSignupContribute
include Mongoid::Timestamps include Mongoid::Timestamps
field :title field :title
field :description
mount_uploader :file, AssetUploader mount_uploader :file, AssetUploader
field :description
belongs_to :seminar_signup belongs_to :seminar_signup
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

View File

@ -41,12 +41,12 @@
<div class="controls"> <div class="controls">
<% if @seminar.registration_status.include?('G') %> <% if @seminar.registration_status.include?('G') %>
<label class="radio-inline"> <label class="radio-inline">
<%= f.radio_button :status, 'G', :checked => true , :onclick => "$('#registration_status').addClass('hide');" %> <%= t('seminar.registration_status_G') %> <%= f.radio_button :status, 'G', :checked => (@seminar_signup.status=='G'), :onclick => "$('#registration_status').addClass('hide');" %> <%= t('seminar.registration_status_G') %>
</label> </label>
<% end %> <% end %>
<% if @seminar.registration_status.include?('C') %> <% if @seminar.registration_status.include?('C') %>
<label class="radio-inline"> <label class="radio-inline">
<%= f.radio_button :status, 'C', :onclick => "$('#registration_status').removeClass('hide');", :checked => (@seminar.registration_status.count == 1 and @seminar.registration_status.include?('C') ? true : false) %> <%= t('seminar.registration_status_C') %> <%= f.radio_button :status, 'C', :onclick => "$('#registration_status').removeClass('hide');", :checked => (@seminar_signup.status=='C') %> <%= t('seminar.registration_status_C') %>
</label> </label>
<% end %> <% end %>
</div> </div>

View File

@ -36,14 +36,24 @@
<% end %> <% end %>
<% end %> <% end %>
<% if @seminar.seminar_submission_field_sets.count != 0 %> <% if @seminar.seminar_submission_field_sets.count != 0 %>
<% @seminar.seminar_submission_field_sets.each do |field_set| %> <% show1 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='title'}[0].hidden)
<% if !(field_set.hidden) %> show2 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='file'}[0].hidden)
<th class='span2'><%= field_set.name[I18n.locale] %></th> show3 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='description'}[0].hidden)
<% end %> %>
<% end %>
<% else %> <% else %>
<th class='span2'><%= t('seminar_signup.file_note')%></th> <% show1 = true
<th class='span2'><%= t('seminar_signup.uploads')%></th> show2 = true
show3 = true
%>
<% end %>
<% if show1 %>
<th class='span2'><%= t('seminar_signup.title')%></th>
<% end %>
<% if show2 %>
<th class='span2'><%= t('seminar_signup.file')%></th>
<% end %>
<% if show3 %>
<th class='span2'><%= t('seminar_signup.description')%></th>
<% end %> <% end %>
<% @seminar.seminar_submission_fields.each do |submission_field| %> <% @seminar.seminar_submission_fields.each do |submission_field| %>
<th class='span2'><%= submission_field.title %></th> <th class='span2'><%= submission_field.title %></th>
@ -115,8 +125,8 @@
<% count_set = 0 %> <% count_set = 0 %>
<% if @seminar.seminar_submission_field_sets.count != 0 %> <% if @seminar.seminar_submission_field_sets.count != 0 %>
<% show1 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='title'}[0].hidden) <% show1 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='title'}[0].hidden)
show2 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='description'}[0].hidden) show2 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='file'}[0].hidden)
show3 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='file'}[0].hidden) show3 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='description'}[0].hidden)
%> %>
<% @seminar.seminar_submission_field_sets.each do |field_set| %> <% @seminar.seminar_submission_field_sets.each do |field_set| %>
<% if !(field_set.hidden) %> <% if !(field_set.hidden) %>
@ -151,14 +161,14 @@
<% end %> <% end %>
<% if show2 %> <% if show2 %>
<td> <td>
<li><%= seminar_signup_contribute.description.to_s.html_safe %></li> <li>
<%= 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(seminar_signup_contribute.description).text} if seminar_signup_contribute.file.file %>
</li>
</td> </td>
<% end %> <% end %>
<% if show3 %> <% if show3 %>
<td> <td>
<li> <li><%= seminar_signup_contribute.description.to_s.html_safe %></li>
<%= 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(seminar_signup_contribute.description).text} if seminar_signup_contribute.file.file %>
</li>
</td> </td>
<% end %> <% end %>
<% <%