Add basic support for exposing Customer.shoppers

now there is a Shoppers field when viewing a Customer, unless
configured otherwise

also tweaked some logic for navigating Customer/Person relationships,
to handle implications of Shoppers being (maybe) present
This commit is contained in:
Lance Edgar 2023-06-07 16:27:10 -05:00
parent afd5c3a5fd
commit 3fde80f991
5 changed files with 201 additions and 46 deletions

View file

@ -26,12 +26,30 @@
</b-field>
<b-field message="If not set, customer chooser is an autocomplete field.">
<b-field message="Set this to show the Shoppers field when viewing a Customer record.">
<b-checkbox name="rattail.customers.expose_shoppers"
v-model="simpleSettings['rattail.customers.expose_shoppers']"
native-value="true"
@input="settingsNeedSaved = true">
Show the Shoppers field
</b-checkbox>
</b-field>
<b-field message="Set this to show the People field when viewing a Customer record.">
<b-checkbox name="rattail.customers.expose_people"
v-model="simpleSettings['rattail.customers.expose_people']"
native-value="true"
@input="settingsNeedSaved = true">
Show the People field
</b-checkbox>
</b-field>
<b-field message="If not set, Customer chooser is an autocomplete field.">
<b-checkbox name="rattail.customers.choice_uses_dropdown"
v-model="simpleSettings['rattail.customers.choice_uses_dropdown']"
native-value="true"
@input="settingsNeedSaved = true">
Show customer chooser as dropdown (select) element
Use dropdown (select element) for Customer chooser
</b-checkbox>
</b-field>

View file

@ -4,8 +4,8 @@
<%def name="object_helpers()">
${parent.object_helpers()}
% if show_profiles_helper and instance.people:
${view_profiles_helper(instance.people)}
% if show_profiles_helper and show_profiles_people:
${view_profiles_helper(show_profiles_people)}
% endif
</%def>
@ -20,7 +20,12 @@
${parent.modify_this_page_vars()}
<script type="text/javascript">
% if expose_shoppers:
${form.component_studly}Data.shoppers = ${json.dumps(shoppers_data)|n}
% endif
% if expose_people:
${form.component_studly}Data.peopleData = ${json.dumps(people_data)|n}
% endif
ThisPage.methods.detachPerson = function(url) {
## TODO: this should require POST, but we will add that once