Fix "toggle batch complete" for Chrome browser
This commit is contained in:
parent
cac005f993
commit
83f9a3faa7
|
@ -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'):
|
||||
|
||||
ThisPageData.showUploadDialog = false
|
||||
|
|
|
@ -431,11 +431,10 @@ class BatchMasterView(MasterView):
|
|||
return dict(batch.params or {})
|
||||
|
||||
def render_complete(self, batch, field):
|
||||
permission_prefix = self.get_permission_prefix()
|
||||
use_buefy = self.get_use_buefy()
|
||||
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
|
||||
|
||||
if batch.complete:
|
||||
|
@ -445,16 +444,18 @@ class BatchMasterView(MasterView):
|
|||
label = "Mark Complete"
|
||||
value = 'true'
|
||||
|
||||
kwargs = {}
|
||||
url = self.get_action_url('toggle_complete', batch)
|
||||
kwargs = {'@submit': 'togglingBatchComplete = true'}
|
||||
if not use_buefy:
|
||||
kwargs['class_'] = 'autodisable'
|
||||
begin_form = tags.form(self.get_action_url('toggle_complete', batch), **kwargs)
|
||||
begin_form = tags.form(url, **kwargs)
|
||||
|
||||
if use_buefy:
|
||||
submit = HTML.tag('once-button',
|
||||
type='is-primary',
|
||||
native_type='submit',
|
||||
text=label)
|
||||
label = HTML.literal(
|
||||
'{{{{ togglingBatchComplete ? "Working, please wait..." : "{}" }}}}'.format(label))
|
||||
submit = self.make_buefy_button(label, is_primary=True,
|
||||
native_type='submit',
|
||||
**{':disabled': 'togglingBatchComplete'})
|
||||
else:
|
||||
submit = tags.submit('submit', label)
|
||||
|
||||
|
|
|
@ -2660,31 +2660,35 @@ class MasterView(View):
|
|||
normal.append(button)
|
||||
return normal
|
||||
|
||||
def make_buefy_button(self, label, is_primary=False,
|
||||
url=None, is_external=False,
|
||||
def make_buefy_button(self, label,
|
||||
type=None, is_primary=False,
|
||||
url=None, target=None, is_external=False,
|
||||
icon_left=None,
|
||||
**kwargs):
|
||||
"""
|
||||
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:
|
||||
btn_kw['type'] = kwargs['type']
|
||||
if type:
|
||||
btn_kw['type'] = 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']
|
||||
if icon_left:
|
||||
btn_kw['icon_left'] = 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']
|
||||
if target:
|
||||
btn_kw['target'] = target
|
||||
elif is_external:
|
||||
btn_kw['target'] = '_blank'
|
||||
|
||||
|
|
Loading…
Reference in a new issue