Improve shoppers/people display for Customer tab in profile view
also expose settings for people/clientele handlers
This commit is contained in:
parent
0d52d554e7
commit
edd5d49e36
|
@ -62,6 +62,14 @@
|
|||
</b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field label="Clientele Handler"
|
||||
message="Leave blank for default handler.">
|
||||
<b-input name="rattail.clientele.handler"
|
||||
v-model="simpleSettings['rattail.clientele.handler']"
|
||||
@input="settingsNeedSaved = true">
|
||||
</b-input>
|
||||
</b-field>
|
||||
|
||||
</div>
|
||||
|
||||
<h3 class="block is-size-3">POS</h3>
|
||||
|
|
|
@ -15,6 +15,14 @@
|
|||
</b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field label="People Handler"
|
||||
message="Leave blank for default handler.">
|
||||
<b-input name="rattail.people.handler"
|
||||
v-model="simpleSettings['rattail.people.handler']"
|
||||
@input="settingsNeedSaved = true">
|
||||
</b-input>
|
||||
</b-field>
|
||||
|
||||
</div>
|
||||
</%def>
|
||||
|
||||
|
|
|
@ -697,25 +697,55 @@
|
|||
{{ customer._key }}
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="Name">
|
||||
<b-field horizontal label="Account Name">
|
||||
{{ customer.name }}
|
||||
</b-field>
|
||||
|
||||
<b-field horizontal label="People">
|
||||
<ul>
|
||||
<li v-for="p in customer.people"
|
||||
:key="p.uuid">
|
||||
<a v-if="p.uuid != person.uuid"
|
||||
:href="p.view_profile_url">
|
||||
{{ p.display_name }}
|
||||
</a>
|
||||
<span v-if="p.uuid == person.uuid">
|
||||
{{ p.display_name }}
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<b-field horizontal label="Account Holder">
|
||||
<span v-if="customer.account_holder && customer.account_holder.uuid == person.uuid">
|
||||
{{ customer.account_holder.display_name }}
|
||||
</span>
|
||||
<a v-if="customer.account_holder && customer.account_holder.uuid != person.uuid"
|
||||
:href="customer.account_holder.view_profile_url">
|
||||
{{ customer.account_holder.display_name }}
|
||||
</a>
|
||||
<span v-if="!customer.account_holder"></span>
|
||||
</b-field>
|
||||
|
||||
% if expose_customer_shoppers:
|
||||
<b-field horizontal label="Shoppers">
|
||||
<ul>
|
||||
<li v-for="shopper in customer.shoppers"
|
||||
:key="shopper.uuid">
|
||||
<a v-if="shopper.person_uuid != person.uuid"
|
||||
:href="shopper.view_profile_url">
|
||||
{{ shopper.display_name }}
|
||||
</a>
|
||||
<span v-if="shopper.person_uuid == person.uuid">
|
||||
{{ shopper.display_name }}
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</b-field>
|
||||
% endif
|
||||
|
||||
% if expose_customer_people:
|
||||
<b-field horizontal label="People">
|
||||
<ul>
|
||||
<li v-for="p in customer.people"
|
||||
:key="p.uuid">
|
||||
<a v-if="p.uuid != person.uuid"
|
||||
:href="p.view_profile_url">
|
||||
{{ p.display_name }}
|
||||
</a>
|
||||
<span v-if="p.uuid == person.uuid">
|
||||
{{ p.display_name }}
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</b-field>
|
||||
% endif
|
||||
|
||||
<b-field horizontal label="Address"
|
||||
v-for="address in customer.addresses"
|
||||
:key="address.uuid">
|
||||
|
|
|
@ -57,6 +57,7 @@ class CustomerView(MasterView):
|
|||
|
||||
labels = {
|
||||
'id': "ID",
|
||||
'name': "Account Name",
|
||||
'default_phone': "Phone Number",
|
||||
'default_email': "Email Address",
|
||||
'default_address': "Physical Address",
|
||||
|
@ -74,6 +75,7 @@ class CustomerView(MasterView):
|
|||
form_fields = [
|
||||
'_customer_key_',
|
||||
'name',
|
||||
'account_holder',
|
||||
'default_phone',
|
||||
'default_address',
|
||||
'address_street',
|
||||
|
@ -111,11 +113,13 @@ class CustomerView(MasterView):
|
|||
default=False)
|
||||
return self._expose_active_in_pos
|
||||
|
||||
# TODO: this is duplicated in people view module
|
||||
def should_expose_shoppers(self):
|
||||
return self.rattail_config.getbool('rattail',
|
||||
'customers.expose_shoppers',
|
||||
default=True)
|
||||
|
||||
# TODO: this is duplicated in people view module
|
||||
def should_expose_people(self):
|
||||
return self.rattail_config.getbool('rattail',
|
||||
'customers.expose_people',
|
||||
|
@ -249,6 +253,13 @@ class CustomerView(MasterView):
|
|||
customer = f.model_instance
|
||||
permission_prefix = self.get_permission_prefix()
|
||||
|
||||
# account_holder
|
||||
if self.creating:
|
||||
f.remove_field('account_holder')
|
||||
else:
|
||||
f.set_readonly('account_holder')
|
||||
f.set_renderer('account_holder', self.render_person)
|
||||
|
||||
# default_email
|
||||
f.set_renderer('default_email', self.render_default_email)
|
||||
if not self.creating and customer.emails:
|
||||
|
@ -623,6 +634,8 @@ class CustomerView(MasterView):
|
|||
'option': 'customers.expose_people',
|
||||
'type': bool,
|
||||
'default': True},
|
||||
{'section': 'rattail',
|
||||
'option': 'clientele.handler'},
|
||||
|
||||
# POS
|
||||
{'section': 'rattail',
|
||||
|
|
|
@ -446,6 +446,8 @@ class PersonView(MasterView):
|
|||
'customers_data': self.get_context_customers(person),
|
||||
# TODO: deprecate / remove this
|
||||
'customer_xref_buttons': self.get_customer_xref_buttons(person),
|
||||
'expose_customer_people': self.customers_should_expose_people(),
|
||||
'expose_customer_shoppers': self.customers_should_expose_shoppers(),
|
||||
'members_data': self.get_context_members(person),
|
||||
'member_xref_buttons': self.get_member_xref_buttons(person),
|
||||
'employee': employee,
|
||||
|
@ -554,6 +556,20 @@ class PersonView(MasterView):
|
|||
|
||||
return context
|
||||
|
||||
def get_context_shopper(self, shopper):
|
||||
person = shopper.person
|
||||
return {
|
||||
'uuid': shopper.uuid,
|
||||
'person_uuid': person.uuid,
|
||||
'first_name': person.first_name,
|
||||
'middle_name': person.middle_name,
|
||||
'last_name': person.last_name,
|
||||
'display_name': person.display_name,
|
||||
'view_profile_url': self.get_action_url('view_profile', person),
|
||||
'phones': self.get_context_phones(person),
|
||||
'emails': self.get_context_emails(person),
|
||||
}
|
||||
|
||||
def get_context_content_title(self, person):
|
||||
return str(person)
|
||||
|
||||
|
@ -578,6 +594,7 @@ class PersonView(MasterView):
|
|||
def get_context_customers(self, person):
|
||||
app = self.get_rattail_app()
|
||||
clientele = app.get_clientele_handler()
|
||||
expose_shoppers = self.customers_should_expose_shoppers()
|
||||
|
||||
customers = clientele.get_customers_for_account_holder(person)
|
||||
key = self.get_customer_key_field()
|
||||
|
@ -599,6 +616,14 @@ class PersonView(MasterView):
|
|||
'external_links': [],
|
||||
}
|
||||
|
||||
if customer.account_holder:
|
||||
context['account_holder'] = self.get_context_person(
|
||||
customer.account_holder)
|
||||
|
||||
if expose_shoppers:
|
||||
context['shoppers'] = [self.get_context_shopper(s)
|
||||
for s in customer.shoppers]
|
||||
|
||||
for supp in self.iter_view_supplements():
|
||||
if hasattr(supp, 'get_context_for_customer'):
|
||||
context = supp.get_context_for_customer(customer, context)
|
||||
|
@ -607,6 +632,18 @@ class PersonView(MasterView):
|
|||
|
||||
return data
|
||||
|
||||
# TODO: this is duplicated in customers view module
|
||||
def customers_should_expose_shoppers(self):
|
||||
return self.rattail_config.getbool('rattail',
|
||||
'customers.expose_shoppers',
|
||||
default=True)
|
||||
|
||||
# TODO: this is duplicated in customers view module
|
||||
def customers_should_expose_people(self):
|
||||
return self.rattail_config.getbool('rattail',
|
||||
'customers.expose_people',
|
||||
default=True)
|
||||
|
||||
def get_context_members(self, person):
|
||||
app = self.get_rattail_app()
|
||||
membership = app.get_membership_handler()
|
||||
|
@ -1394,6 +1431,8 @@ class PersonView(MasterView):
|
|||
{'section': 'rattail',
|
||||
'option': 'people.straight_to_profile',
|
||||
'type': bool},
|
||||
{'section': 'rattail',
|
||||
'option': 'people.handler'},
|
||||
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in a new issue