added enable option

This commit is contained in:
Harry Bomrah 2017-08-08 19:44:37 +08:00
parent c122fc27b4
commit b07152d872
3 changed files with 179 additions and 19 deletions

View File

@ -37,6 +37,23 @@ class Act
field :has_emergency_contact_person, :type => Boolean, :default => false
field :has_vegetarian, :type => Boolean, :default => false
field :enabled_name, :type => Boolean, :default => true
field :enabled_tel, :type => Boolean, :default => true
field :enabled_phone, :type => Boolean, :default => true
field :enabled_fax, :type => Boolean, :default => true
field :enabled_email, :type => Boolean, :default => true
field :enabled_idno, :type => Boolean, :default => false
field :enabled_sex, :type => Boolean, :default => false
field :enabled_birthday, :type => Boolean, :default => false
field :enabled_note, :type => Boolean, :default => false
field :enabled_organization, :type => Boolean, :default => false
field :enabled_title, :type => Boolean, :default => false
field :enabled_address, :type => Boolean, :default => false
field :enabled_emergency_contact_number, :type => Boolean, :default => false
field :enabled_emergency_contact_person, :type => Boolean, :default => false
field :enabled_vegetarian, :type => Boolean, :default => false
has_many :act_links, :autosave => true, :dependent => :destroy
has_many :act_files, :autosave => true, :dependent => :destroy
has_many :act_signups, :autosave => true, :dependent => :destroy

View File

