Add basic Buefy support for batch refresh, execute buttons

still doesn't yet handle the "execution options" use case though
This commit is contained in:
Lance Edgar 2019-05-20 14:43:51 -05:00
parent 93d0cfcfeb
commit a125e381a9

View file

@ -3,6 +3,7 @@
<%def name="extra_javascript()"> <%def name="extra_javascript()">
${parent.extra_javascript()} ${parent.extra_javascript()}
% if not use_buefy:
${h.javascript_link(request.static_url('tailbone:static/js/tailbone.batch.js') + '?ver={}'.format(tailbone.__version__))} ${h.javascript_link(request.static_url('tailbone:static/js/tailbone.batch.js') + '?ver={}'.format(tailbone.__version__))}
<script type="text/javascript"> <script type="text/javascript">
@ -26,6 +27,7 @@
}); });
</script> </script>
% endif
</%def> </%def>
<%def name="extra_styles()"> <%def name="extra_styles()">
@ -58,21 +60,61 @@
</%def> </%def>
<%def name="refresh_button()"> <%def name="refresh_button()">
% if master.viewing and master.batch_refreshable(batch) and request.has_perm('{}.refresh'.format(permission_prefix)): % if master.batch_refreshable(batch) and request.has_perm('{}.refresh'.format(permission_prefix)):
<button type="button" id="refresh-data">Refresh Data</button> % if use_buefy:
## TODO: this should surely use a POST request?
<a class="button"
href="${url('{}.refresh'.format(route_prefix), uuid=batch.uuid)}">
Refresh Data
</a>
% else:
<button type="button" class="button" id="refresh-data">Refresh Data</button>
% endif % endif
% endif
</%def>
<%def name="execute_submit_button()">
<button type="submit"
class="button is-primary"
% if not execute_enabled:
disabled="disabled"
% endif
% if why_not_execute:
title="${why_not_execute}"
% endif
>
${execute_title}
</button>
</%def> </%def>
<%def name="execute_button()"> <%def name="execute_button()">
% if not batch.executed and request.has_perm('{}.execute'.format(permission_prefix)): % if not batch.executed and request.has_perm('{}.execute'.format(permission_prefix)):
% if execute_enabled:
<button type="button" id="execute-batch">${execute_title}</button> % if use_buefy:
% elif why_not_execute: % if master.has_execution_options(batch):
<button type="button" id="execute-batch" disabled="disabled" title="${why_not_execute}">${execute_title}</button> ## TODO: this doesn't work yet
${execute_submit_button()}
% else: % else:
<button type="button" id="execute-batch" disabled="disabled">${execute_title}</button> ${execute_form.render_deform(buttons=capture(execute_submit_button))|n}
% endif
% else:
## no buefy, do legacy thing
<button type="button"
class="button is-primary"
id="execute-batch"
% if not execute_enabled:
disabled="disabled"
% endif
% if why_not_execute:
title="${why_not_execute}"
% endif
>
${execute_title}
</button>
% endif % endif
% endif % endif
</%def> </%def>
<%def name="object_helpers()"> <%def name="object_helpers()">
@ -132,7 +174,7 @@
${rows_grid|n} ${rows_grid|n}
% endif % endif
% if master.handler.executable(batch) and not batch.executed: % if not use_buefy and master.handler.executable(batch) and not batch.executed:
<div id="execution-options-dialog" style="display: none;"> <div id="execution-options-dialog" style="display: none;">
${execute_form.render_deform(form_kwargs={'name': 'batch-execution'}, buttons=False)|n} ${execute_form.render_deform(form_kwargs={'name': 'batch-execution'}, buttons=False)|n}
</div> </div>