From 7fc26940542d0fe719bf8572ac61a128303285a6 Mon Sep 17 00:00:00 2001 From: rulingcom Date: Tue, 14 Jan 2025 23:37:25 +0800 Subject: [PATCH] added color and fix available_for_hire bug and confirm for no period properties --- app/models/p_hire.rb | 5 +++-- app/models/property.rb | 5 +++++ app/views/admin/property_hires/_form.html.erb | 9 +++++++++ app/views/property_hires/hire.html.erb | 16 ++++++++-------- config/locales/en.yml | 1 + config/locales/zh_tw.yml | 3 ++- 6 files changed, 28 insertions(+), 11 deletions(-) diff --git a/app/models/p_hire.rb b/app/models/p_hire.rb index 463bae2..df2ea40 100644 --- a/app/models/p_hire.rb +++ b/app/models/p_hire.rb @@ -74,15 +74,16 @@ class PHire :note => self.note_for_hire || "", :start => startt.to_json.gsub('"',''), :end => endt.to_json.gsub('"',''), - :allDay => false, + :allDay => true, :diff_day => (self.end_time - self.start_time >= 1), - :color => (self.passed ? "#3788d8" : "#FC4040"), + # :eventColor => (self.passed ? "#3788d8" : "#FC4040"), :error_message => (self.passed ? nil : "Not approved"), :s_id=>self.property_day_setting_id.to_s, :date=>datet, :recurring=>recurring, :classNames => classNames, :view_button => viewButton, + :color => self.property.property_color, :view_path => "/#{OrbitHelper.get_site_locale}/admin/property_hires/#{self.id.to_s}/show_booking_details", :view_path_name => I18n.t("property_hire.view") } diff --git a/app/models/property.rb b/app/models/property.rb index 59194d6..8e0fec4 100644 --- a/app/models/property.rb +++ b/app/models/property.rb @@ -34,6 +34,7 @@ class Property field :p_display_start_time, type: DateTime field :p_display_end_time, type: DateTime field :recurring_enable, type: Boolean, :default => false + field :property_color, :default => "#000000" mount_uploader :image, ImageUploader @@ -339,6 +340,10 @@ class Property return 0 end end + + startt = self.start_date.nil? ? stime : self.start_date + endt = self.end_date.nil? ? etime : self.end_date + if DateTime.now >= (self.start_date || DateTime.now - 1.day) && DateTime.now <= (self.end_date || DateTime.now + 1.month) if self.hours_restriction > 0 && !user.nil? sd = nil diff --git a/app/views/admin/property_hires/_form.html.erb b/app/views/admin/property_hires/_form.html.erb index fffbf0b..2aea0ba 100644 --- a/app/views/admin/property_hires/_form.html.erb +++ b/app/views/admin/property_hires/_form.html.erb @@ -73,6 +73,7 @@ <%= stylesheet_link_tag "lib/fileupload" %> <%= stylesheet_link_tag "lib/main-list" %> <%= stylesheet_link_tag "admin/card" %> + <%= stylesheet_link_tag "jquery.miniColors" %> <% end %> <% content_for :page_specific_javascript do %> <%= javascript_include_tag "lib/bootstrap-fileupload" %> @@ -80,6 +81,7 @@ <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> <%= javascript_include_tag "lib/file-type" %> <%= javascript_include_tag "lib/module-area" %> + <%= javascript_include_tag "jquery.miniColors.min" %> <% end %> @@ -122,6 +124,12 @@ <% end %> +
+ <%= f.label :property_color, t("property_hire.property_color"), :class => "control-label muted" %> +
+ <%= f.text_field :property_color, :class=>'set_color miniColors color-picker',:value=>(@property.property_color || '#000000') %> +
+
"> <%= f.label :other_location, t("property_hire.other_location"), :class => "control-label muted" %>
@@ -762,6 +770,7 @@