fix error

This commit is contained in:
邱博亞 2022-07-21 16:43:51 +08:00
parent 53eced22cc
commit 429ef0f11c
8 changed files with 18 additions and 15 deletions

View File

@ -131,7 +131,7 @@ class PHireField
def self.add_p_hire_field(property,property_param, p_hire_field_id=nil,field_status)
@field_name = 'property'
if field_status.eql?(true)
@p_hire_field_counter = property.p_hire_fields.count rescue nil
@p_hire_field_counter = property.p_hire_fields_enabled.count rescue nil
@p_hire_field = self.find(p_hire_field_id) rescue nil
old_key = @p_hire_field.key
@p_hire_field.update(property_param)
@ -145,7 +145,7 @@ class PHireField
end
@p_hire_field[:af_count] = @p_hire_field_counter
else
@p_hire_field_counter = property.p_hire_fields.count rescue nil
@p_hire_field_counter = property.p_hire_fields_enabled.count rescue nil
@p_hire_field = property.p_hire_fields.build(property_param) rescue nil
@p_hire_field.save
@p_hire_field[:af_count] = @p_hire_field_counter

View File

@ -125,6 +125,9 @@ class Property
after_save do
self.change_day_setting_status
end
def p_hire_fields_enabled
self.p_hire_fields.where(disabled: false)
end
def all_day_settings
self.property_day_settings.asc(:key).group_by(&:day)
end
@ -468,10 +471,10 @@ class Property
end
def check_require_fields(booking_p)
fields_name = self.get_all_fields
has_p_hire_fields = self.p_hire_fields.count != 0
has_p_hire_fields = self.p_hire_fields_enabled.count != 0
p_hire_fields = {}
if has_p_hire_fields
p_hire_fields = self.p_hire_fields.map{|rf| [rf.id.to_s,rf]}.to_h
p_hire_fields = self.p_hire_fields_enabled.map{|rf| [rf.id.to_s,rf]}.to_h
end
error_messages = ""
form_index = 0
@ -546,7 +549,7 @@ class Property
if @default_field_names.nil?
basic_fields = self.get_basic_fields
custom_fields = []
self.p_hire_fields.each do |p_hire_field|
self.p_hire_fields_enabled.each do |p_hire_field|
unless p_hire_field.disabled
custom_fields << "p_hire_fields.#{p_hire_field.id}"
end

View File

@ -23,7 +23,7 @@
<fieldset>
<div id="attributes-area" class="input-area">
<%= render partial: "attribute_field",collection: @attribute.p_hire_fields.asc(:_id)%>
<%= render partial: "attribute_field",collection: @attribute.p_hire_fields_enabled.asc(:_id)%>
</div>
<div class="form-actions">

View File

@ -714,10 +714,10 @@ ul.list-unstyled li {
<% custom_field_inputs["note_for_hire"] = render(:partial=>"note_for_hire",:locals=>{:f=>f,:property=>property}) %>
<% end %>
<% fields_name = property.get_all_fields %>
<% has_p_hire_fields = property.p_hire_fields.count != 0
<% has_p_hire_fields = property.p_hire_fields_enabled.count != 0
p_hire_fields = {}
if has_p_hire_fields
p_hire_fields = property.p_hire_fields.map{|rf| [rf.id.to_s,rf]}.to_h
p_hire_fields = property.p_hire_fields_enabled.map{|rf| [rf.id.to_s,rf]}.to_h
end
%>
<% @form_index = 0 %>

View File

@ -17,7 +17,7 @@
}
</style>
<%= form_for @property , :url => {:action => "update_fields_display_order"}, html: {class: "form-horizontal main-forms"} do |f| %>
<% p_hire_fields = @property.p_hire_fields.map{|rf| [rf.id.to_s,rf]}.to_h %>
<% p_hire_fields = @property.p_hire_fields_enabled.map{|rf| [rf.id.to_s,rf]}.to_h %>
<fieldset>
<legend><%= @property.title %></legend>
<div class="control-group">

View File

@ -26,7 +26,7 @@
</thead>
<tbody>
<%
p_hire_fields = property.p_hire_fields.map{|rf| [rf.id.to_s,rf]}.to_h
p_hire_fields = property.p_hire_fields_enabled.map{|rf| [rf.id.to_s,rf]}.to_h
fields_name = property.get_all_fields
basic_keys = []
if (property.set_availability rescue false)
@ -37,7 +37,7 @@
fields_name = fields_name - basic_keys
keys = basic_keys + fields_name
keys = keys.select{|field_name| (property[field_name]["enable"] == "1" rescue true) }
p_hire_fields = property.p_hire_fields.map{|rf| [rf.id.to_s,rf]}.to_h
p_hire_fields = property.p_hire_fields_enabled.map{|rf| [rf.id.to_s,rf]}.to_h
has_p_hire_fields = p_hire_fields.count != 0
tmp_keys = []
all_trans = keys.map do |k|

View File

@ -558,10 +558,10 @@
<% custom_field_inputs["note_for_hire"] = render(:partial=>"note_for_hire",:locals=>{:f=>f,:property=>property}) %>
<% end %>
<% fields_name = property.get_all_fields %>
<% has_p_hire_fields = property.p_hire_fields.count != 0
<% has_p_hire_fields = property.p_hire_fields_enabled.count != 0
p_hire_fields = {}
if has_p_hire_fields
p_hire_fields = property.p_hire_fields.map{|rf| [rf.id.to_s,rf]}.to_h
p_hire_fields = property.p_hire_fields_enabled.map{|rf| [rf.id.to_s,rf]}.to_h
end
%>
<% @form_index = 0 %>

View File

@ -308,10 +308,10 @@
</div>
<% end %>
<% end %>
<% if property.p_hire_fields.count != 0 %>
<% if property.p_hire_fields_enabled.count != 0 %>
<% p_hire = PHire.new(:id=>nil) %>
<% @form_index = 0 %>
<% property.p_hire_fields.asc(:_id).each do |rf| %>
<% property.p_hire_fields_enabled.asc(:_id).each do |rf| %>
<div class="form-group">
<%= rf.block_helper(property,@form_index,false,"p_hire",p_hire, rf.to_require) %>
</div>