Fix dynamic content title for "view profile" page

This commit is contained in:
Lance Edgar 2021-11-08 20:17:07 -06:00
parent a12318246f
commit 90cc8e5370
2 changed files with 21 additions and 3 deletions

View file

@ -14,6 +14,10 @@
</style> </style>
</%def> </%def>
<%def name="content_title()">
${dynamic_content_title}
</%def>
<%def name="page_content()"> <%def name="page_content()">
<profile-info @change-content-title="changeContentTitle"> <profile-info @change-content-title="changeContentTitle">
</profile-info> </profile-info>
@ -1394,7 +1398,7 @@
mixins: [SubmitMixin], mixins: [SubmitMixin],
props: { props: {
employee: Object, employee: Object,
employeeHistory: Object, employeeHistory: Array,
}, },
computed: { computed: {

View file

@ -445,18 +445,27 @@ class PersonView(MasterView):
'employee_view_url': self.request.route_url('employees.view', uuid=employee.uuid) if employee else None, 'employee_view_url': self.request.route_url('employees.view', uuid=employee.uuid) if employee else None,
'employee_history': employee.get_current_history() if employee else None, 'employee_history': employee.get_current_history() if employee else None,
'employee_history_data': self.get_context_employee_history(employee), 'employee_history_data': self.get_context_employee_history(employee),
'dynamic_content_title': self.get_context_content_title(person),
} }
use_buefy = self.get_use_buefy() use_buefy = self.get_use_buefy()
template = 'view_profile_buefy' if use_buefy else 'view_profile' template = 'view_profile_buefy' if use_buefy else 'view_profile'
return self.render_to_response(template, context) return self.render_to_response(template, context)
def template_kwargs_view_profile_buefy(self, **kwargs): def template_kwargs_view_profile(self, **kwargs):
""" """
Method stub, so subclass can always invoke super() for it. Stub method so subclass can call `super()` for it.
""" """
return kwargs return kwargs
def template_kwargs_view_profile_buefy(self, **kwargs):
"""
Note that any subclass should not need to define this method.
It by default invokes :meth:`template_kwargs_view_profile()`
and returns that result.
"""
return self.template_kwargs_view_profile(**kwargs)
def get_max_lengths(self): def get_max_lengths(self):
model = self.model model = self.model
return { return {
@ -507,6 +516,7 @@ class PersonView(MasterView):
'view_profile_url': self.get_action_url('view_profile', person), 'view_profile_url': self.get_action_url('view_profile', person),
'phones': self.get_context_phones(person), 'phones': self.get_context_phones(person),
'emails': self.get_context_emails(person), 'emails': self.get_context_emails(person),
'dynamic_content_title': self.get_context_content_title(person),
} }
if person.address: if person.address:
@ -514,6 +524,9 @@ class PersonView(MasterView):
return context return context
def get_context_content_title(self, person):
return six.text_type(person)
def get_context_address(self, address): def get_context_address(self, address):
context = { context = {
'uuid': address.uuid, 'uuid': address.uuid,
@ -633,6 +646,7 @@ class PersonView(MasterView):
return { return {
'success': True, 'success': True,
'person': self.get_context_person(person), 'person': self.get_context_person(person),
'dynamic_content_title': self.get_context_content_title(person),
} }
def get_context_phones(self, person): def get_context_phones(self, person):