Allow override of version diff for master views

and misc. other tweaks
This commit is contained in:
Lance Edgar 2023-10-23 15:48:48 -05:00
parent ec8a8d5ddc
commit f70772fabc
3 changed files with 13 additions and 7 deletions

View file

@ -574,7 +574,7 @@
</b-field>
<b-field label="Unit Size">
<span>{{ productSize }}</span>
<span>{{ productSize || '' }}</span>
</b-field>
<b-field label="Case Size">
@ -734,7 +734,7 @@
<b-field grouped>
<b-field label="Product" horizontal>
<span :class="productIsKnown ? null : 'has-text-success'">
{{ productIsKnown ? productDisplay : pendingProduct.brand_name + ' ' + pendingProduct.description + ' ' + pendingProduct.size }}
{{ productIsKnown ? productDisplay : (pendingProduct.brand_name || '') + ' ' + (pendingProduct.description || '') + ' ' + (pendingProduct.size || '') }}
</span>
</b-field>
</b-field>
@ -761,7 +761,7 @@
:class="productPriceNeedsConfirmation ? 'has-background-warning' : ''"
% endif
>
{{ productIsKnown ? productUnitPriceDisplay : '$' + pendingProduct.regular_price_amount }}
{{ productIsKnown ? productUnitPriceDisplay : (pendingProduct.regular_price_amount ? '$' + pendingProduct.regular_price_amount : '') }}
</span>
</b-field>

View file

@ -35,7 +35,7 @@
<nav class="panel">
<p class="panel-heading">Cross-Reference</p>
<div class="panel-block buttons">
<div style="display: flex; flex-direction: column;">
<div style="display: flex; flex-direction: column; gap: 0.5rem;">
% for button in xref_buttons:
${button}
% endfor

View file

@ -1441,8 +1441,8 @@ class MasterView(View):
changed_raw = app.render_datetime(app.localtime(txn.issued_at, from_utc=True))
changed_ago = app.render_time_ago(app.make_utc() - txn.issued_at)
changed_by = str(txn.user)
if self.request.has_perm('users.view'):
changed_by = str(txn.user or '')
if self.request.has_perm('users.view') and txn.user:
changed_by = tags.link_to(changed_by, self.request.route_url('users.view', uuid=txn.user.uuid))
return {
@ -4961,10 +4961,16 @@ class MasterView(View):
def make_diff(self, old_data, new_data, **kwargs):
return diffs.Diff(old_data, new_data, **kwargs)
def get_version_diff_factory(self, **kwargs):
if hasattr(self, 'version_diff_factory'):
return self.version_diff_factory
return diffs.VersionDiff
def make_version_diff(self, version, *args, **kwargs):
if 'title' not in kwargs:
kwargs['title'] = self.title_for_version(version)
return diffs.VersionDiff(version, *args, **kwargs)
factory = self.get_version_diff_factory()
return factory(version, *args, **kwargs)
##############################
# Configuration Views