@ -36,8 +36,9 @@
<%= @act.title %>
</div>
</div>
<!-- Name -->
<% if @act.enabled_name %>
<div class="form-group">
<label for="name" class="col-sm-2 control-label"><%= @act.has_name ? "*" : "" %><%= t('act_signup.name') %></label>
<div class="col-sm-10">
@ -48,8 +49,10 @@
<% end %>
</div>
</div>
<% end %>
<!-- IDNO -->
<% if @act.enabled_idno %>
<div class="form-group">
<label for="name" class="col-sm-2 control-label"><%= @act.has_idno ? "*" : "" %><%= t('act_signup.idno') %></label>
<div class="col-sm-10">
@ -60,9 +63,11 @@
<% end %>
</div>
</div>
<% end %>
<!-- Birthday -->
<% if @act.enabled_birthday %>
<div class="form-group">
<label for="birthday" class="col-sm-2 control-label"><%= @act.has_birthday ? "*" : "" %><%= t('act_signup.birthday') %></label>
<div class="col-sm-10">
@ -73,8 +78,10 @@
<% end %>
</div>
</div>
<% end %>
<!-- Sex -->
<% if @act.enabled_sex %>
<div class="form-group">
<label for="sex" class="col-sm-2 control-label"><%= @act.has_sex ? "*" : "" %><%= t('act_signup.sex') %></label>
<div class="col-sm-10">
@ -90,8 +97,10 @@
</label>
</div>
</div>
<% end %>
<!-- Tel -->
<% if @act.enabled_tel %>
<div class="form-group">
<label for="tel" class="col-sm-2 control-label"><%= @act.has_tel ? "*" : "" %><%= t('act_signup.tel') %></label>
<div class="col-sm-10">
@ -102,8 +111,10 @@
<% end %>
</div>
</div>
<% end %>
<!-- Phone -->
<% if @act.enabled_phone %>
<div class="form-group">
<label for="phone" class="col-sm-2 control-label"><%= @act.has_phone ? "*" : "" %><%= t('act_signup.phone') %></label>
<div class="col-sm-10">
@ -114,8 +125,10 @@
<% end %>
</div>
</div>
<% end %>
<!-- Fax -->
<% if @act.enabled_fax %>
<div class="form-group">
<label for="fax" class="col-sm-2 control-label"><%= @act.has_fax ? "*" : "" %><%= t('act_signup.fax') %></label>
<div class="col-sm-10">
@ -126,8 +139,10 @@
<% end %>
</div>
</div>
<% end %>
<!-- Email -->
<% if @act.enabled_email %>
<div class="form-group">
<label for="email" class="col-sm-2 control-label"><%= @act.has_email ? "*" : "" %><%= t(:email) %></label>
<div class="col-sm-10">
@ -138,8 +153,10 @@
<% end %>
</div>
</div>
<% end %>
<!-- Note -->
<% if @act.enabled_note %>
<div class="form-group">
<label for="note" class="col-sm-2 control-label"><%= @act.has_note ? "*" : "" %><%= t('act_signup.note') %></label>
<div class="col-sm-10">
@ -150,32 +167,38 @@
<% end %>
</div>
</div>
<% end %>
<!-- Organization -->
<% if @act.enabled_organization %>
<div class="form-group">
<label for="fax" class="col-sm-2 control-label"><%= @act.has_organization ? "*" : "" %><%= t('act_signup.organization') %></label>
<div class="col-sm-10">
<% if @act.has_fax %>
<% if @act.has_organization %>
<%= f.text_field :organization, :class=>"input-medium form-control", :placeholder=> t('act_signup.organization'), :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty.;"} %>
<% else %>
<%= f.text_field :organization, :class=>"input-medium form-control", :placeholder=> t('act_signup.organization') %>
<% end %>
</div>
</div>
<% end %>
<!-- Title -->
<% if @act.enabled_title %>
<div class="form-group">
<label for="fax" class="col-sm-2 control-label"><%= @act.has_title ? "*" : "" %><%= t('act_signup.title') %></label>
<div class="col-sm-10">
<% if @act.has_fax %>
<% if @act.has_title %>
<%= f.text_field :title, :class=>"input-medium form-control", :placeholder=> t('act_signup.title'), :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty.;"} %>
<% else %>
<%= f.text_field :title, :class=>"input-medium form-control", :placeholder=> t('act_signup.title') %>
<% end %>
</div>
</div>
<% end %>
<!-- Address -->
<% if @act.enabled_address %>
<div class="form-group">
<label for="note" class="col-sm-2 control-label"><%= @act.has_address ? "*" : "" %><%= t('act_signup.address') %></label>
<div class="col-sm-10">
@ -186,32 +209,38 @@
<% end %>
</div>
</div>
<% end %>
<!-- Emergency Contact Person -->
<% if @act.enabled_emergency_contact_person %>
<div class="form-group">
<label for="fax" class="col-sm-2 control-label"><%= @act.has_emergency_contact_person ? "*" : "" %><%= t('act_signup.emergency_contact_person') %></label>
<div class="col-sm-10">
<% if @act.has_fax %>
<% if @act.has_emergency_contact_person %>
<%= f.text_field :emergency_contact_person, :class=>"input-medium form-control", :placeholder=> t('act_signup.emergency_contact_person'), :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty.;"} %>
<% else %>
<%= f.text_field :emergency_contact_person, :class=>"input-medium form-control", :placeholder=> t('act_signup.emergency_contact_person') %>
<% end %>
</div>
</div>
<% end %>
<!-- Emergency Contact Number -->
<% if @act.enabled_emergency_contact_number %>
<div class="form-group">
<label for="fax" class="col-sm-2 control-label"><%= @act.has_emergency_contact_number ? "*" : "" %><%= t('act_signup.emergency_contact_number') %></label>
<div class="col-sm-10">
<% if @act.has_fax %>
<% if @act.has_emergency_contact_number %>
<%= f.text_field :emergency_contact_number, :class=>"input-medium form-control", :placeholder=> t('act_signup.emergency_contact_number'), :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty.;"} %>
<% else %>
<%= f.text_field :emergency_contact_number, :class=>"input-medium form-control", :placeholder=> t('act_signup.emergency_contact_number') %>
<% end %>
</div>
</div>
<% end %>
<!-- Vegetarian -->
<% if @act.enabled_vegetarian %>
<div class="form-group">
<label for="sex" class="col-sm-2 control-label"><%= @act.has_vegetarian ? "*" : "" %><%= t('act_signup.vegetarian') %></label>
<div class="col-sm-10">
@ -227,6 +256,7 @@
</label>
</div>
</div>
<% end %>
<!-- 驗證碼 -->
<div class="form-group">

