updates by Junyi

This commit is contained in:
rulingcom 2025-09-03 17:31:59 +08:00
parent c5390eb00a
commit 105e4969d0
4 changed files with 37 additions and 38 deletions

View File

@ -6,7 +6,7 @@ class Admin::PropertyHiresController < OrbitAdminController
@filter_fields = filter_fields(@categories, @tags)
@table_fields = ["property_hire.title", :category, "property_hire.location", "property_hire.available_for_hire"]
@properties = Property.order_by(sort)
@properties = Property.order_by(order_position: :asc)
.with_categories(filters("category"))
.with_tags(filters("tag"))
@ -27,7 +27,7 @@ class Admin::PropertyHiresController < OrbitAdminController
redirect_to params[:referer_url]
end
def order
@properties = Property.all.sort_order
@properties = Property.order_by(order_position: :asc)
end
def updateorder
ids_with_order = params[:order]

View File

@ -2,7 +2,7 @@ class PropertyHiresController < ApplicationController
include Admin::PropertyHiresHelper
FrontendMethods = ["hire", "view_calendar", "hire_success"]
def index
properties = Property.can_display.filter_by_categories.sort_order
properties = Property.can_display.filter_by_categories.order_by(order_position: :asc)
url = "/#{I18n.locale}#{OrbitHelper.page.get_url}"
data = index_data(properties, url)
filterprops = data.dup
@ -82,7 +82,7 @@ class PropertyHiresController < ApplicationController
end
def widget
properties = Property.filter_by_widget_categories.sort_order.can_display
properties = Property.filter_by_widget_categories.order_by(order_position: :asc).can_display
url = OrbitHelper.get_current_widget.get_read_more_page_url
data = index_data(properties, url)
headers = [

View File

@ -23,17 +23,17 @@
<th><%= t("property_hire.title") %></th>
</thead>
<tbody>
<% @properties.each_with_index do |property,i| %>
<tr data-index="<%=i%>">
<td><span class="brand"><i class="icons-list-2"></i></span></td>
<td class="position-text">
<div class="position-text-div" data-value="<%= (i + 1).to_s %>"><%= (i + 1).to_s %></div>
</td>
<td>
<div class="property-text-id" data-property-id="<%= property.id.to_s %>"><%= property.title %></div>
</td>
</tr>
<% end %>
<% @properties.each do |property| %>
<tr data-index="<%= property.order_position %>">
<td><span class="brand"><i class="icons-list-2"></i></span></td>
<td class="position-text">
<div class="position-text-div" data-value="<%= property.order_position %>"><%= property.order_position %></div>
</td>
<td>
<div class="property-text-id" data-property-id="<%= property.id.to_s %>"><%= property.title %></div>
</td>
</tr>
<% end %>
</tbody>
</table>
<div class="bottomnav clearfix" style="left: 81px;">

View File

@ -1,5 +1,5 @@
<% property = Property.where(id: @data['property_id']).first%>
<% email_set = property.hire_email_sets.select{|v| v.field_name == 'p_hire'} %>
<% property = Property.where(id: @data['property_id']).first %>
<% email_set = property.hire_email_sets.select { |v| v.field_name == 'p_hire' } %>
<% if email_set.length != 0 %>
<% if !(email_set[0].content.nil?) %>
<%= email_set[0].content[@data['locale']].html_safe %>
@ -26,57 +26,56 @@
</thead>
<tbody>
<%
p_hire_fields = property.p_hire_fields_enabled.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)
basic_keys = ['date','time','hiring_person_name','hiring_person_email','recurring','recurring_interval','recurring_end_date','passed']
basic_keys = ['date', 'time', 'hiring_person_name', 'hiring_person_email', 'recurring', 'recurring_interval', 'recurring_end_date', 'passed']
else
basic_keys = ['hiring_person_name','hiring_person_email','start_time','end_time','recurring','recurring_interval','recurring_end_date','passed']
basic_keys = ['hiring_person_name', 'hiring_person_email', 'start_time', 'end_time', 'recurring', 'recurring_interval', 'recurring_end_date', 'passed']
end
fields_name = fields_name - basic_keys
keys = basic_keys + fields_name
keys = keys.select do |field_name|
return true if field_name.include?('p_hire_fields.')
next true if field_name.include?('p_hire_fields.')
tmp = property[field_name]
tmp.is_a?(Hash) ? (tmp["enable"] == "1") : true
tmp.is_a?(Hash) ? (tmp["enable"] == "1") : true
end
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|
if has_p_hire_fields && k.include?("p_hire_fields")
tmp_keys << k.sub("p_hire_fields.",'')
tmp_keys << k.sub("p_hire_fields.", '')
nil
else
tmp_keys << k
property.custom_text(k,"name")
property.custom_text(k, "name")
end
end
%>
<% p_hire_field_values = hire.p_hire_field_values.to_a %>
<% keys.each_with_index do |k,i| %>
<% keys.each_with_index do |k, i| %>
<% if has_p_hire_fields && k.include?("p_hire_fields")
p_hire_field_id = tmp_keys[i]
v = p_hire_field_values.select{|v| v.p_hire_field_id.to_s == p_hire_field_id}.first
field_info = v.get_field_value rescue {}
if field_info["title"].present? && !field_info["value"].nil?
all_trans[i] = field_info["title"]
v = field_info["value"]
end
p_hire_field_id = tmp_keys[i]
v = p_hire_field_values.select { |v| v.p_hire_field_id.to_s == p_hire_field_id }.first
field_info = v.get_field_value rescue {}
if field_info["title"].present? && !field_info["value"].nil?
all_trans[i] = field_info["title"]
v = field_info["value"]
end
else
v = hire.send(k)
v = hire.send(k)
end
%>
<% if !v.nil? && !(k.include?('recurring') && hire.recurring != true)%>
<% if !v.nil? && !(k.include?('recurring') && hire.recurring != true) %>
<tr>
<td>
<%= all_trans[i] %>:&nbsp;
</td>
<td>
<% if ['start_time','end_time','recurring','recurring_interval','recurring_end_date','passed'].exclude?(k) %>
<% if ['start_time', 'end_time', 'recurring', 'recurring_interval', 'recurring_end_date', 'passed'].exclude?(k) %>
<%= v.to_s.html_safe %>
<% elsif ['start_time','end_time','recurring_end_date'].include?(k) %>
<% elsif ['start_time', 'end_time', 'recurring_end_date'].include?(k) %>
<%= v.strftime('%Y/%m/%d %H:%M') rescue nil %>
<% elsif k == 'recurring_interval' %>
<%= t("property_hire.recurring_interval_types.#{v}") %>
@ -92,4 +91,4 @@
</tbody>
</table>
<% end %>
<% end %>
<% end %>