Fix "toggle batch complete" for Chrome browser

This commit is contained in:
Lance Edgar 2023-01-13 16:49:16 -06:00
parent cac005f993
commit 83f9a3faa7
3 changed files with 26 additions and 17 deletions

View file

@ -426,6 +426,10 @@
}) })
} }
% if not batch.executed and master.has_perm('edit'):
${form.component_studly}Data.togglingBatchComplete = false
% endif
% if master.has_worksheet_file and master.allow_worksheet(batch) and master.has_perm('worksheet'): % if master.has_worksheet_file and master.allow_worksheet(batch) and master.has_perm('worksheet'):
ThisPageData.showUploadDialog = false ThisPageData.showUploadDialog = false

View file

@ -431,11 +431,10 @@ class BatchMasterView(MasterView):
return dict(batch.params or {}) return dict(batch.params or {})
def render_complete(self, batch, field): def render_complete(self, batch, field):
permission_prefix = self.get_permission_prefix()
use_buefy = self.get_use_buefy() use_buefy = self.get_use_buefy()
text = "Yes" if batch.complete else "No" text = "Yes" if batch.complete else "No"
if batch.executed or not self.request.has_perm('{}.edit'.format(permission_prefix)): if batch.executed or not self.has_perm('edit'):
return text return text
if batch.complete: if batch.complete:
@ -445,16 +444,18 @@ class BatchMasterView(MasterView):
label = "Mark Complete" label = "Mark Complete"
value = 'true' value = 'true'
kwargs = {} url = self.get_action_url('toggle_complete', batch)
kwargs = {'@submit': 'togglingBatchComplete = true'}
if not use_buefy: if not use_buefy:
kwargs['class_'] = 'autodisable' kwargs['class_'] = 'autodisable'
begin_form = tags.form(self.get_action_url('toggle_complete', batch), **kwargs) begin_form = tags.form(url, **kwargs)
if use_buefy: if use_buefy:
submit = HTML.tag('once-button', label = HTML.literal(
type='is-primary', '{{{{ togglingBatchComplete ? "Working, please wait..." : "{}" }}}}'.format(label))
submit = self.make_buefy_button(label, is_primary=True,
native_type='submit', native_type='submit',
text=label) **{':disabled': 'togglingBatchComplete'})
else: else:
submit = tags.submit('submit', label) submit = tags.submit('submit', label)

View file

@ -2660,31 +2660,35 @@ class MasterView(View):
normal.append(button) normal.append(button)
return normal return normal
def make_buefy_button(self, label, is_primary=False, def make_buefy_button(self, label,
url=None, is_external=False, type=None, is_primary=False,
url=None, target=None, is_external=False,
icon_left=None,
**kwargs): **kwargs):
""" """
Make and return a HTML ``<b-button>`` literal. Make and return a HTML ``<b-button>`` literal.
""" """
btn_kw = dict(c=label, icon_pack='fas') btn_kw = kwargs
btn_kw.setdefault('c', label)
btn_kw.setdefault('icon_pack', 'fas')
if 'type' in kwargs: if type:
btn_kw['type'] = kwargs['type'] btn_kw['type'] = type
elif is_primary: elif is_primary:
btn_kw['type'] = 'is-primary' btn_kw['type'] = 'is-primary'
if url: if url:
btn_kw['href'] = url btn_kw['href'] = url
if 'icon_left' in kwargs: if icon_left:
btn_kw['icon_left'] = kwargs['icon_left'] btn_kw['icon_left'] = icon_left
elif is_external: elif is_external:
btn_kw['icon_left'] = 'external-link-alt' btn_kw['icon_left'] = 'external-link-alt'
else: else:
btn_kw['icon_left'] = 'eye' btn_kw['icon_left'] = 'eye'
if 'target' in kwargs: if target:
btn_kw['target'] = kwargs['target'] btn_kw['target'] = target
elif is_external: elif is_external:
btn_kw['target'] = '_blank' btn_kw['target'] = '_blank'