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
flash.now[:notice] = "Updated Fields"
@seminar.seminar_submission_fields.each{|t| t.destroy if t["to_delete"] == true}
redirect_to admin_seminars_path
else

View File

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

View File

@ -4,8 +4,9 @@ class SeminarSignupContribute
include Mongoid::Timestamps
field :title
field :description
mount_uploader :file, AssetUploader
field :description
belongs_to :seminar_signup
has_many :seminar_submission_values, autosave: true, dependent: :destroy
accepts_nested_attributes_for :seminar_submission_values, :allow_destroy => true

View File

@ -41,12 +41,12 @@
<div class="controls">
<% if @seminar.registration_status.include?('G') %>
<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>
<% end %>
<% if @seminar.registration_status.include?('C') %>
<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>
<% end %>
</div>

View File

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