From afca8eb6eaa237ffc5888f4132739eef72c23fac Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 29 Oct 2026 23:56:07 -0400 Subject: [PATCH] Estimate hooks: replaceable Create Estimate link and per-estimate actions view_customers_show_estimate_link lets a plugin replace the customer page's Create Estimate link (which opens QuickBooks). view_estimate_actions adds links after an estimate on the customer page's list and the issue page. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM --- README.md | 2 ++ app/views/customers/show.html.erb | 10 ++++++++-- app/views/estimates/_list.html.erb | 1 + app/views/issues/_show_details.html.erb | 5 ++++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index baed7a6..b8c3581 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,8 @@ Available hooks: |Type|Hook|Note |--|--|--| View Hook|:view_customers_show_contextual, { customer: @customer } | Used to add action links to the customer page's top-right action area (return links styled like Redmine's, e.g. `link_to sprite_icon('add', 'Label'), path, class: 'icon icon-add'`). Replaces `customer_actions_top` / `customer_actions_bottom` +View Hook|:view_customers_show_estimate_link, { customer: @customer } | Replaces the customer page's Create Estimate link (which opens QuickBooks) with the link a plugin returns +View Hook|:view_estimate_actions, { estimate: estimate } | Used to add small action links after an estimate on the customer page's estimate list and the issue page (e.g. an Edit link) View Hook|:pdf_left, { issue: issue } | Used to add text to left side of PDF View Hook|:pdf_right, { issue: issue } | Used to add text to right side of PDF View Hook|:show_customer_view_right, { customer: customer } | Used to show partials on right side of customer view diff --git a/app/views/customers/show.html.erb b/app/views/customers/show.html.erb index 2c25e15..6866c60 100644 --- a/app/views/customers/show.html.erb +++ b/app/views/customers/show.html.erb @@ -4,8 +4,14 @@ id: 'dynamic-new-issue-link', class: 'icon icon-add', target: :_blank %> <%# Plugins add their customer actions here (e.g. redmine_qbo_calendar's Add appointment) %> <%= call_hook :view_customers_show_contextual, { customer: @customer } %> - <%= link_to sprite_icon('document', l(:label_create_estimate)), "https://qbo.intuit.com/app/estimate?nameId=#{@customer.id}", - class: 'icon icon-document', target: :_blank %> + <%# A plugin can replace the Create Estimate link (e.g. redmine_qbo_estimates writes estimates in Redmine) %> + <% estimate_link = call_hook(:view_customers_show_estimate_link, { customer: @customer }) %> + <% if estimate_link.present? %> + <%= estimate_link %> + <% else %> + <%= link_to sprite_icon('document', l(:label_create_estimate)), "https://qbo.intuit.com/app/estimate?nameId=#{@customer.id}", + class: 'icon icon-document', target: :_blank %> + <% end %> <%= link_to sprite_icon('add', l(:label_create_payment)), "https://qbo.intuit.com/app/recvpayment?nameId=#{@customer.id}", class: 'icon icon-add', target: :_blank %> <% if User.current.allowed_to?(:edit_customers, nil, global: true) %> diff --git a/app/views/estimates/_list.html.erb b/app/views/estimates/_list.html.erb index db22fd8..d714f39 100644 --- a/app/views/estimates/_list.html.erb +++ b/app/views/estimates/_list.html.erb @@ -4,6 +4,7 @@
<%= check_box_tag "estimate_ids[]", estimate.id, false, onchange: "updateLink()", data: { text: "Estimate ##{estimate.doc_number}" }, class: "estimate-checkbox appointment" %> <%= link_to "##{estimate.doc_number}", estimate_path(estimate), target: :_blank %> <%= estimate.txn_date %> + <%= call_hook :view_estimate_actions, { estimate: estimate } %>
<% end %> diff --git a/app/views/issues/_show_details.html.erb b/app/views/issues/_show_details.html.erb index e0fc707..40b03d0 100644 --- a/app/views/issues/_show_details.html.erb +++ b/app/views/issues/_show_details.html.erb @@ -7,7 +7,10 @@
<%=t(:field_estimate)%>:
-
<%= estimate_link %>
+
+ <%= estimate_link %> + <%= call_hook :view_estimate_actions, { estimate: issue.estimate } if issue.estimate %> +