Fix batch row status breakdown for Buefy themes

also, fix the "import batch from file" feature UI, per Buefy theme
This commit is contained in:
Lance Edgar 2020-03-02 14:38:06 -06:00
parent 2100f0461d
commit 2605f5ab79
5 changed files with 33 additions and 5 deletions

View file

@ -966,7 +966,9 @@ class Grid(object):
return self.render_complete(template=template, **kwargs)
def render_buefy_table_element(self, template='/grids/b-table.mako', data_prop='gridData', **kwargs):
def render_buefy_table_element(self, template='/grids/b-table.mako',
data_prop='gridData', empty_labels=False,
**kwargs):
"""
This is intended for ad-hoc "small" grids with static data. Renders
just a ``<b-table>`` element instead of the typical "full" grid.
@ -974,6 +976,7 @@ class Grid(object):
context = dict(kwargs)
context['grid'] = self
context['data_prop'] = data_prop
context['empty_labels'] = empty_labels
if 'grid_columns' not in context:
context['grid_columns'] = self.get_buefy_columns()

View file

@ -108,7 +108,9 @@
<div class="object-helper">
<h3>Row Status Breakdown</h3>
<div class="object-helper-content">
% if status_breakdown:
% if use_buefy:
${status_breakdown_grid.render_buefy_table_element(data_prop='statusBreakdownData', empty_labels=True)|n}
% elif status_breakdown:
<div class="grid full">
<table>
% for i, (status, count) in enumerate(status_breakdown):
@ -197,6 +199,12 @@
<%def name="modify_this_page_vars()">
${parent.modify_this_page_vars()}
<script type="text/javascript">
ThisPageData.statusBreakdownData = ${json.dumps(status_breakdown_grid.get_buefy_data()['data'])|n}
</script>
% if not batch.executed and request.has_perm('{}.execute'.format(permission_prefix)):
<script type="text/javascript">

View file

@ -14,8 +14,17 @@
>
<template slot-scope="props">
% for column in grid_columns:
<b-table-column field="${column['field']}" label="${column['label']}" ${'sortable' if column['sortable'] else ''}>
% for i, column in enumerate(grid_columns):
<b-table-column field="${column['field']}"
% if not empty_labels:
label="${column['label']}"
% elif i > 0:
label=" "
% endif
${'sortable' if column['sortable'] else ''}>
% if empty_labels and i == 0:
<template slot="header" slot-scope="{ column }"></template>
% endif
% if grid.is_linked(column['field']):
<a :href="props.row._action_url_view"
v-html="props.row.${column['field']}"

View file

@ -147,6 +147,7 @@ class BatchMasterView(MasterView):
return self.rattail_config.batch_filepath(batch.batch_key, batch.uuid, filename)
def template_kwargs_view(self, **kwargs):
use_buefy = self.get_use_buefy()
batch = kwargs['instance']
kwargs['batch'] = batch
kwargs['handler'] = self.handler
@ -164,6 +165,12 @@ class BatchMasterView(MasterView):
else:
kwargs['why_not_execute'] = self.handler.why_not_execute(batch)
kwargs['status_breakdown'] = self.make_status_breakdown(batch)
if use_buefy:
data = [{'title': title, 'count': count}
for title, count in kwargs['status_breakdown']]
Grid = self.get_grid_factory()
kwargs['status_breakdown_grid'] = Grid('batch_row_status_breakdown',
data, ['title', 'count'])
return kwargs
def make_status_breakdown(self, batch, rows=None, status_enum=None):

View file

@ -818,10 +818,11 @@ class MasterView(View):
delete=False, schema=None, importer_host_title=None):
handler = handler_factory(self.rattail_config)
use_buefy = self.get_use_buefy()
if not schema:
schema = forms.SimpleFileImport().bind(request=self.request)
form = forms.Form(schema=schema, request=self.request)
form = forms.Form(schema=schema, request=self.request, use_buefy=use_buefy)
form.save_label = "Upload"
form.cancel_url = self.get_index_url()
if form.validate(newstyle=True):