fix: allow auto-collapse of header when viewing trainwreck txn

This commit is contained in:
Lance Edgar 2024-07-16 18:59:35 -05:00
parent af0f84762c
commit 3aafe578f0
3 changed files with 81 additions and 4 deletions

View file

@ -16,10 +16,53 @@
</%def> </%def>
<%def name="page_content()"> <%def name="page_content()">
<div class="form-wrapper"> % if main_form_collapsible:
<br /> <${b}-collapse class="panel"
${self.render_form()} % if request.use_oruga:
</div> v-model:open="mainFormPanelOpen"
% else:
:open.sync="mainFormPanelOpen"
% endif
>
<template #trigger="props">
<div class="panel-heading"
role="button"
style="cursor: pointer;">
## TODO: for some reason buefy will "reuse" the icon
## element in such a way that its display does not
## refresh. so to work around that, we use different
## structure for the two icons, so buefy is forced to
## re-draw
<b-icon v-if="props.open"
pack="fas"
icon="caret-down">
</b-icon>
<span v-if="!props.open">
<b-icon pack="fas"
icon="caret-right">
</b-icon>
</span>
&nbsp;
<strong>Transaction Header</strong>
</div>
</template>
<div class="panel-block">
<div class="form-wrapper">
<br />
${self.render_form()}
</div>
</div>
</${b}-collapse>
% else:
<div class="form-wrapper">
<br />
${self.render_form()}
</div>
% endif
</%def> </%def>
<%def name="render_this_page()"> <%def name="render_this_page()">
@ -54,6 +97,15 @@
${parent.render_this_page_template()} ${parent.render_this_page_template()}
</%def> </%def>
<%def name="modify_this_page_vars()">
${parent.modify_this_page_vars()}
% if main_form_collapsible:
<script>
ThisPageData.mainFormPanelOpen = ${'false' if main_form_autocollapse else 'true'}
</script>
% endif
</%def>
<%def name="finalize_this_page_vars()"> <%def name="finalize_this_page_vars()">
${parent.finalize_this_page_vars()} ${parent.finalize_this_page_vars()}
% if form is not Undefined: % if form is not Undefined:

View file

@ -3,6 +3,19 @@
<%def name="form_content()"> <%def name="form_content()">
<h3 class="block is-size-3">Display</h3>
<div class="block" style="padding-left: 2rem;">
<b-field>
<b-checkbox name="tailbone.trainwreck.view_txn.autocollapse_header"
v-model="simpleSettings['tailbone.trainwreck.view_txn.autocollapse_header']"
native-value="true"
@input="settingsNeedSaved = true">
Auto-collapse header when viewing transaction
</b-checkbox>
</b-field>
</div>
<h3 class="block is-size-3">Rotation</h3> <h3 class="block is-size-3">Rotation</h3>
<div class="block" style="padding-left: 2rem;"> <div class="block" style="padding-left: 2rem;">

View file

@ -256,6 +256,7 @@ class TransactionView(MasterView):
def template_kwargs_view(self, **kwargs): def template_kwargs_view(self, **kwargs):
kwargs = super().template_kwargs_view(**kwargs) kwargs = super().template_kwargs_view(**kwargs)
config = self.rattail_config
form = kwargs['form'] form = kwargs['form']
if 'custorder_xref_markers' in form: if 'custorder_xref_markers' in form:
@ -268,6 +269,12 @@ class TransactionView(MasterView):
}) })
kwargs['custorder_xref_markers_data'] = markers kwargs['custorder_xref_markers_data'] = markers
# collapse header
kwargs['main_form_collapsible'] = True
kwargs['main_form_autocollapse'] = config.get_bool(
'tailbone.trainwreck.view_txn.autocollapse_header',
default=False)
return kwargs return kwargs
def get_xref_buttons(self, txn): def get_xref_buttons(self, txn):
@ -419,6 +426,11 @@ class TransactionView(MasterView):
def configure_get_simple_settings(self): def configure_get_simple_settings(self):
return [ return [
# display
{'section': 'tailbone',
'option': 'trainwreck.view_txn.autocollapse_header',
'type': bool},
# rotation # rotation
{'section': 'trainwreck', {'section': 'trainwreck',
'option': 'use_rotation', 'option': 'use_rotation',