fix: allow view supplements to add extra links for profile employee tab

This commit is contained in:
Lance Edgar 2024-07-04 18:21:06 -05:00
parent 793a15883e
commit 89d7009a18
2 changed files with 136 additions and 120 deletions

View file

@ -1274,8 +1274,7 @@
</div>
<div>
<div class="buttons">
<div style="display: flex; gap: 0.75rem;">
% if request.has_perm('people_profile.toggle_employee'):
@ -1410,6 +1409,17 @@
</${b}-modal>
% endif
<div style="display: flex; flex-direction: column; align-items: right; gap: 0.75rem;">
<b-button v-for="link in employee.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('employees.view'):
<b-button v-if="employee.view_url"
tag="a" :href="employee.view_url">

View file

@ -803,6 +803,12 @@ class PersonView(MasterView):
app = self.get_rattail_app()
handler = app.get_employment_handler()
context = handler.get_context_employee(employee)
context.setdefault('external_links', [])
for supp in self.iter_view_supplements():
if hasattr(supp, 'get_context_for_employee'):
context = supp.get_context_for_employee(employee, context)
context['view_url'] = self.request.route_url('employees.view', uuid=employee.uuid)
return context