diff --git a/app/views/my/blocks/_upcoming_appointments.html.erb b/app/views/my/blocks/_upcoming_appointments.html.erb new file mode 100644 index 0000000..62c1406 --- /dev/null +++ b/app/views/my/blocks/_upcoming_appointments.html.erb @@ -0,0 +1,118 @@ +
| Title | +Customer | +Vehicle | +Date | +Status | +
|---|---|---|---|---|
| + <%= link_to appt.subject, customer_appointment_path(appt) %> + <% if item[:total_days] > 1 %> + (Day <%= item[:day_number] %> of <%= item[:total_days] %>) + <% end %> + | ++ <% + customer_obj = appt.try(:customer) || appt.try(:qbo_customer) || appt.try(:customer_name) + customer_text = if customer_obj.respond_to?(:display_name) + customer_obj.display_name + elsif customer_obj.respond_to?(:name) + customer_obj.name + else + customer_obj.to_s + end + %> + <%= customer_text.presence || '-' %> + | ++ <% + vehicle_obj = appt.try(:vehicle) || appt.try(:vehicle_name) + vehicle_text = if vehicle_obj.respond_to?(:name) + vehicle_obj.name + elsif vehicle_obj.respond_to?(:to_s) + vehicle_obj.to_s + else + nil + end + %> + <%= vehicle_text.presence || '-' %> + | ++ <%= format_date(item[:date]) %> + | ++ <% if appt.respond_to?(:status) && appt.status.present? %> + + <%= appt.status.to_s.humanize %> + + <% end %> + | +
<%= l(:label_no_data) %>
+<% end %> \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index db7e679..b68cf2e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -24,6 +24,7 @@ en: label_event: "Event" label_open_appointment: Open Appointment label_start_date: Start Date + label_upcoming_appointments: "My Upcoming Appointments" permission_manage_customer_appointments: Manage Customer Appointments permission_view_customer_appointments: View Customer Appointments \ No newline at end of file diff --git a/init.rb b/init.rb index d5495c4..1ea23ff 100644 --- a/init.rb +++ b/init.rb @@ -53,9 +53,13 @@ end end Rails.configuration.to_prepare do - ApplicationController.prepend_view_path( - File.expand_path("app/views", __dir__) - ) + ApplicationController.prepend_view_path( File.expand_path("app/views", __dir__) ) + + Redmine::Views::MyPage::Block.register( + 'upcoming_appointments', + label: :label_upcoming_appointments, + partial: 'my/blocks/upcoming_appointments' + ) end RedmineQboCalendar.setup \ No newline at end of file diff --git a/lib/redmine_qbo_calendar.rb b/lib/redmine_qbo_calendar.rb index 1817ae9..3998132 100644 --- a/lib/redmine_qbo_calendar.rb +++ b/lib/redmine_qbo_calendar.rb @@ -10,8 +10,12 @@ module RedmineQboCalendar def self.setup + # Patches Customer.prepend(RedmineQboCalendar::Patches::CustomerPatch) + User.prepend(RedmineQboCalendar::Patches::UserPatch) CalendarsController.prepend(RedmineQboCalendar::Patches::CalendarsControllerPatch) + + # Hooks RedmineQboCalendar::Hooks::ViewHookListener end end \ No newline at end of file diff --git a/lib/redmine_qbo_calendar/patches/user_patch.rb b/lib/redmine_qbo_calendar/patches/user_patch.rb new file mode 100644 index 0000000..c219a99 --- /dev/null +++ b/lib/redmine_qbo_calendar/patches/user_patch.rb @@ -0,0 +1,21 @@ +#The MIT License (MIT) +# +#Copyright (c) 2026 rick barrette +# +#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +# +#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +module RedmineQboCalendar + module Patches + module UserPatch extend ActiveSupport::Concern + + prepended do + has_many :customer_appointments + end + + end + end +end \ No newline at end of file