Add xref buttons for Customer, Member tabs in profile view

This commit is contained in:
Lance Edgar 2022-12-10 09:11:27 -06:00
parent cb6c25f829
commit f8f6b76657
3 changed files with 25 additions and 0 deletions

View file

@ -579,6 +579,9 @@
</%def>
<%def name="render_member_panel_buttons(member)">
% for button in member_xref_buttons:
${button}
% endfor
% if request.has_perm('members.view'):
<b-button tag="a" :href="member.view_url">
View Member
@ -665,6 +668,9 @@
</%def>
<%def name="render_customer_panel_buttons(customer)">
% for button in customer_xref_buttons:
${button}
% endfor
% if request.has_perm('customers.view'):
<b-button tag="a" :href="customer.view_url">
View Customer

View file

@ -5107,6 +5107,7 @@ class ViewSupplement(object):
self.request = master.request
self.model = master.model
self.rattail_config = master.rattail_config
self.Session = master.Session
def get_grid_query(self, query):
"""

View file

@ -417,7 +417,9 @@ class PersonView(MasterView):
'email_type_options': self.get_email_type_options(),
'max_lengths': self.get_max_lengths(),
'customers_data': self.get_context_customers(person),
'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),
'employee': employee,
'employee_data': self.get_context_employee(employee) if employee else {},
'employee_view_url': self.request.route_url('employees.view', uuid=employee.uuid) if employee else None,
@ -430,6 +432,22 @@ class PersonView(MasterView):
template = 'view_profile_buefy' if use_buefy else 'view_profile'
return self.render_to_response(template, context)
def get_customer_xref_buttons(self, person):
buttons = []
for supp in self.iter_view_supplements():
if hasattr(supp, 'get_customer_xref_buttons'):
buttons.extend(supp.get_customer_xref_buttons(person) or [])
buttons = self.normalize_xref_buttons(buttons)
return buttons
def get_member_xref_buttons(self, person):
buttons = []
for supp in self.iter_view_supplements():
if hasattr(supp, 'get_member_xref_buttons'):
buttons.extend(supp.get_member_xref_buttons(person) or [])
buttons = self.normalize_xref_buttons(buttons)
return buttons
def template_kwargs_view_profile(self, **kwargs):
"""
Stub method so subclass can call `super()` for it.