fix: make the Members tab optional, for profile view

and hidden by default
This commit is contained in:
Lance Edgar 2024-07-05 14:57:19 -05:00
parent 2917463bb6
commit 2f2ebd0f07
3 changed files with 43 additions and 10 deletions

View file

@ -37,6 +37,14 @@
<h3 class="block is-size-3">Profile View</h3>
<div class="block" style="padding-left: 2rem; width: 50%;">
<b-field>
<b-checkbox name="tailbone.people.profile.expose_members"
v-model="simpleSettings['tailbone.people.profile.expose_members']"
native-value="true"
@input="settingsNeedSaved = true">
Show tab for Member Accounts
</b-checkbox>
</b-field>
<b-field>
<b-checkbox name="tailbone.people.profile.expose_transactions"
v-model="simpleSettings['tailbone.people.profile.expose_transactions']"

View file

@ -819,6 +819,7 @@
</${b}-tab-item>
</%def>
% if expose_members:
<%def name="render_member_tab_template()">
<script type="text/x-template" id="member-tab-template">
<div>
@ -961,6 +962,7 @@
</member-tab>
</${b}-tab-item>
</%def>
% endif
<%def name="render_customer_tab_template()">
<script type="text/x-template" id="customer-tab-template">
@ -1827,7 +1829,11 @@
<%def name="render_profile_tabs()">
${self.render_personal_tab()}
${self.render_member_tab()}
% if expose_members:
${self.render_member_tab()}
% endif
${self.render_customer_tab()}
% if expose_customer_shoppers:
${self.render_shopper_tab()}
@ -1965,7 +1971,11 @@
<%def name="render_this_page_template()">
${parent.render_this_page_template()}
${self.render_personal_tab_template()}
${self.render_member_tab_template()}
% if expose_members:
${self.render_member_tab_template()}
% endif
${self.render_customer_tab_template()}
% if expose_customer_shoppers:
${self.render_shopper_tab_template()}
@ -2385,6 +2395,7 @@
</script>
</%def>
% if expose_members:
<%def name="declare_member_tab_vars()">
<script type="text/javascript">
@ -2430,6 +2441,7 @@
</script>
</%def>
% endif
<%def name="declare_customer_tab_vars()">
<script type="text/javascript">
@ -3159,7 +3171,11 @@
<%def name="make_this_page_component()">
${parent.make_this_page_component()}
${self.make_personal_tab_component()}
${self.make_member_tab_component()}
% if expose_members:
${self.make_member_tab_component()}
% endif
${self.make_customer_tab_component()}
% if expose_customer_shoppers:
${self.make_shopper_tab_component()}

View file

@ -488,6 +488,7 @@ class PersonView(MasterView):
'expose_customer_shoppers': self.customers_should_expose_shoppers(),
'max_one_member': app.get_membership_handler().max_one_per_person(),
'use_preferred_first_name': self.people_handler.should_use_preferred_first_name(),
'expose_members': self.should_expose_profile_members(),
'expose_transactions': self.should_expose_profile_transactions(),
}
@ -499,6 +500,10 @@ class PersonView(MasterView):
return self.render_to_response('view_profile', context)
def should_expose_profile_members(self):
return self.rattail_config.get_bool('tailbone.people.profile.expose_members',
default=False)
def should_expose_profile_transactions(self):
return self.rattail_config.get_bool('tailbone.people.profile.expose_transactions',
default=False)
@ -585,7 +590,6 @@ class PersonView(MasterView):
def get_context_tabchecks(self, person):
app = self.get_rattail_app()
membership = app.get_membership_handler()
clientele = app.get_clientele_handler()
tabchecks = {}
@ -596,12 +600,14 @@ class PersonView(MasterView):
tabchecks['personal'] = True
# member
if membership.max_one_per_person():
member = app.get_member(person)
tabchecks['member'] = bool(member and member.active)
else:
members = membership.get_members_for_account_holder(person)
tabchecks['member'] = any([m.active for m in members])
if self.should_expose_profile_members():
membership = app.get_membership_handler()
if membership.max_one_per_person():
member = app.get_member(person)
tabchecks['member'] = bool(member and member.active)
else:
members = membership.get_members_for_account_holder(person)
tabchecks['member'] = any([m.active for m in members])
# customer
customers = clientele.get_customers_for_account_holder(person)
@ -1696,6 +1702,9 @@ class PersonView(MasterView):
# Profile View
{'section': 'tailbone',
'option': 'people.profile.expose_members',
'type': bool},
{'section': 'tailbone',
'option': 'people.profile.expose_transactions',
'type': bool},