When viewing report output, show params as proper buefy table

plus couple of other random tweaks
This commit is contained in:
Lance Edgar 2021-12-07 11:28:23 -06:00
parent 092f1cda0c
commit 5a4abbb163
4 changed files with 50 additions and 4 deletions

View file

@ -8,4 +8,16 @@
% endif
</%def>
<%def name="modify_this_page_vars()">
${parent.modify_this_page_vars()}
<script type="text/javascript">
% if params_data is not Undefined:
${form.component_studly}Data.paramsData = ${json.dumps(params_data)|n}
% endif
</script>
</%def>
${parent.body()}

View file

@ -224,7 +224,6 @@ class DataSyncChangeView(MasterView):
url_prefix = '/datasync/changes'
permission_prefix = 'datasync_changes'
creatable = False
editable = False
bulk_deletable = True
labels = {
@ -256,6 +255,12 @@ class DataSyncChangeView(MasterView):
kwargs['allow_filemon_restart'] = bool(self.rattail_config.get('tailbone', 'filemon.restart'))
return kwargs
def configure_form(self, f):
super(DataSyncChangeView, self).configure_form(f)
f.set_readonly('obtained')
# TODO: deprecate / remove this
DataSyncChangesView = DataSyncChangeView

View file

@ -45,7 +45,7 @@ from mako.template import Template
from pyramid.response import Response
from webhelpers2.html import HTML
from tailbone import forms, grids
from tailbone import forms
from tailbone.db import Session
from tailbone.views import View
from tailbone.views.exports import ExportMasterView
@ -257,18 +257,39 @@ class ReportOutputView(ExportMasterView):
params.sort(key=lambda param: param['key'])
route_prefix = self.get_route_prefix()
g = grids.Grid(
factory = self.get_grid_factory()
g = factory(
key='{}.params'.format(route_prefix),
data=params,
columns=['key', 'value'],
labels={'key': "Name"},
)
return HTML.literal(g.render_grid())
if self.get_use_buefy():
return HTML.literal(
g.render_buefy_table_element(data_prop='paramsData'))
else:
return HTML.literal(g.render_grid())
def render_download(self, report, field):
path = report.filepath(self.rattail_config)
url = self.get_action_url('download', report)
return self.render_file_field(path, url=url)
def template_kwargs_view(self, **kwargs):
use_buefy = self.get_use_buefy()
if use_buefy:
report = kwargs['instance']
params_data = []
for name, value in report.params.items():
params_data.append({
'name': name,
'value': value,
})
kwargs['params_data'] = params_data
return kwargs
def download(self):
report = self.get_instance()
path = report.filepath(self.rattail_config)
@ -387,6 +408,13 @@ class GenerateReport(View):
if param.type is datetime.date:
form.set_type(param.name, 'date_jquery')
# auto-select default choice for fields which have only one
for param in report_params:
if param.type == 'choice' and param.required:
values = form.schema[param.name].widget.values
if len(values) == 1:
form.set_default(param.name, values[0][0])
# if form validates, start generating new report output; show progress page
if form.validate(newstyle=True):
key = 'report_output.generate'

View file

@ -42,6 +42,7 @@ class StoreView(MasterView):
"""
model_class = model.Store
has_versions = True
touchable = True
grid_columns = [
'id',