seminar/app/views/seminars/_contribute_form.html.erb

139 lines
5.8 KiB
Plaintext
Raw Normal View History

<fieldset>
<% unless f.object.new_record? %>
<%= f.hidden_field :id %>
<% end %>
<% if @seminar.seminar_submission_field_sets.count != 0
data1 = @seminar.seminar_submission_field_sets.select{|v| v.field_name=='title'}[0]
data2 = @seminar.seminar_submission_field_sets.select{|v| v.field_name=='description'}[0]
data3 = @seminar.seminar_submission_field_sets.select{|v| v.field_name=='file'}[0]
show1 = !(data1.disabled)
show2 = !(data2.disabled)
show3 = !(data3.disabled)
name1 = data1['name'][I18n.locale]
name2 = data2['name'][I18n.locale]
name3 = data3['name'][I18n.locale]
plc1 = data1['placeholder'][I18n.locale]
plc2 = data2['placeholder'][I18n.locale]==t('seminar_signup.description') ? '' : data2['placeholder'][I18n.locale]
plc3 = data3['placeholder'][I18n.locale]==t('seminar_signup.file') ? '' : data3['placeholder'][I18n.locale]
else
show1 = true
show2 = true
show3 = true
name1 = t('seminar_signup.title')
name2 = t('seminar_signup.description')
name3 = t('seminar_signup.file')
plc1 = t('seminar_signup.title')
plc2 = ''
plc3 = ''
end
%>
<% if show1 %>
<div class="form-group">
<label for="file_name" class="col-sm-2 control-label">*<%= name1 %></label>
<div class="col-sm-10">
<%= f.text_field :title, :class=>"input-medium form-control", :id=>'name', :placeholder=> plc1, :required => true %>
</div>
</div>
<% end %>
<% if show2 %>
<div class="form-group" style="display: flex;justify-content: flex-end;text-align: right;">
<span style="margin-right: 0.5em;">
<% required = @seminar.enable_summary_choice %>
<label for="description" class="col-sm-2 control-label" style="display: contents;">
<%=required ? '*' : '' %><%= name2 %>
</label>
<br>
<%= "(#{plc2})" if !(plc2.to_s.blank?) %>
</span>
<div class="col-sm-10" id="description" required="required">
<% if @seminar.enable_summary_choice %>
<% check_choices = Array(f.object.description) %>
<% if @seminar.summary_chioice_type == "select" %>
<%= f.select :description,options_for_select(@seminar.summary_chioices.map.with_index{|v,i| [v,i]},check_choices),{},{:style=>"float: left;",:required=>"required"} %>
<% else %>
<% multiple = @seminar.summary_chioice_type == "checkbox" %>
<% @seminar.summary_chioices.each_with_index do |c,i| %>
<label class="inline-label">
<input type="<%=@seminar.summary_chioice_type%>" name="<%=f.object_name%>[description]<%= (multiple ? '[]' : '')%>" value="<%=i%>" <%= "checked=checked" if check_choices.include?(i.to_s)%>>
<%=c%>
</label>
<% end %>
<% end %>
<% else %>
<%= f.text_area :description, rows: 5, :class=>"ckeditor input-medium form-control", :placeholder=> plc2 %>
<% end %>
</div>
</div>
<% end %>
<% if show3 %>
<div class="form-group" style="display: flex;justify-content: flex-end;text-align: right;">
<span style="margin-right: 0.5em;">
<label for="note" class="col-sm-2 control-label" style="display: contents;">
*<%= name3 %>
</label>
<br>
<%= "(#{plc3})" if !(plc3.to_s.blank?) %>
</span>
<div class="col-sm-10">
<label style="float: left;border-color: #666666" class="btn">
2021-11-29 03:11:30 +00:00
<%= f.file_field :file, :required => f.object.new_record?, :style=>"position: absolute;width: 0.00000001em;border: 0;margin: 0;padding: 0;" %>
<%= t('seminar_signup.load_file') %>
</label>
<div class="filename" style="float: left;margin-left: 0.3em; "><%= f.object["file"] if f.object.file.present? %></div>
</div>
</div>
<% end %>
<% @seminar.seminar_submission_fields.asc(:_id).each do |rf| %>
<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) %>
</div>
<% @form_index = @form_index +1 %>
<% end %>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="hidden" name="referer_url" value="<%= request.original_url.split(request.env["HTTP_HOST"]).last.split('?').first %>">
<input type="hidden" name="seminar_signup_contribute[seminar_signup_id]" value="<%= session[:seminar_signup_id] %>">
<%= f.submit "Submit", class: 'btn btn-primary', :id => 'button-mail' %>
<%= f.button "Delete", type: 'reset', class: 'btn' %>
</div>
</div>
</fieldset>
<script type="text/javascript">
$("input[type=\"file\"]").change(function(){
var file_name = "";
if($(this).prop("files").length != 0){
file_name = $(this).prop("files")[0].name;
}
$(this).parent().next(".filename").text(file_name)
})
$("form.form-horizontal").submit(function(){
var flag = true;
$("div[required=\"required\"]").each(function(i,v){
2022-01-11 02:21:11 +00:00
if($(v).find("input").length != 0 && $(v).find("input:checked").length == 0){
$(v).find("input").attr("required","required");
flag = false;
}else{
$(v).find("input").removeAttr("required");
}
})
return flag;
})
$("form.form-horizontal [type=\"submit\"]").click(function(){
var flag = true;
$("div[required=\"required\"]").each(function(i,v){
2022-01-11 02:21:11 +00:00
if($(v).find("input").length != 0 && $(v).find("input:checked").length == 0){
$(v).find("input").attr("required","required");
flag = false;
}else{
2022-01-11 02:21:11 +00:00
$(v).find("input").removeAttr("required");
}
})
return flag;
})
</script>
<style type="text/css">
.inline-label{
float: left;
cursor: pointer;
}
</style>