Buefy support for "mark batch as (in)complete"
This commit is contained in:
parent
3ddde1a1ca
commit
d51fe8483a
|
@ -157,6 +157,9 @@ ${self.render_form_complete()}
|
|||
<br /><br />
|
||||
## TODO: stop using |n filter
|
||||
${rows_grid.render_buefy(allow_save_defaults=False, tools=rows_grid_tools)|n}
|
||||
<div id="tailbone-grid-app">
|
||||
<tailbone-grid></tailbone-grid>
|
||||
</div>
|
||||
${self.make_tailbone_form_app()}
|
||||
${self.make_tailbone_grid_app()}
|
||||
% else:
|
||||
|
|
|
@ -331,11 +331,12 @@ class BatchMasterView(MasterView):
|
|||
return render_status
|
||||
|
||||
def render_complete(self, batch, field):
|
||||
content = [HTML.literal("Yes" if batch.complete else "No")]
|
||||
|
||||
if not batch.executed:
|
||||
permission_prefix = self.get_permission_prefix()
|
||||
if self.request.has_perm('{}.edit'.format(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)):
|
||||
return text
|
||||
|
||||
if batch.complete:
|
||||
label = "Mark as NOT Complete"
|
||||
|
@ -344,14 +345,44 @@ class BatchMasterView(MasterView):
|
|||
label = "Mark as Complete"
|
||||
value = 'true'
|
||||
|
||||
content.extend([
|
||||
HTML.literal(' '),
|
||||
tags.form(self.get_action_url('toggle_complete', batch), class_='autodisable'),
|
||||
kwargs = {}
|
||||
if not use_buefy:
|
||||
kwargs['class_'] = 'autodisable'
|
||||
begin_form = tags.form(self.get_action_url('toggle_complete', batch), **kwargs)
|
||||
|
||||
if use_buefy:
|
||||
submit = HTML.tag('once-button',
|
||||
type='is-primary',
|
||||
native_type='submit',
|
||||
text=label)
|
||||
else:
|
||||
submit = tags.submit('submit', label)
|
||||
|
||||
form = [
|
||||
begin_form,
|
||||
csrf_token(self.request),
|
||||
tags.hidden('complete', value=value),
|
||||
tags.submit('submit', label),
|
||||
submit,
|
||||
tags.end_form(),
|
||||
])
|
||||
]
|
||||
|
||||
if use_buefy:
|
||||
text = HTML.tag('div', class_='control', c=text)
|
||||
form = HTML.tag('div', class_='control', c=form)
|
||||
content = [
|
||||
HTML.tag('nav', class_='level',
|
||||
c=[HTML.tag('div', class_='level-left', c=[
|
||||
text,
|
||||
HTML.literal(' '),
|
||||
form,
|
||||
])]),
|
||||
]
|
||||
|
||||
else:
|
||||
content = [
|
||||
text,
|
||||
HTML.literal(' '),
|
||||
] + form
|
||||
|
||||
return HTML.tag('div', c=content)
|
||||
|
||||
|
|
Loading…
Reference in a new issue