847 lines
40 KiB
Plaintext
847 lines
40 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;
|
|
}
|
|
.card-header a{
|
|
text-align: center;
|
|
display: block;
|
|
}
|
|
.card-header:hover{
|
|
background: aquamarine;
|
|
}
|
|
.card-header:hover a{
|
|
text-decoration: none;
|
|
}
|
|
.add_weekday_setting{
|
|
text-align: center;
|
|
align-self: center;
|
|
}
|
|
.time_setting_form, .image_group{
|
|
border: 0.2em solid #333;
|
|
padding-top: 0;
|
|
}
|
|
.add-on.iconbtn{
|
|
display: none;
|
|
}
|
|
.time_setting_form:last-child, .image_group:last-child {
|
|
margin-bottom: 1em;
|
|
}
|
|
.card-header {
|
|
padding: 0;
|
|
}
|
|
.card-header a {
|
|
padding: .75rem 1.25rem;
|
|
}
|
|
.card-header h4 {
|
|
margin: 0;
|
|
}
|
|
</style>
|
|
<% content_for :page_specific_css do %>
|
|
<%= stylesheet_link_tag "lib/main-forms" %>
|
|
<%= stylesheet_link_tag "lib/fileupload" %>
|
|
<%= stylesheet_link_tag "lib/main-list" %>
|
|
<%= stylesheet_link_tag "admin/card" %>
|
|
<% 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="#page_setting" data-toggle="tab"><%= t("property_hire.page_setting") %></a></li>
|
|
<li><a href="#files_links" data-toggle="tab"><%= t("property_hire.files_links") %></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="#carousel_image_upload" data-toggle="tab" title="<%= t('property_hire.carousel_image_title') %>"><%= t('property_hire.carousel_image') %></a></li>
|
|
<li><a href="#unavailability" data-toggle="tab"><%= t('property_hire.unavailable_time')%></a></li>
|
|
<li><a href="#available_time" data-toggle="tab"><%= t('property_hire.available_time')%></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.reservation_fields') %></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>
|
|
<!-- page_setting -->
|
|
<div class="tab-pane fade" id="page_setting">
|
|
<div class="control-group">
|
|
<%= f.label :custom_calendar_type, t("property_hire.display_calendar"), :class => "control-label muted" %>
|
|
<div class="controls">
|
|
<%= f.select :custom_calendar_type, options_for_select(Property::CAlENDARTYPE.map.with_index{|type,i| [t("property_hire.custom_calendar_type.#{type}"), i]}, f.object.custom_calendar_type) %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- files_links -->
|
|
<div class="tab-pane fade" id="files_links">
|
|
<%= render :partial => "form_file_link", :locals=>{:f=>f} %>
|
|
</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="/assets/property_hire/AAAAAA.png" />
|
|
<% 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>
|
|
<!-- display img src -->
|
|
<div class="control-group">
|
|
<%= f.label :display_img, t("property_hire.display_img"), :class => "control-label muted" %>
|
|
<div class="controls">
|
|
<%= f.check_box :display_img %>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Image display setting -->
|
|
<% image_display_class_relation = {"full_width"=>"full-size-img","up_left_corner"=>"pull-left","up_right_corner"=>"pull-right"} %>
|
|
<div class="control-group <%='hide' if !f.object.display_img %>" id="image_display_setting">
|
|
<%= f.label :image_display_class, t("property_hire.cover_image_display_setting"), :class => "control-label muted" %>
|
|
<div class="controls">
|
|
<% image_display_class_relation.each.with_index do |(key,value),i| %>
|
|
<label>
|
|
<%= radio_button_tag "#{f.object_name}[image_display_class]", value , (f.object.image_display_class == value) %>
|
|
<%= t("property_hire.#{key}") %>
|
|
</label>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- Images Module -->
|
|
<div class="tab-pane fade" id="carousel_image_upload">
|
|
<div class="control-group">
|
|
<label class="control-label muted" for="carousel_image_width"><%= t("property_hire.carousel_image_width") %></label>
|
|
<div class="controls">
|
|
<%= f.text_field :custom_carousel_image_width, :placeholder => t("property_hire.custom_carousel_image_width_hint") %>
|
|
</div>
|
|
</div>
|
|
<% if f.object && !f.object.property_carousel_images.blank? %>
|
|
<div class="exist">
|
|
<% f.object.property_carousel_images.each_with_index do |property_carousel_image, i| %>
|
|
<%= f.fields_for :property_carousel_images, property_carousel_image do |f| %>
|
|
<%= render :partial => 'form_image', :object => property_carousel_image, :locals => {:f => f, :i => i} %>
|
|
<% end %>
|
|
<% end %>
|
|
<hr>
|
|
</div>
|
|
<% end %>
|
|
<!-- Add -->
|
|
<div class="add-target">
|
|
</div>
|
|
<p class="add-btn controls">
|
|
<%= hidden_field_tag 'property_carousel_image_count', f.object.property_carousel_images.count %>
|
|
<a id="add_carousel_image" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
|
|
</p>
|
|
</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 :can_hire_before_months, t("property_hire.how_many_months_ago_can_be_hired"), :class => "control-label muted" %>
|
|
<div class="controls">
|
|
<%= f.select :can_hire_before_months, options_for_select([[t("property_hire.no_limit"),0]] + (1..12).to_a.map{|month| [t("property_hire.month", month: month), month]},f.object.can_hire_before_months) %>
|
|
</div>
|
|
</div>
|
|
<div class="control-group">
|
|
<%= f.label :need_hire_before, t("property_hire.need_hire_before"), :class => "control-label muted" %>
|
|
<div class="controls">
|
|
<% units = ['month', 'day', 'hour', 'minute'] %>
|
|
<%= f.number_field :need_hire_before, :min=>0 %>
|
|
<%= f.select :need_hire_before_unit, options_for_select(units.map{|unit| [t("property_hire._#{unit}"), unit]},f.object.need_hire_before_unit) %>
|
|
</div>
|
|
</div>
|
|
<div class="control-group">
|
|
<label class="control-label muted"><%=t("property_hire.weekdays").html_safe%></label>
|
|
<div class="controls">
|
|
<% weekdays = @property.weekdays rescue [] %>
|
|
<% Property::WEEKDAYS.each_with_index do |weekday,i| %>
|
|
<label for="<%=weekday%>">
|
|
<input id="<%=weekday%>" type="checkbox" name="property[weekdays][]" value="<%=i%>" <%= weekdays.include?(i.to_s) ? "checked=checked" : "" %> /> <% trans = t("property_hire.#{weekday}") %><%= (trans.class == ActiveSupport::SafeBuffer ? weekday : trans) %>
|
|
</label>
|
|
<% end %>
|
|
</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>
|
|
<div class="control-group">
|
|
<%= f.label :start_time, t("property_hire.limit_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.limit_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>
|
|
<% @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>
|
|
<!-- available_time -->
|
|
<div class="tab-pane fade" id="available_time">
|
|
<div class="control-group">
|
|
<%= f.label :set_availability, t("property_hire.set_availability"), :class => "control-label muted" %>
|
|
<div class="controls">
|
|
<%= f.check_box :set_availability %>
|
|
</div>
|
|
</div>
|
|
<% if @property.set_availability %>
|
|
<div id="set_availability_div">
|
|
<% else %>
|
|
<div id="set_availability_div" style="display: none;">
|
|
<% end %>
|
|
<ul>
|
|
<% all_day_settings = f.object.all_day_settings %>
|
|
<% setting_count = 0 %>
|
|
<% Property::WEEKDAYS.each_with_index do |weekday,i| %>
|
|
<li class="card">
|
|
<div class="card-header">
|
|
<h4>
|
|
<a data-toggle="collapse" href="#<%=weekday%>_setting" role="button" aria-expanded="false" aria-controls="<%=weekday%>_setting"><% trans = t("property_hire.#{weekday}") %><%= (trans.class == ActiveSupport::SafeBuffer ? weekday : trans) %></a>
|
|
</h4>
|
|
</div>
|
|
<div class="collapse" id="<%=weekday%>_setting">
|
|
<div class="card card-body">
|
|
<div id="add_target_weekday_<%=i%>">
|
|
<% if all_day_settings[i.to_s] %>
|
|
<% all_day_settings[i.to_s].each_with_index do |setting,j| %>
|
|
<%= f.fields_for :property_day_settings, setting,:child_index => setting_count do |f| %>
|
|
<%= render :partial => "time_form", :locals=>{:key=>j,:day=>i,:f=>f} %>
|
|
<% setting_count += 1 %>
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|
|
</div>
|
|
<a class="btn btn-primary add_weekday_setting" data-target="#add_target_weekday_<%=i%>" data-count="<%= all_day_settings[i] ? all_day_settings[i].count : 0 %>" data-day="<%=i%>"><%=t(:add)%></a>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
<% end %>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="tab-pane fade" id="settings">
|
|
<% fields_name = f.object.class::FIELDSNAME %>
|
|
<div style="padding: 1.2em;">
|
|
<table style="margin: 0;">
|
|
<thead>
|
|
<th><%= t('property_hire.field_name') %></th>
|
|
<th><%= t('property_hire.name') %></th>
|
|
<th><%= t('property_hire.placeholder') %></th>
|
|
<th><%= t('property_hire.disable') %></th>
|
|
<th><%= t('property_hire.required') %></th>
|
|
</thead>
|
|
<tbody>
|
|
<% fields_name.each do |field_name| %>
|
|
<tr>
|
|
<td>
|
|
<%= t("property_hire.#{field_name}") %>
|
|
</td>
|
|
<td>
|
|
<%= render_custom_text_field(f,field_name,"name") %>
|
|
</td>
|
|
<td>
|
|
<%= render_custom_text_field(f,field_name,"placeholder") %>
|
|
</td>
|
|
<td>
|
|
<input type="hidden" name='<%= "#{f.object_name}[#{field_name}][enable]" %>' value="1">
|
|
<%= check_box_tag("#{f.object_name}[#{field_name}][enable]", "0" , (f.object.send(field_name)["enable"] == "0" rescue false)) %>
|
|
</td>
|
|
<td>
|
|
<input type="hidden" name='<%= "#{f.object_name}[#{field_name}][required]" %>' value="false">
|
|
<%= check_box_tag("#{f.object_name}[#{field_name}][required]", "true" , (f.object.send(field_name)["required"] == "true" rescue false)) %>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<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: "ckeditor 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: "ckeditor 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">
|
|
<% referer = request.referer rescue nil %>
|
|
<% referer = get_referer_url if referer.blank? || request.host != URI.parse(URI.encode(referer)).host %>
|
|
<input type="hidden" name="referer_url" value="<%= referer %>">
|
|
<%= hidden_field_tag("property[id]",@property.id) %>
|
|
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
|
<%= link_to t('cancel'), referer, :class=>"btn" %>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$("#bulletin_display_img").click(function(){$("#image_display_setting").toggleClass("hide")})
|
|
$(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_set_availability").on("click",function(){
|
|
if($(this).is(":checked")){
|
|
$("#set_availability_div").show();
|
|
}else{
|
|
$("#set_availability_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","");
|
|
}
|
|
})
|
|
var setting_count = <%=setting_count%>;
|
|
$(".add_weekday_setting").click(function(){
|
|
var target = $($(this).data("target"));
|
|
var key = $(this).data("key");
|
|
var day = $(this).data("day");
|
|
var new_key = $(this).prev().attr('value');
|
|
var old_key = new RegExp("new_key", "g");
|
|
var new_day = day;
|
|
var old_day = new RegExp("new_day", "g");
|
|
var new_key = key;
|
|
key += 1;
|
|
$(this).data("key",key);
|
|
var old_index = new RegExp("new_index", "g");
|
|
var new_index = setting_count;
|
|
setting_count += 1;
|
|
<% property_day_setting = f.object.property_day_settings.new(:id=>nil) %>
|
|
<%= f.fields_for :property_day_settings,property_day_setting,:child_index => "new_index" do |f| %>
|
|
var template_html = "<%= escape_javascript(render(:partial=>"time_form",:locals=>{:f=>f})) %>";
|
|
<%end%>
|
|
var tmp = $(template_html.replace(old_index,new_index).replace(old_key,new_key).replace(old_day,new_day));
|
|
target.append(tmp);
|
|
tmp.find("input[data-format]").each(function(i,input){
|
|
var $input = $(input);
|
|
var format = $input.data("format"),
|
|
timeOnly = !(format.match(/Y|M|d/)), timeFormat, dateFormat = "";
|
|
if(timeOnly){
|
|
timeFormat = format;
|
|
}else{
|
|
dateFormat = format.match(/yy(\/|-|)(mm|)(\/|-|)(dd|)/i)[0];
|
|
timeFormat = $.trim(format.replace(dateFormat,""));
|
|
}
|
|
var options = {dateFormat: dateFormat,timeFormat: timeFormat,timeOnly: timeOnly};
|
|
var additionalOptions = $input.data();
|
|
$.extend(options, additionalOptions);
|
|
$input.ui_datetimepicker(options);
|
|
$input.siblings('.clearDate').click(function(){
|
|
$input.val('');
|
|
$input.trigger('change');
|
|
});
|
|
})
|
|
})
|
|
$(document).on('click', '.setting-form-remove', function(){
|
|
if($(this).find(".remove_existing_record").length != 0){
|
|
if(confirm("<%= I18n.t(:sure?)%>")){
|
|
$(this).find('.should_destroy').attr('value', 1);
|
|
$(this).parents('.time_setting_form').hide();
|
|
}
|
|
}else{
|
|
$(this).parents('.time_setting_form').remove();
|
|
}
|
|
});
|
|
$(document).on('click', '.image-form-remove', function(){
|
|
if($(this).find(".remove_existing_record").length != 0){
|
|
if(confirm("<%= I18n.t(:sure?)%>")){
|
|
$(this).find('.should_destroy').attr('value', 1);
|
|
$(this).parents('.image_group').hide();
|
|
}
|
|
}else{
|
|
$(this).parents('.image_group').remove();
|
|
}
|
|
});
|
|
$(document).on('click', '#add_carousel_image', function(){
|
|
var new_id = $(this).prev().attr('value');
|
|
var old_id = new RegExp("new_property_carousel_images", "g");
|
|
var on = $('.language-nav li.active').index();
|
|
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
|
|
$(this).prev().attr('value', parseInt(new_id) + 1);
|
|
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_image', f, :property_carousel_images) %>").replace(old_id, new_id));
|
|
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
|
|
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
|
|
});
|
|
});
|
|
$(document).on('click', '.fileupload-remove', function(){
|
|
if($(this).find(".delete_image").length != 0){
|
|
$(this).parents('.image_group').remove();
|
|
}
|
|
});
|
|
</script>
|
|
|
|
|