property_hire/app/views/admin/property_hires/_form.html.erb

610 lines
30 KiB
Plaintext

<%
hire_method = Admin::PropertyHiresHelper::HireMethod
hire_method.set_input_name('property')
%>
<style type="text/css">
.tab-panel > .tab-content{
display: none;
}
.tab-panel > .tab-content.active{
display: block;
}
.tab-panel{
display: flex;
flex-wrap: wrap;
}
.label_left{
float: left;
margin-right: 0.5em;
}
.select_field_block{
border: 0.2em solid #666;
padding: 1em;
}
.remove_btn:hover{
font-size: 1.3em;
}
.remove_btn{
cursor: pointer;
}
</style>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<!-- Input Area -->
<div class="input-area">
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li class="active"><a href="#basic" data-toggle="tab"><%= t(:basic) %></a></li>
<li><a href="#tag" data-toggle="tab"><%= t(:tags) %></a></li>
<li><a href="#imageupload" data-toggle="tab"><%= t(:image) %></a></li>
<li><a href="#unavailability" data-toggle="tab"><%= t('property_hire.unavailability')%></a></li>
<li><a href="#auto_send_email_set" data-toggle="tab"><%= t('property_hire.auto_send_email_set') %></a></li>
<li><a href="#settings" data-toggle="tab"><%= t('property_hire.settings') %></a></li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<!-- Category -->
<div class="control-group">
<label class="control-label muted"><%= t(:category) %></label>
<div class="controls">
<%= select_category(f, @module_app) %>
</div>
</div>
<div class="control-group">
<%= f.label :property_location, t("property_hire.property_location"), :class => "control-label muted" %>
<div class="controls">
<% if @property.new_record? %>
<%= f.select :property_location, @locations %>
<% elsif @property.property_location.nil? %>
<%= f.select :property_location, @locations, {:selected => "other_location"} %>
<% else %>
<%= f.select :property_location, @locations %>
<% end %>
</div>
</div>
<div class="control-group" id="other-location-div" style="<%= @property.new_record? || !@property.property_location.nil? ? "display: none;" : "" %>">
<%= f.label :other_location, t("property_hire.other_location"), :class => "control-label muted" %>
<div class="controls">
<%= f.text_field :other_location %>
</div>
</div>
<div class="control-group">
<%= f.label :property_number, t("property_hire.property_number"), :class => "control-label muted" %>
<div class="controls">
<%= f.text_field :property_number %>
</div>
</div>
<div class="control-group">
<%= f.label :can_be_hired, t("property_hire.can_be_hired"), :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :can_be_hired %>
</div>
</div>
<div class="control-group">
<%= f.label :purchase_date, t("property_hire.purchase_date"), :class => "control-label muted" %>
<div class="controls">
<%= f.datetime_picker :purchase_date, :no_label => true, :new_record => @property.new_record?, :picker_type => "date", :format => "yyyy/MM/dd" %>
</div>
</div>
<div class="control-group">
<%= f.label :owners, t("property_hire.owners"), :class => "control-label muted" %>
<div class="controls">
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'property[owners][]', email_members: @property.owner_profiles} %>
</div>
</div>
<div class="control-group">
<%= f.label :other_owner, t("property_hire.other_owner"), :class => "control-label muted" %>
<div class="controls">
<%= f.text_field :other_owner %>
</div>
</div>
<div class="control-group">
<%= f.label :owner_email, t("property_hire.owner_email"), :class => "control-label muted" %>
<div class="controls">
<%= f.text_field :owner_email %>
</div>
</div>
<div class="control-group">
<%= f.label :owner_phone, t("property_hire.owner_phone"), :class => "control-label muted" %>
<div class="controls">
<%= f.text_field :owner_phone %>
</div>
</div>
<div class="control-group">
<%= f.label :price, t("property_hire.price"), :class => "control-label muted" %>
<div class="controls">
<%= f.text_field :price %>
</div>
</div>
</div>
<!-- tags -->
<div class="tab-pane fade" id="tag">
<div class="control-group">
<label class="control-label muted"><%= t(:tags) %></label>
<%= select_tags(f, @module_app) %>
</div>
</div>
<!-- image -->
<div class="tab-pane fade" id="imageupload">
<div class="control-group">
<label class="control-label muted"><%= t(:image) %></label>
<div class="controls">
<div class="fileupload fileupload-new clearfix <%= 'fileupload-edit' if @property.image.file %>" data-provides="fileupload">
<div class="fileupload-new thumbnail pull-left">
<% if @property.image.file %>
<%= image_tag @property.image %>
<% else %>
<img src="http://www.placehold.it/50x50/EFEFEF/AAAAAA" />
<% end %>
</div>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<span class="btn btn-file">
<span class="fileupload-new"><%= t(:select_image) %></span>
<span class="fileupload-exists"><%= t(:change) %></span>
<%= f.file_field :image %>
</span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn btn-danger fileupload-remove">
<%= f.check_box :remove_image %><%= t(:remove) %>
</label>
</div>
</div>
</div>
</div>
</div>
<!-- Email Set Module -->
<div class="tab-pane fade" id="auto_send_email_set" style="padding: 1.2em;">
<ul class="nav nav-pills module-nav">
<li class="active">
<a href="#email_set0" data-toggle="tab">
<%= t('property_hire.hire') %>
</a>
</li>
<li class="">
<a href="#email_set1" data-toggle="tab">
<%= t('property_hire.edit') %>
</a>
</li>
<li class="">
<a href="#email_set2" data-toggle="tab">
<%= t('property_hire.delete') %>
</a>
</li>
</ul>
<div class="tab-content">
<% (0..2).each do |index1| %>
<% active_email_set = index1==0 ? ' active' : '' %>
<div class="tab-pane<%= active_email_set %>" id="email_set<%= index1 %>" style="padding: 1.2em;">
<table style="width:100%;">
<tbody>
<tr>
<td>
<%= t('disable') %>
</td>
<td>
<input type="hidden" class="field_set" name='<%= "property[hire_email_sets][#{index1}][disabled]" %>' value="false">
<%= check_box_tag("property[hire_email_sets][#{index1}][disabled]", true ,@email_set[index1].disabled) %>
</td>
</tr>
<tr>
<td>
<%= t('property_hire.email_title') %>
</td>
<td>
<%= hire_method.show_set_field(@email_set[index1].id,@email_set[index1]['title'],'hire_email_sets',index1,'title','text_field',action_name != 'new') %>
</td>
</tr>
<tr>
<td>
<%= t('property_hire.email_content') %>
</td>
<td>
<div class="form-group">
<%= hire_method.show_set_field(@email_set[index1].id,@email_set[index1]['content'],'hire_email_sets',index1,'content','text_area',action_name != 'new') %>
</div>
<%= hidden_field_tag("property[hire_email_sets][#{index1}][field_name]",@email_set[index1]['field_name']) %>
<%= hidden_field_tag("property[hire_email_sets][#{index1}][property_id]",@property.id) %>
</td>
</tr>
</tbody>
</table>
</div>
<% end %>
</div>
</div>
<!-- unavailability -->
<div class="tab-pane fade" id="unavailability">
<div class="control-group">
<%= f.label :set_unavailibility, t("property_hire.set_unavailibility"), :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :set_unavailibility %>
</div>
</div>
<% if @property.new_record? %>
<div id="set_unavailibility_div" style="display: none;">
<% elsif @property.set_unavailibility %>
<div id="set_unavailibility_div">
<% else %>
<div id="set_unavailibility_div" style="display: none;">
<% end %>
<div class="control-group">
<%= f.label :start_time, t("property_hire.start_time"), :class => "control-label muted" %>
<div class="controls">
<%= f.datetime_picker :start_time, :picker_type => "time", :no_label => true, :new_record => @property.new_record?, :value => (Time.parse(@property.start_time) rescue "") %>
</div>
</div>
<div class="control-group">
<%= f.label :end_time, t("property_hire.end_time"), :class => "control-label muted" %>
<div class="controls">
<%= f.datetime_picker :end_time, :picker_type => "time", :no_label => true, :new_record => @property.new_record?, :value => (Time.parse(@property.end_time) rescue "") %>
</div>
</div>
<div class="control-group">
<label class="control-label muted">Weekdays</label>
<div class="controls">
<% weekdays = @property.weekdays rescue [] %>
<label for="sunday">
<input id="sunday" type="checkbox" name="property[weekdays][]" value="0" <%= weekdays.include?("0") ? "checked=checked" : "" %> /> Sunday
</label>
<label for="monday">
<input id="monday" type="checkbox" name="property[weekdays][]" value="1" <%= weekdays.include?("1") ? "checked=checked" : "" %> /> Monday
</label>
<label for="tuesday">
<input id="tuesday" type="checkbox" name="property[weekdays][]" value="2" <%= weekdays.include?("2") ? "checked=checked" : "" %> /> Tuesday
</label>
<label for="wednesday">
<input id="wednesday" type="checkbox" name="property[weekdays][]" value="3" <%= weekdays.include?("3") ? "checked=checked" : "" %> /> Wednesday
</label>
<label for="thursday">
<input id="thursday" type="checkbox" name="property[weekdays][]" value="4" <%= weekdays.include?("4") ? "checked=checked" : "" %> /> Thursday
</label>
<label for="friday">
<input id="friday" type="checkbox" name="property[weekdays][]" value="5" <%= weekdays.include?("5") ? "checked=checked" : "" %> /> Friday
</label>
<label for="saturday">
<input id="saturday" type="checkbox" name="property[weekdays][]" value="6" <%= weekdays.include?("6") ? "checked=checked" : "" %> /> Saturday
</label>
</div>
</div>
<div class="control-group">
<%= f.label :start_date, t("property_hire.start_date"), :class => "control-label muted" %>
<div class="controls">
<%= f.datetime_picker :start_date, :picker_type => "date", :no_label => true, :new_record => @property.new_record?, :data=>{"picker-type" => "range", "range" => "start"}, :format => "yyyy/MM/dd" %>
</div>
</div>
<div class="control-group">
<%= f.label :end_date, t("property_hire.end_date"), :class => "control-label muted" %>
<div class="controls">
<%= f.datetime_picker :end_date, :picker_type => "date", :no_label => true, :new_record => @property.new_record?, :data=>{"picker-type" => "range", "range" => "end"}, :format => "yyyy/MM/dd" %>
</div>
</div>
<% @site_in_use_locales.each do |locale| %>
<%= f.fields_for :description_translations do |f| %>
<div class="control-group">
<label class="control-label muted" for="description_<%= locale.to_s %>"><%= t(:description) + " (#{t(locale.to_s)})" %></label>
<div class="controls">
<%= f.text_field locale, value: (@property.description_translations[locale.to_s] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
<% @site_in_use_locales.each do |locale| %>
<%= f.fields_for :unavailibility_note_translations do |f| %>
<div class="control-group">
<label class="control-label muted" for="note_<%= locale.to_s %>"><%= t(:note) + " (#{t(locale.to_s)})" %></label>
<div class="controls">
<%= f.text_area locale, value: (@property.unavailibility_note_translations[locale.to_s] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
<div class="tab-pane fade" id="settings">
<% fields_name = ["organization" ,"person_in_charge" , "tel_of_person_in_charge" , "department" , "contact_person" , "tel_of_contact_person" , "mobile_phone_of_contact_person" , "contact_person_Email" , "contact_person_department"] %>
<% fields_name.each do |field_name| %>
<div class="control-group">
<label class="control-label muted"><%= t("property_hire.#{field_name}") %></label>
<div class="controls">
<label for="act_enabled_name" class="checkbox inline">
<%= hidden_field_tag "property[#{field_name}][enable]", "0" %>
<%= f.check_box_tag "property[#{field_name}][enable]", "1" , (@property[field_name]["enable"] == "1" rescue false) %>
Enable
</label>
</div>
<div class="controls required">
<label class="radio inline"><%= t("property_hire.required") %></label>
<%= f.fields_for field_name do |sub_f|%>
<label class="radio inline"><%= sub_f.radio_button "required", "true", checked: ((@property[field_name]["required"] rescue "false") == "true") %><%= t(:yes_) %></label>
<label class="radio inline"><%= sub_f.radio_button "required", "false", checked: ((@property[field_name]["required"] rescue "false") == "false") %><%= t(:no_) %></label>
<% end %>
</div>
</div>
<% end %>
<hr style="border-color: black; ">
<div class="control-group">
<% field_name = "enable_notes_selector" %>
<label class="control-label muted"><%= t("property_hire.#{field_name}") %></label>
<div class="controls">
<label for="act_enabled_name" class="checkbox inline">
<%= hidden_field_tag "property[#{field_name}]", "0" %>
<%= f.check_box_tag "property[#{field_name}]", "1" , (@property[field_name] rescue false) %>
Enable
</label>
</div>
</div>
<div class="control-group" id="selector_block">
<% field_name = "notes_selector" %>
<label class="control-label muted"><%= t("property_hire.#{field_name}") %></label>
<div class="controls">
<div id="select_choice_block">
<% @property[field_name].each do |index,sub_hash| %>
<div id="select_choice<%=index.to_s%>" class="select_field_block">
<span class="remove_btn">❌</span>
<div class="field_name_block">
<div>
<label for="select_choice_type_index<%=index.to_s%>" class="label_left"><%=t("property_hire.field_type")%>:</label>
<select name="<%="property[#{field_name}][#{index}][type]"%>">
<option value="radio" <%=(@property["#{field_name}"]["#{index}"]["type"] == "radio") ? 'selected="selected"' : ''%>><%=t("property_hire.radio")%></option>
<option value="checkbox" <%=(@property["#{field_name}"]["#{index}"]["type"] == "checkbox") ? 'selected="selected"' : ''%>><%=t("property_hire.checkbox")%></option>
</select>
</div>
<div><label for="select_choice_name_index<%=index.to_s%>" class="label_left"><%=t("property_hire.field_name")%>:</label>
<div class="input-append">
<div class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="select_choice_name_index<%=index%>_<%=locale.to_s%>">
<input type="text" value="<%=sub_hash['name'][locale.to_s] rescue ''%>" name="<%="property[#{field_name}][#{index}][name][#{locale}]"%>">
</div>
<% end %>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#select_choice_name_index<%=index%>_<%=locale.to_s%>" data-toggle="tab"><%= t(locale.to_s) %></a>
<% end %>
</div>
</div>
</div>
</div>
<div class="field_value_block">
<label><%=t("property_hire.field_value")%></label>
<% @property["#{field_name}"]["#{index}"]["value"].values.first.each_with_index do |v,val_index|%>
<div class="value_choice">
<span class="remove_btn">❌</span>
<div class="input-append">
<div class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="select_choice_value_index<%=index.to_s%>_<%=locale.to_s%>_<%=val_index%>">
<input type="text" name="property[notes_selector][<%=index.to_s%>][value][<%=locale.to_s%>][]" value="<%=@property["#{field_name}"][index.to_s]["value"][locale.to_s][val_index]%>">
</div>
<% end %>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#select_choice_value_index<%=index.to_s%>_<%=locale.to_s%>_<%=val_index%>" data-toggle="tab"><%= t(locale.to_s) %></a>
<% end %>
</div>
</div>
</div>
<% end %>
<div style="clear: both;"></div>
<a class="btn btn-primary add_choice" data-index="<%=index.to_s%>"><%=t("property_hire.add_choice")%></a>
</div>
</div>
<% end %>
</div>
<a id="add_note_select_field" class="btn btn-primary"><%=t(:add)%></a>
</div>
</div>
</div>
</div>
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
</li>
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- Title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("property_hire.title") %></label>
<div class="controls">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("property_hire.title"), value: (@property.title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<div class="control-group input-title">
<label class="control-label muted"><%= t("property_hire.property_usage") %></label>
<div class="controls">
<%= f.fields_for :property_usage_translations do |f| %>
<%= f.text_area locale, class: "input-block-level", placeholder: t("property_hire.property_usage"), value: (@property.property_usage_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<div class="control-group input-title">
<label class="control-label muted"><%= t("property_hire.note") %></label>
<div class="controls">
<%= f.fields_for :note_translations do |f| %>
<%= f.text_area locale, class: "input-block-level", placeholder: t("property_hire.note"), value: (@property.note_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
<% end %>
</div>
<!-- Form Actions -->
<div class="form-actions">
<% if params[:page] %>
<input type="hidden" name="page" value="<%= params[:page] %>" />
<% end %>
<%= hidden_field_tag("property[id]",@property.id) %>
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= link_to t('cancel'), admin_property_hires_path, :class=>"btn" %>
</div>
<script type="text/javascript">
$(document).ready(function(){
if($("[type=checkbox][name='property[enable_notes_selector]']:checked").length == 0){
$("#selector_block").css("display","none");
}else{
$("#selector_block").css("display","");
}
})
$("#property_set_unavailibility").on("click",function(){
if($(this).is(":checked")){
$("#set_unavailibility_div").show();
}else{
$("#set_unavailibility_div").hide();
}
})
$("#property_property_location").on("change",function(){
if($(this).val() == "other_location"){
$("#other-location-div").show();
}else{
$("#other-location-div").hide();
}
})
$("#add_note_select_field").on("click",function(){
var index = ($("#select_choice_block").find(">div").length == 0) ? 0 : (Number($("#select_choice_block").find(">div").eq(-1).attr("id").split("select_choice").last()) + 1);
$("#select_choice_block").append('<div id="select_choice'+String(index)+'" class="select_field_block"><span class="remove_btn">❌</span>'+
'<div class="field_name_block">'+
'<div>'+
'<label for="select_choice_type_index'+String(index)+'" class="label_left"><%=t("property_hire.field_type")%>:</label>'+
'<select name="property[notes_selector]['+String(index)+'][type]">'+
'<option value="radio"><%=t("property_hire.radio")%></option>'+
'<option value="checkbox"><%=t("property_hire.checkbox")%></option>'+
'</select>'+
'</div>'+
'<div><label for="select_choice_name_index'+String(index)+'" class="label_left"><%=t("property_hire.field_name")%>:</label>'+
'<div class="input-append" id="select_choice_name_index'+String(index)+'">'+
'<div class="tab-content">'+
<% @site_in_use_locales.each_with_index do |locale, i| %>
'<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="select_choice_name_index'+String(index)+'_<%=locale.to_s%>">'+
'<input type="text" name="property[notes_selector]['+String(index)+'][name][<%=locale.to_s%>]">'+
'</div>'+
<% end %>
'</div>'+
'<div class="btn-group" data-toggle="buttons-radio">'+
<% @site_in_use_locales.each_with_index do |locale, i| %>
'<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#select_choice_name_index'+String(index)+'_<%=locale.to_s%>" data-toggle="tab"><%= t(locale.to_s) %></a>'+
<% end %>
'</div>'+
'</div>'+
'</div>'+
'</div>'+
'<div class="field_value_block">'+
'<label><%=t("property_hire.field_value")%></label>'+
'<div class="value_choice">'+
'<span class="remove_btn">❌</span>'+
'<div class="input-append">'+
'<div class="tab-content">'+
<% @site_in_use_locales.each_with_index do |locale, i| %>
'<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="select_choice_value_index'+String(index)+'_<%=locale.to_s%>_0">'+
'<input type="text" name="property[notes_selector]['+String(index)+'][value][<%=locale.to_s%>][]">'+
'</div>'+
<% end %>
'</div>'+
'<div class="btn-group" data-toggle="buttons-radio">'+
<% @site_in_use_locales.each_with_index do |locale, i| %>
'<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#select_choice_value_index'+String(index)+'_<%=locale.to_s%>_0" data-toggle="tab"><%= t(locale.to_s) %></a>'+
<% end %>
'</div>'+
'</div>'+
'</div>'+
'<div style="clear: both;"></div>'+
'<a class="btn btn-primary add_choice" data-index="'+String(index)+'"><%=t("property_hire.add_choice")%></a>'+
'</div>'+
'</div>');
$(".add_choice").off("click").on("click",function(){
var index = $(this).attr("data-index");
var val_index = $(this).siblings(".value_choice").length;
var $last_item = $(this).siblings(".value_choice").eq(-1);
if(val_index == 0){
$last_item = $(this).siblings("label").eq(-1);
}
$last_item.after('<div class="value_choice"><span class="remove_btn">❌</span><div class="input-append">'+
'<div class="tab-content">'+
<% @site_in_use_locales.each_with_index do |locale, i| %>
'<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="select_choice_value_index'+String(index)+'_<%=locale.to_s%>_'+String(val_index)+'">'+
'<input type="text" name="property[notes_selector]['+String(index)+'][value][<%=locale.to_s%>][]">'+
'</div>'+
<% end %>
'</div>'+
'<div class="btn-group" data-toggle="buttons-radio">'+
<% @site_in_use_locales.each_with_index do |locale, i| %>
'<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#select_choice_value_index'+String(index)+'_<%=locale.to_s%>_'+String(val_index)+'" data-toggle="tab"><%= t(locale.to_s) %></a>'+
<% end %>
'</div>'+
'</div></div>');
$(".remove_btn").off("click").on("click",function(){
$(this).parent().remove();
})
})
$(".remove_btn").off("click").on("click",function(){
$(this).parent().remove();
})
})
$(".add_choice").off("click").on("click",function(){
var index = $(this).attr("data-index");
var val_index = $(this).siblings(".value_choice").length;
var $last_item = $(this).siblings(".value_choice").eq(-1);
if(val_index == 0){
$last_item = $(this).siblings("label").eq(-1);
}
$last_item.after('<div class="value_choice"><span class="remove_btn">❌</span><div class="input-append">'+
'<div class="tab-content">'+
<% @site_in_use_locales.each_with_index do |locale, i| %>
'<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="select_choice_value_index'+String(index)+'_<%=locale.to_s%>_'+String(val_index)+'">'+
'<input type="text" name="property[notes_selector]['+String(index)+'][value][<%=locale.to_s%>][]">'+
'</div>'+
<% end %>
'</div>'+
'<div class="btn-group" data-toggle="buttons-radio">'+
<% @site_in_use_locales.each_with_index do |locale, i| %>
'<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#select_choice_value_index'+String(index)+'_<%=locale.to_s%>_'+String(val_index)+'" data-toggle="tab"><%= t(locale.to_s) %></a>'+
<% end %>
'</div>'+
'</div></div>');
$(".remove_btn").off("click").on("click",function(){
$(this).parent().remove();
})
});
$(".remove_btn").off("click").on("click",function(){
$(this).parent().remove();
})
$("[type=checkbox][name='property[enable_notes_selector]']").click(function(){
if(!$(this).prop("checked")){
$("#selector_block").css("display","none");
}else{
$("#selector_block").css("display","");
}
})
</script>