Fix various templates for generating reports, per Buefy

also various other tweaks which came up along the way...
This commit is contained in:
Lance Edgar 2019-09-06 17:45:59 -05:00
parent cb4e9e9eda
commit 4c42ccc7d7
7 changed files with 102 additions and 26 deletions

View file

@ -291,20 +291,25 @@ class GenerateReport(View):
View which allows user to choose which type of report they wish to
generate.
"""
use_buefy = self.get_use_buefy()
# handler is responsible for determining which report types are valid
reports = self.handler.get_reports()
# make form to accept user choice of report type
schema = NewReport().bind(valid_report_types=list(reports))
form = forms.Form(schema=schema, request=self.request)
form = forms.Form(schema=schema, request=self.request, use_buefy=use_buefy)
form.submit_label = "Continue"
form.cancel_url = self.request.route_url('report_output')
# TODO: should probably "group" certain reports together somehow?
# e.g. some for customers/membership, others for product movement etc.
values = [(r.type_key, r.name) for r in reports.values()]
form.set_widget('report_type', forms.widgets.PlainSelectWidget(values=values,
size=10))
if use_buefy:
form.set_widget('report_type', forms.widgets.CustomSelectWidget(values=values, size=10))
form.widgets['report_type'].set_template_values(input_handler='reportTypeChanged')
else:
form.set_widget('report_type', forms.widgets.PlainSelectWidget(values=values, size=10))
# if form validates, that means user has chosen a report type, so we
# just redirect to the appropriate "new report" page
@ -321,6 +326,7 @@ class GenerateReport(View):
for r in reports.values()]),
'use_form': self.rattail_config.getbool('tailbone', 'reporting.choosing_uses_form',
default=True),
'use_buefy': use_buefy,
}
def generate(self):
@ -329,6 +335,7 @@ class GenerateReport(View):
input parameters specific to the report type, then creates a new report
and redirects user to view the output.
"""
use_buefy = self.get_use_buefy()
type_key = self.request.matchdict['type_key']
report = self.handler.get_report(type_key)
report_params = report.make_params(Session())
@ -351,7 +358,7 @@ class GenerateReport(View):
schema.add(node)
form = forms.Form(schema=schema, request=self.request,
use_buefy=self.get_use_buefy())
use_buefy=use_buefy)
form.submit_label = "Generate this Report"
form.cancel_url = self.request.route_url('generate_report')