Some aesthetic improvements for vendor catalog batch

hopefully they're improvements...
This commit is contained in:
Lance Edgar 2022-01-07 15:03:56 -06:00
parent f89dc88c0e
commit ab61778d35
5 changed files with 124 additions and 17 deletions

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -686,6 +686,8 @@ class BatchMasterView(MasterView):
return HTML.tag('p', c=[link])
def make_batch_row_grid_tools(self, batch):
if self.get_use_buefy():
return
if self.rows_bulk_deletable and not batch.executed and self.request.has_perm('{}.delete_rows'.format(self.get_permission_prefix())):
url = self.request.route_url('{}.delete_rows'.format(self.get_route_prefix()), uuid=batch.uuid)
return HTML.tag('p', c=[tags.link_to("Delete all rows matching current search", url)])

View file

@ -40,6 +40,7 @@ from webhelpers2.html import tags
from tailbone import forms
from tailbone.db import Session
from tailbone.views.batch import FileBatchMasterView
from tailbone.diffs import Diff
log = logging.getLogger(__name__)
@ -76,11 +77,12 @@ class VendorCatalogView(FileBatchMasterView):
form_fields = [
'id',
'description',
'vendor',
'filename',
'parser_key',
'vendor',
'future',
'effective',
'description',
'notes',
'created',
'created_by',
@ -114,16 +116,6 @@ class VendorCatalogView(FileBatchMasterView):
'description',
'size',
'is_preferred_vendor',
'old_vendor_code',
'vendor_code',
'old_case_size',
'case_size',
'old_case_cost',
'case_cost',
'case_cost_diff',
'old_unit_cost',
'unit_cost',
'unit_cost_diff',
'suggested_retail',
'starts',
'ends',
@ -131,6 +123,8 @@ class VendorCatalogView(FileBatchMasterView):
'discount_ends',
'discount_amount',
'discount_percent',
'case_cost_diff',
'unit_cost_diff',
'status_code',
'status_text',
]
@ -228,7 +222,7 @@ class VendorCatalogView(FileBatchMasterView):
# starts
if not batch.future:
g.hide_column('starts')
g.remove('starts')
g.set_type('old_unit_cost', 'currency')
g.set_type('unit_cost', 'currency')
@ -262,6 +256,25 @@ class VendorCatalogView(FileBatchMasterView):
f.set_type('upc', 'gpc')
f.set_type('discount_percent', 'percent')
def template_kwargs_view_row(self, **kwargs):
row = kwargs['instance']
batch = row.batch
fields = [
'vendor_code',
'case_size',
'case_cost',
'unit_cost',
]
old_data = dict([(field, getattr(row, 'old_{}'.format(field)))
for field in fields])
new_data = dict([(field, getattr(row, field))
for field in fields])
kwargs['catalog_entry_diff'] = Diff(old_data, new_data, fields=fields,
monospace=True)
return kwargs
def template_kwargs_create(self, **kwargs):
parsers = self.get_parsers()
for parser in parsers: