From e90dc31f8493b10e40e4e98a91434cd6f38cc3a3 Mon Sep 17 00:00:00 2001 From: BoHung Chiu Date: Sat, 22 Apr 2023 13:03:15 +0800 Subject: [PATCH] Fix bug. --- .../admin/property_hires_controller.rb | 19 ++++++++++++++++++- .../admin/property_hires/edit_hire.html.erb | 2 +- app/views/property_hires/hire.html.erb | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/property_hires_controller.rb b/app/controllers/admin/property_hires_controller.rb index 341f6db..c011fc3 100644 --- a/app/controllers/admin/property_hires_controller.rb +++ b/app/controllers/admin/property_hires_controller.rb @@ -254,7 +254,24 @@ class Admin::PropertyHiresController < OrbitAdminController params.require(:property_location).permit! end def phire_params - params.require(:p_hire).permit! + p_hire_params = params.require(:p_hire).permit! + property = (@phire ? @phire.property : Property.find(params[:p_hire][:property_id]) rescue nil) + if(property.enable_notes_selector rescue false) + note_texts = "" + property.notes_selector.each do |index,sub_hash| + name = sub_hash["name"][I18n.locale.to_s] + name = sub_hash["name"].values.select{|v| v.present?}.first.to_s if name.blank? + values = sub_hash["value"][I18n.locale.to_s] + values = sub_hash["value"].values.select{|v| v.present?}.first.to_s if values.blank? + value_text = p_hire_params["notes_selector"][index.to_s].to_a.map{|i| values[i.to_i]}.join(",") rescue "" + value_text = I18n.t("property_hire.none") if value_text.blank? + note_texts += (name + ":"+value_text) + note_texts += "
".html_safe + end + p_hire_params["note_for_hire"] = note_texts + p_hire_params.delete("notes_selector") + end + return p_hire_params end def property_params prop = params.require(:property).permit! diff --git a/app/views/admin/property_hires/edit_hire.html.erb b/app/views/admin/property_hires/edit_hire.html.erb index 19e58ef..4f3b700 100644 --- a/app/views/admin/property_hires/edit_hire.html.erb +++ b/app/views/admin/property_hires/edit_hire.html.erb @@ -711,7 +711,7 @@ ul.list-unstyled li { <% custom_field_inputs = {} %> <% custom_field_type = {"note_for_hire"=>"text_area"} %> <% if(property.enable_notes_selector rescue false) %> - <% custom_field_inputs["note_for_hire"] = render(:partial=>"note_for_hire",:locals=>{:f=>f,:property=>property}) %> + <% custom_field_inputs["note_for_hire"] = render(:partial=>"property_hires/notes_selector",:locals=>{:f=>f,:property=>property,:label_col=>label_col}) %> <% end %> <% fields_name = property.get_all_fields %> <% has_p_hire_fields = property.p_hire_fields_enabled.count != 0 diff --git a/app/views/property_hires/hire.html.erb b/app/views/property_hires/hire.html.erb index 7b4092b..b06ea47 100644 --- a/app/views/property_hires/hire.html.erb +++ b/app/views/property_hires/hire.html.erb @@ -555,7 +555,7 @@ <% custom_field_inputs = {} %> <% custom_field_type = {"note_for_hire"=>"text_area"} %> <% if(property.enable_notes_selector rescue false) %> - <% custom_field_inputs["note_for_hire"] = render(:partial=>"note_for_hire",:locals=>{:f=>f,:property=>property}) %> + <% custom_field_inputs["note_for_hire"] = render(:partial=>"property_hires/notes_selector",:locals=>{:f=>f,:property=>property,:label_col=>label_col}) %> <% end %> <% fields_name = property.get_all_fields %> <% has_p_hire_fields = property.p_hire_fields_enabled.count != 0