From e0c96b2f5413457a65c76ad8435d5edd22c79308 Mon Sep 17 00:00:00 2001 From: rulingcom Date: Wed, 8 Jan 2025 22:08:27 +0800 Subject: [PATCH] fixed polyfill issue and added some for label radio --- app/models/p_hire.rb | 3 ++- app/models/property.rb | 1 + app/views/admin/property_hires/_form.html.erb | 24 ++++++++++++++++++- app/views/property_hires/hire.html.erb | 2 +- config/locales/en.yml | 1 + config/locales/zh_tw.yml | 3 ++- 6 files changed, 30 insertions(+), 4 deletions(-) diff --git a/app/models/p_hire.rb b/app/models/p_hire.rb index 65c9684..463bae2 100644 --- a/app/models/p_hire.rb +++ b/app/models/p_hire.rb @@ -61,7 +61,8 @@ class PHire viewButton = true end end - title = startt.strftime("%H:%M") + " ~ " + endt.strftime("%H:%M") + " " + self.reason_for_hire + label = self.send(self.property.calendar_label_field_name) rescue "" + title = startt.strftime("%H:%M") + " ~ " + endt.strftime("%H:%M") + " " + label { :id => self.id.to_s, # :title => (self.reason_for_hire.to_s + " "+ self.tmp_reason_for_hire.to_s).html_safe, diff --git a/app/models/property.rb b/app/models/property.rb index 1747eb3..59194d6 100644 --- a/app/models/property.rb +++ b/app/models/property.rb @@ -72,6 +72,7 @@ class Property field :custom_field_names, type: Array field :default_field_names, type: Array field :copy_id + field :calendar_label_field_name field :except_clone_relations, :type=>Array, :default => [] belongs_to :property_location has_many :p_hires diff --git a/app/views/admin/property_hires/_form.html.erb b/app/views/admin/property_hires/_form.html.erb index 97ef17e..fffbf0b 100644 --- a/app/views/admin/property_hires/_form.html.erb +++ b/app/views/admin/property_hires/_form.html.erb @@ -64,6 +64,9 @@ .apply_default_time_settings{ margin-bottom: 1em; } + .hide{ + display: none; + } <% content_for :page_specific_css do %> <%= stylesheet_link_tag "lib/main-forms" %> @@ -596,6 +599,7 @@ <%= t('property_hire.placeholder') %> <%= t('property_hire.disable') %> <%= t('property_hire.required') %> + <%= t('property_hire.for_label') %> <% fields_name.each do |field_name| %> @@ -615,7 +619,11 @@ - <%= check_box_tag("#{f.object_name}[#{field_name}][required]", "true" , (f.object.send(field_name)["required"] == "true" rescue false)) %> + <%= check_box_tag("#{f.object_name}[#{field_name}][required]", "true" , (f.object.send(field_name)["required"] == "true" rescue false), class: "for_required") %> + <% for_label = f.object.send(field_name)["required"] == "true" ? true : false %> + + + <%= f.radio_button :calendar_label_field_name, field_name, {:class => "for_label_selection #{(for_label == true ? '' : 'hide')}" } %> <% end %> @@ -759,7 +767,19 @@ }else{ $("#selector_block").css("display",""); } + + // adding for label selector + $("input.for_required").on("click", function() { + var dom = $(this).parent().parent().find(".for_label_selection") + if($(this).is(":checked")){ + dom.removeClass("hide"); + }else{ + dom.addClass("hide"); + dom.removeAttr("checked"); + } + }) }) + $("#property_set_unavailibility").on("click",function(){ if($(this).is(":checked")){ $("#set_unavailibility_div").show(); @@ -896,6 +916,8 @@ $("#selector_block").css("display",""); } }) + + var setting_count = <%=setting_count%>; var default_time_settings = <%= PropertyHireSetting.first.default_time_settings.map{|s| s.attributes.except("_id","created_at","updated_at")}.to_s.gsub("=>",": ").html_safe rescue "[]" %> <% property_day_setting = f.object.property_day_settings.new(:id=>nil) %> diff --git a/app/views/property_hires/hire.html.erb b/app/views/property_hires/hire.html.erb index ffa1636..96ee609 100644 --- a/app/views/property_hires/hire.html.erb +++ b/app/views/property_hires/hire.html.erb @@ -1,6 +1,6 @@ <% OrbitHelper.render_css_in_head(["basic/bootstrap-datetimepicker.css","property_hire_fullcalendar.css","property_hire_calendar"]) %> <%= javascript_include_tag "validator.js" %> - + diff --git a/config/locales/en.yml b/config/locales/en.yml index c7c4add..ebbb84a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -211,3 +211,4 @@ en: month: Month all_properties: All Properties export_reservation_data: Export data + for_label: For Label diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 51dbfbf..7bb1fdd 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -232,4 +232,5 @@ zh_tw: week: 週模式 month: 月模式 all_properties: All Properties - export_reservation_data: Export data \ No newline at end of file + export_reservation_data: Export data + for_label: For Label \ No newline at end of file