Show help link when generating or viewing report, if applicable

This commit is contained in:
Lance Edgar 2023-01-04 16:39:37 -06:00
parent 31b213610f
commit db62bd20b3
3 changed files with 74 additions and 7 deletions

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar
# Copyright © 2010-2023 Lance Edgar
#
# This file is part of Rattail.
#
@ -2643,6 +2643,47 @@ class MasterView(View):
normal.append(button)
return normal
def make_buefy_button(self, label, is_primary=False,
url=None, is_external=False,
**kwargs):
"""
Make and return a HTML ``<b-button>`` literal.
"""
btn_kw = dict(c=label, icon_pack='fas')
if 'type' in kwargs:
btn_kw['type'] = kwargs['type']
elif is_primary:
btn_kw['type'] = 'is-primary'
if url:
btn_kw['href'] = url
if 'icon_left' in kwargs:
btn_kw['icon_left'] = kwargs['icon_left']
elif is_external:
btn_kw['icon_left'] = 'external-link-alt'
else:
btn_kw['icon_left'] = 'eye'
if 'target' in kwargs:
btn_kw['target'] = kwargs['target']
elif is_external:
btn_kw['target'] = '_blank'
button = HTML.tag('b-button', **btn_kw)
if url:
# nb. unfortunately HTML.tag() calls its first arg 'tag' and
# so we can't pass a kwarg with that name...so instead we
# patch that into place manually
button = six.text_type(button)
button = button.replace('<b-button ',
'<b-button tag="a"')
button = HTML.literal(button)
return button
def make_xref_button(self, **kwargs):
"""
Make and return a HTML ``<b-button>`` literal, for display in
@ -2655,6 +2696,8 @@ class MasterView(View):
assumed to be external, which affects the icon and causes
button click to open link in a new tab.
"""
# TODO: this should call make_buefy_button()
# nb. unfortunately HTML.tag() calls its first arg 'tag' and
# so we can't pass a kwarg with that name...so instead we
# patch that into place manually