View File

@ -80,6 +80,13 @@
<div class="control-group">
<label class="control-label muted"><%= t('act.has_name') %></label>
<div class="controls">
<label for="act_enabled_name" class="checkbox inline">
<%= f.check_box :enabled_name, :class => "enabler" %>
Enable
</label>
</div>
<div class="controls required">
<label class="radio inline">Required</label>
<label class="radio inline"><%= f.radio_button :has_name, "yes", checked: @act.has_name == true ? true : false %><%= t(:yes_) %></label>
<label class="radio inline"><%= f.radio_button :has_name, "no", checked: @act.has_name == false ? true : false %><%= t(:no_) %></label>
</div>
@ -89,6 +96,13 @@
<div class="control-group">
<label class="control-label muted"><%= t('act.has_tel') %></label>
<div class="controls">
<label for="act_enabled_tel" class="checkbox inline">
<%= f.check_box :enabled_tel, :class => "enabler" %>
Enable
</label>
</div>
<div class="controls required" <%= !@act.enabled_tel ? "style=display:none;" : "" %>>
<label class="radio inline">Required</label>
<label class="radio inline"><%= f.radio_button :has_tel, "yes", checked: @act.has_tel == true ? true : false %><%= t(:yes_) %></label>
<label class="radio inline"><%= f.radio_button :has_tel, "no", checked: @act.has_tel == false ? true : false %><%= t(:no_) %></label>
</div>
@ -98,6 +112,13 @@
<div class="control-group">
<label class="control-label muted"><%= t('act.has_phone') %></label>
<div class="controls">
<label for="act_enabled_phone" class="checkbox inline">
<%= f.check_box :enabled_phone, :class => "enabler" %>
Enable
</label>
</div>
<div class="controls required" <%= !@act.enabled_phone ? "style=display:none;" : "" %>>
<label class="radio inline">Required</label>
<label class="radio inline"><%= f.radio_button :has_phone, "yes", checked: @act.has_phone == true ? true : false %><%= t(:yes_) %></label>
<label class="radio inline"><%= f.radio_button :has_phone, "no", checked: @act.has_phone == false ? true : false %><%= t(:no_) %></label>
</div>
@ -107,6 +128,13 @@
<div class="control-group">
<label class="control-label muted"><%= t('act.has_fax') %></label>
<div class="controls">
<label for="act_enabled_fax" class="checkbox inline">
<%= f.check_box :enabled_fax, :class => "enabler" %>
Enable
</label>
</div>
<div class="controls required" <%= !@act.enabled_fax ? "style=display:none;" : "" %>>
<label class="radio inline">Required</label>
<label class="radio inline"><%= f.radio_button :has_fax, "yes", checked: @act.has_fax == true ? true : false %><%= t(:yes_) %></label>
<label class="radio inline"><%= f.radio_button :has_fax, "no", checked: @act.has_fax == false ? true : false %><%= t(:no_) %></label>
</div>
@ -116,6 +144,13 @@
<div class="control-group">
<label class="control-label muted"><%= t('act.has_email') %></label>
<div class="controls">
<label for="act_enabled_email" class="checkbox inline">
<%= f.check_box :enabled_email, :class => "enabler" %>
Enable
</label>
</div>
<div class="controls required" <%= !@act.enabled_email ? "style=display:none;" : "" %>>
<label class="radio inline">Required</label>
<label class="radio inline"><%= f.radio_button :has_email, "yes", checked: @act.has_email == true ? true : false %><%= t(:yes_) %></label>
<label class="radio inline"><%= f.radio_button :has_email, "no", checked: @act.has_email == false ? true : false %><%= t(:no_) %></label>
</div>
@ -125,6 +160,13 @@
<div class="control-group">
<label class="control-label muted"><%= t('act.has_idno') %></label>
<div class="controls">
<label for="act_enabled_idno" class="checkbox inline">
<%= f.check_box :enabled_idno, :class => "enabler" %>
Enable
</label>
</div>
<div class="controls required" <%= !@act.enabled_idno ? "style=display:none;" : "" %>>
<label class="radio inline">Required</label>
<label class="radio inline"><%= f.radio_button :has_idno, "yes", checked: @act.has_idno == true ? true : false %><%= t(:yes_) %></label>
<label class="radio inline"><%= f.radio_button :has_idno, "no", checked: @act.has_idno == false ? true : false %><%= t(:no_) %></label>
</div>
@ -134,6 +176,13 @@
<div class="control-group">
<label class="control-label muted"><%= t('act.has_sex') %></label>
<div class="controls">
<label for="act_enabled_sex" class="checkbox inline">
<%= f.check_box :enabled_sex, :class => "enabler" %>
Enable
</label>
</div>
<div class="controls required" <%= !@act.enabled_sex ? "style=display:none;" : "" %>>
<label class="radio inline">Required</label>
<label class="radio inline"><%= f.radio_button :has_sex, "yes", checked: @act.has_sex == true ? true : false %><%= t(:yes_) %></label>
<label class="radio inline"><%= f.radio_button :has_sex, "no", checked: @act.has_sex == false ? true : false %><%= t(:no_) %></label>
</div>
@ -144,6 +193,13 @@
<div class="control-group">
<label class="control-label muted"><%= t('act.has_birthday') %></label>
<div class="controls">
<label for="act_enabled_birthday" class="checkbox inline">
<%= f.check_box :enabled_birthday, :class => "enabler" %>
Enable
</label>
</div>
<div class="controls required" <%= !@act.enabled_birthday ? "style=display:none;" : "" %>>
<label class="radio inline">Required</label>
<label class="radio inline"><%= f.radio_button :has_birthday, "yes", checked: @act.has_birthday == true ? true : false %><%= t(:yes_) %></label>
<label class="radio inline"><%= f.radio_button :has_birthday, "no", checked: @act.has_birthday == false ? true : false %><%= t(:no_) %></label>
</div>
@ -153,6 +209,13 @@
<div class="control-group">
<label class="control-label muted"><%= t('act.has_note') %></label>
<div class="controls">
<label for="act_enabled_note" class="checkbox inline">
<%= f.check_box :enabled_note, :class => "enabler" %>
Enable
</label>
</div>
<div class="controls required" <%= !@act.enabled_note ? "style=display:none;" : "" %>>
<label class="radio inline">Required</label>
<label class="radio inline"><%= f.radio_button :has_note, "yes", checked: @act.has_note == true ? true : false %><%= t(:yes_) %></label>
<label class="radio inline"><%= f.radio_button :has_note, "no", checked: @act.has_note == false ? true : false %><%= t(:no_) %></label>
</div>
@ -162,6 +225,13 @@
<div class="control-group">
<label class="control-label muted"><%= t('act.has_organization') %></label>
<div class="controls">
<label for="act_enabled_organization" class="checkbox inline">
<%= f.check_box :enabled_organization, :class => "enabler" %>
Enable
</label>
</div>
<div class="controls required" <%= !@act.enabled_organization ? "style=display:none;" : "" %>>
<label class="radio inline">Required</label>
<label class="radio inline"><%= f.radio_button :has_organization, "yes", checked: @act.has_organization == true ? true : false %><%= t(:yes_) %></label>
<label class="radio inline"><%= f.radio_button :has_organization, "no", checked: @act.has_organization == false ? true : false %><%= t(:no_) %></label>
</div>
@ -171,6 +241,13 @@
<div class="control-group">
<label class="control-label muted"><%= t('act.has_title') %></label>
<div class="controls">
<label for="act_enabled_title" class="checkbox inline">
<%= f.check_box :enabled_title, :class => "enabler" %>
Enable
</label>
</div>
<div class="controls required" <%= !@act.enabled_title ? "style=display:none;" : "" %>>
<label class="radio inline">Required</label>
<label class="radio inline"><%= f.radio_button :has_title, "yes", checked: @act.has_title == true ? true : false %><%= t(:yes_) %></label>
<label class="radio inline"><%= f.radio_button :has_title, "no", checked: @act.has_title == false ? true : false %><%= t(:no_) %></label>
</div>
@ -180,6 +257,13 @@
<div class="control-group">
<label class="control-label muted"><%= t('act.has_address') %></label>
<div class="controls">
<label for="act_enabled_address" class="checkbox inline">
<%= f.check_box :enabled_address, :class => "enabler" %>
Enable
</label>
</div>
<div class="controls required" <%= !@act.enabled_address ? "style=display:none;" : "" %>>
<label class="radio inline">Required</label>
<label class="radio inline"><%= f.radio_button :has_address, "yes", checked: @act.has_address == true ? true : false %><%= t(:yes_) %></label>
<label class="radio inline"><%= f.radio_button :has_address, "no", checked: @act.has_address == false ? true : false %><%= t(:no_) %></label>
</div>
@ -189,6 +273,13 @@
<div class="control-group">
<label class="control-label muted"><%= t('act.has_emergency_contact_number') %></label>
<div class="controls">
<label for="act_enabled_emergency_contact_number" class="checkbox inline">
<%= f.check_box :enabled_emergency_contact_number, :class => "enabler" %>
Enable
</label>
</div>
<div class="controls required" <%= !@act.enabled_emergency_contact_number ? "style=display:none;" : "" %>>
<label class="radio inline">Required</label>
<label class="radio inline"><%= f.radio_button :has_emergency_contact_number, "yes", checked: @act.has_emergency_contact_number == true ? true : false %><%= t(:yes_) %></label>
<label class="radio inline"><%= f.radio_button :has_emergency_contact_number, "no", checked: @act.has_emergency_contact_number == false ? true : false %><%= t(:no_) %></label>
</div>
@ -198,6 +289,13 @@
<div class="control-group">
<label class="control-label muted"><%= t('act.has_emergency_contact_person') %></label>
<div class="controls">
<label for="act_enabled_emergency_contact_person" class="checkbox inline">
<%= f.check_box :enabled_emergency_contact_person, :class => "enabler" %>
Enable
</label>
</div>
<div class="controls required" <%= !@act.enabled_emergency_contact_person ? "style=display:none;" : "" %>>
<label class="radio inline">Required</label>
<label class="radio inline"><%= f.radio_button :has_emergency_contact_person, "yes", checked: @act.has_emergency_contact_person == true ? true : false %><%= t(:yes_) %></label>
<label class="radio inline"><%= f.radio_button :has_emergency_contact_person, "no", checked: @act.has_emergency_contact_person == false ? true : false %><%= t(:no_) %></label>
</div>
@ -207,6 +305,13 @@
<div class="control-group">
<label class="control-label muted"><%= t('act.has_vegetarian') %></label>
<div class="controls">
<label for="act_enabled_vegetarian" class="checkbox inline">
<%= f.check_box :enabled_vegetarian, :class => "enabler" %>
Enable
</label>
</div>
<div class="controls required" <%= !@act.enabled_vegetarian ? "style=display:none;" : "" %>>
<label class="radio inline">Required</label>
<label class="radio inline"><%= f.radio_button :has_vegetarian, "yes", checked: @act.has_vegetarian == true ? true : false %><%= t(:yes_) %></label>
<label class="radio inline"><%= f.radio_button :has_vegetarian, "no", checked: @act.has_vegetarian == false ? true : false %><%= t(:no_) %></label>
</div>
@ -351,6 +456,14 @@
<% content_for :page_specific_javascript do %>
<script>
$(function() {
$(".enabler").on("click",function(){
var parent = $(this).parent().parent().parent();
if($(this).is(":checked")){
parent.find(".required").show();
}else{
parent.find(".required").hide();
}
})
$("#main-wrap").after("");
$(document).on('click', '#add_link', function(){