From 41e1a7ecf95a1865f24e6fe50b1491af8b490abc Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 29 Oct 2026 23:29:46 -0400 Subject: [PATCH] Add appointment link in the customer page's contextual area Uses redmine_qbo's new :view_customers_show_contextual hook (replacing customer_actions_top) and renders "Add appointment" as a Redmine-style icon link alongside the customer's other actions. Needs the matching redmine_qbo update. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM --- .../_customer_actions.html.erb | 11 +++++------ .../hooks/customer_actions_hook_listener.rb | 13 +++++-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/app/views/customer_appointments/_customer_actions.html.erb b/app/views/customer_appointments/_customer_actions.html.erb index ad908d0..80007be 100644 --- a/app/views/customer_appointments/_customer_actions.html.erb +++ b/app/views/customer_appointments/_customer_actions.html.erb @@ -1,6 +1,5 @@ -<% customer = context[:customer] %> -<% if User.current.allowed_to?(:add_customer_appointments, nil, global: true) %> -

- <%= link_to l(:label_add_appointment), new_customer_appointment_path(customer_id: customer.id), target: :_blank, id: :appointment_link %> -

-<% end %> \ No newline at end of file +<% if customer && User.current.allowed_to?(:add_customer_appointments, nil, global: true) %> + <%= link_to sprite_icon('time-add', l(:label_add_appointment)), + new_customer_appointment_path(customer_id: customer.id), + class: 'icon icon-time-add', target: :_blank, id: 'appointment_link' %> +<% end %> diff --git a/lib/redmine_qbo_calendar/hooks/customer_actions_hook_listener.rb b/lib/redmine_qbo_calendar/hooks/customer_actions_hook_listener.rb index a580d77..f3ab4a9 100644 --- a/lib/redmine_qbo_calendar/hooks/customer_actions_hook_listener.rb +++ b/lib/redmine_qbo_calendar/hooks/customer_actions_hook_listener.rb @@ -13,14 +13,11 @@ module RedmineQboCalendar class CustomerActionsHookListener < Redmine::Hook::ViewListener - # This hook is called in the customer view, and allows us to add a link to create a new appointment for the customer. - def customer_actions_top(context = {}) - context[:controller].send(:render_to_string, { - partial: 'customer_appointments/customer_actions', - locals: { - context: context - } - }) + # Adds "Add appointment" to the customer page's top-right action area + # (redmine_qbo's :view_customers_show_contextual hook). + def view_customers_show_contextual(context = {}) + context[:hook_caller].render(partial: 'customer_appointments/customer_actions', + locals: { customer: context[:customer] }) end end