Let external customer link buttons be more dynamic, for profile view

need to copy this pattern elsewhere yet i'm sure..
This commit is contained in:
Lance Edgar 2023-06-10 20:12:33 -05:00
parent 40ae14bd7a
commit 9e1b83cbbe
2 changed files with 19 additions and 5 deletions

View file

@ -739,9 +739,14 @@
</%def>
<%def name="render_customer_panel_buttons(customer)">
% for button in customer_xref_buttons:
${button}
% endfor
<b-button v-for="link in customer.external_links"
:key="link.url"
type="is-primary"
tag="a" :href="link.url" target="_blank"
icon-pack="fas"
icon-left="external-link-alt">
{{ link.label }}
</b-button>
% if request.has_perm('customers.view'):
<b-button tag="a" :href="customer.view_url">
View Customer

View file

@ -420,6 +420,7 @@ class PersonView(MasterView):
'email_type_options': self.get_email_type_options(),
'max_lengths': self.get_max_lengths(),
'customers_data': self.get_context_customers(person),
# TODO: deprecate / remove this
'customer_xref_buttons': self.get_customer_xref_buttons(person),
'members_data': self.get_context_members(person),
'member_xref_buttons': self.get_member_xref_buttons(person),
@ -437,6 +438,7 @@ class PersonView(MasterView):
template = 'view_profile_buefy'
return self.render_to_response(template, context)
# TODO: deprecate / remove this
def get_customer_xref_buttons(self, person):
buttons = []
for supp in self.iter_view_supplements():
@ -558,7 +560,7 @@ class PersonView(MasterView):
data = []
for customer in customers:
data.append({
context = {
'uuid': customer.uuid,
'_key': getattr(customer, key),
'id': customer.id,
@ -570,7 +572,14 @@ class PersonView(MasterView):
for p in customer.people],
'addresses': [self.get_context_address(a)
for a in customer.addresses],
})
'external_links': [],
}
for supp in self.iter_view_supplements():
if hasattr(supp, 'get_context_for_customer'):
context = supp.get_context_for_customer(customer, context)
data.append(context)
return data