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>
<%def name="render_customer_panel_buttons(customer)"> <%def name="render_customer_panel_buttons(customer)">
% for button in customer_xref_buttons: <b-button v-for="link in customer.external_links"
${button} :key="link.url"
% endfor 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'): % if request.has_perm('customers.view'):
<b-button tag="a" :href="customer.view_url"> <b-button tag="a" :href="customer.view_url">
View Customer View Customer

View file

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