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 />
|
<br /><br />
|
||||||
## TODO: stop using |n filter
|
## TODO: stop using |n filter
|
||||||
${rows_grid.render_buefy(allow_save_defaults=False, tools=rows_grid_tools)|n}
|
${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_form_app()}
|
||||||
${self.make_tailbone_grid_app()}
|
${self.make_tailbone_grid_app()}
|
||||||
% else:
|
% else:
|
||||||
|
|
|
@ -331,27 +331,58 @@ class BatchMasterView(MasterView):
|
||||||
return render_status
|
return render_status
|
||||||
|
|
||||||
def render_complete(self, batch, field):
|
def render_complete(self, batch, field):
|
||||||
content = [HTML.literal("Yes" if batch.complete else "No")]
|
permission_prefix = self.get_permission_prefix()
|
||||||
|
use_buefy = self.get_use_buefy()
|
||||||
|
text = "Yes" if batch.complete else "No"
|
||||||
|
|
||||||
if not batch.executed:
|
if batch.executed or not self.request.has_perm('{}.edit'.format(permission_prefix)):
|
||||||
permission_prefix = self.get_permission_prefix()
|
return text
|
||||||
if self.request.has_perm('{}.edit'.format(permission_prefix)):
|
|
||||||
|
|
||||||
if batch.complete:
|
if batch.complete:
|
||||||
label = "Mark as NOT Complete"
|
label = "Mark as NOT Complete"
|
||||||
value = 'false'
|
value = 'false'
|
||||||
else:
|
else:
|
||||||
label = "Mark as Complete"
|
label = "Mark as Complete"
|
||||||
value = 'true'
|
value = 'true'
|
||||||
|
|
||||||
content.extend([
|
kwargs = {}
|
||||||
HTML.literal(' '),
|
if not use_buefy:
|
||||||
tags.form(self.get_action_url('toggle_complete', batch), class_='autodisable'),
|
kwargs['class_'] = 'autodisable'
|
||||||
csrf_token(self.request),
|
begin_form = tags.form(self.get_action_url('toggle_complete', batch), **kwargs)
|
||||||
tags.hidden('complete', value=value),
|
|
||||||
tags.submit('submit', label),
|
if use_buefy:
|
||||||
tags.end_form(),
|
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),
|
||||||
|
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)
|
return HTML.tag('div', c=content)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue