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

157 lines
6.1 KiB
Plaintext

<% 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/module-area" %>
<% end %>
<style>
.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;
}
</style>
<%= form_for @settings , :url => settings_admin_property_hires_path, html: {class: "form-horizontal main-forms"} do |f| %>
<fieldset>
<% if @saved %>
<div class="alert alert-success">Settings saved.</div>
<% 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>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<div class="control-group">
<%= f.label :allow_no_logins_user, t("property_hire.allow_no_logins_user"), :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :allow_no_logins_user %>
</div>
</div>
<div class="control-group">
<%= f.label :calendar_type, t("property_hire.display_calendar_default"), :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :calendar_type, {}, "0", "1" %>
</div>
</div>
<div class="control-group">
<%= f.label :auto_approve, t("property_hire.auto_approve"), :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :auto_approve %>
</div>
</div>
<div class="control-group">
<%= f.label :disable_content_page, t("property_hire.disable_content_page"), :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :disable_content_page %>
</div>
</div>
<div class="control-group">
<%= f.label :disable_view_calendar_page, t("property_hire.disable_view_calendar_page"), :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :disable_view_calendar_page %>
</div>
</div>
<div class="control-group">
<%= f.label :carousel_image_width, t("property_hire.default_carousel_image_width"), :class => "control-label muted" %>
<div class="controls">
<%= f.text_field :carousel_image_width %>
</div>
</div>
<div class="control-group">
<%= f.label :default_time_settings, t("property_hire.default_time_settings"), :class => "control-label muted" %>
<% default_time_settings = f.object.default_time_settings %>
<% setting_count = 0 %>
<div class="controls">
<div id="default_time_settings">
<% if default_time_settings %>
<% default_time_settings.each_with_index do |setting,j| %>
<%= f.fields_for :property_day_settings do |f| %>
<%= f.fields_for setting_count.to_s, setting do |f| %>
<%= render :partial => "time_form", :locals=>{:key=>j,:day=>0,:f=>f} %>
<% setting_count += 1 %>
<% end %>
<% end %>
<% end %>
<% end %>
</div>
<a class="btn btn-primary add_weekday_setting" data-target="#default_time_settings" data-count="<%= default_time_settings.count %>" data-day="0"><%=t(:add)%></a>
</div>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= f.submit t('submit'), class: 'btn btn-primary' %>
</div>
</fieldset>
<script>
var setting_count = <%=setting_count%>;
$(".add_weekday_setting").click(function(){
var target = $($(this).data("target"));
var key = $(this).data("count");
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("count",key);
var old_index = new RegExp("new_index", "g");
var new_index = setting_count;
setting_count += 1;
<% property_day_setting = PropertyDaySetting.new(:id=>nil,:property_id=>"default_settings") %>
<%= f.fields_for :property_day_settings do |f| %>
<%= f.fields_for "new_index",property_day_setting do |f| %>
var template_html = "<%= escape_javascript(render(:partial=>"time_form",:locals=>{:f=>f})) %>";
<%end%>
<%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();
}
});
</script>
<% end %>