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:
parent
2100f0461d
commit
2605f5ab79
|
@ -966,7 +966,9 @@ class Grid(object):
|
||||||
|
|
||||||
return self.render_complete(template=template, **kwargs)
|
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
|
This is intended for ad-hoc "small" grids with static data. Renders
|
||||||
just a ``<b-table>`` element instead of the typical "full" grid.
|
just a ``<b-table>`` element instead of the typical "full" grid.
|
||||||
|
@ -974,6 +976,7 @@ class Grid(object):
|
||||||
context = dict(kwargs)
|
context = dict(kwargs)
|
||||||
context['grid'] = self
|
context['grid'] = self
|
||||||
context['data_prop'] = data_prop
|
context['data_prop'] = data_prop
|
||||||
|
context['empty_labels'] = empty_labels
|
||||||
if 'grid_columns' not in context:
|
if 'grid_columns' not in context:
|
||||||
context['grid_columns'] = self.get_buefy_columns()
|
context['grid_columns'] = self.get_buefy_columns()
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,9 @@
|
||||||
<div class="object-helper">
|
<div class="object-helper">
|
||||||
<h3>Row Status Breakdown</h3>
|
<h3>Row Status Breakdown</h3>
|
||||||
<div class="object-helper-content">
|
<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">
|
<div class="grid full">
|
||||||
<table>
|
<table>
|
||||||
% for i, (status, count) in enumerate(status_breakdown):
|
% for i, (status, count) in enumerate(status_breakdown):
|
||||||
|
@ -197,6 +199,12 @@
|
||||||
|
|
||||||
<%def name="modify_this_page_vars()">
|
<%def name="modify_this_page_vars()">
|
||||||
${parent.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)):
|
% if not batch.executed and request.has_perm('{}.execute'.format(permission_prefix)):
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,17 @@
|
||||||
>
|
>
|
||||||
|
|
||||||
<template slot-scope="props">
|
<template slot-scope="props">
|
||||||
% for column in grid_columns:
|
% for i, column in enumerate(grid_columns):
|
||||||
<b-table-column field="${column['field']}" label="${column['label']}" ${'sortable' if column['sortable'] else ''}>
|
<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']):
|
% if grid.is_linked(column['field']):
|
||||||
<a :href="props.row._action_url_view"
|
<a :href="props.row._action_url_view"
|
||||||
v-html="props.row.${column['field']}"
|
v-html="props.row.${column['field']}"
|
||||||
|
|
|
@ -147,6 +147,7 @@ class BatchMasterView(MasterView):
|
||||||
return self.rattail_config.batch_filepath(batch.batch_key, batch.uuid, filename)
|
return self.rattail_config.batch_filepath(batch.batch_key, batch.uuid, filename)
|
||||||
|
|
||||||
def template_kwargs_view(self, **kwargs):
|
def template_kwargs_view(self, **kwargs):
|
||||||
|
use_buefy = self.get_use_buefy()
|
||||||
batch = kwargs['instance']
|
batch = kwargs['instance']
|
||||||
kwargs['batch'] = batch
|
kwargs['batch'] = batch
|
||||||
kwargs['handler'] = self.handler
|
kwargs['handler'] = self.handler
|
||||||
|
@ -164,6 +165,12 @@ class BatchMasterView(MasterView):
|
||||||
else:
|
else:
|
||||||
kwargs['why_not_execute'] = self.handler.why_not_execute(batch)
|
kwargs['why_not_execute'] = self.handler.why_not_execute(batch)
|
||||||
kwargs['status_breakdown'] = self.make_status_breakdown(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
|
return kwargs
|
||||||
|
|
||||||
def make_status_breakdown(self, batch, rows=None, status_enum=None):
|
def make_status_breakdown(self, batch, rows=None, status_enum=None):
|
||||||
|
|
|
@ -818,10 +818,11 @@ class MasterView(View):
|
||||||
delete=False, schema=None, importer_host_title=None):
|
delete=False, schema=None, importer_host_title=None):
|
||||||
|
|
||||||
handler = handler_factory(self.rattail_config)
|
handler = handler_factory(self.rattail_config)
|
||||||
|
use_buefy = self.get_use_buefy()
|
||||||
|
|
||||||
if not schema:
|
if not schema:
|
||||||
schema = forms.SimpleFileImport().bind(request=self.request)
|
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.save_label = "Upload"
|
||||||
form.cancel_url = self.get_index_url()
|
form.cancel_url = self.get_index_url()
|
||||||
if form.validate(newstyle=True):
|
if form.validate(newstyle=True):
|
||||||
|
|
Loading…
Reference in a new issue