More Buefy form cleanup for upgrades, clone/execute

This commit is contained in:
Lance Edgar 2019-06-08 14:06:07 -05:00
parent 2b6d88105c
commit 7224be9de2
3 changed files with 70 additions and 33 deletions

View file

@ -1,24 +1,51 @@
## -*- coding: utf-8; -*- ## -*- coding: utf-8; -*-
<%inherit file="/base.mako" /> <%inherit file="/form.mako" />
<%def name="title()">Clone ${model_title}: ${instance_title}</%def> <%def name="title()">Clone ${model_title}: ${instance_title}</%def>
<br /> <%def name="render_buefy_form()">
<p>You are about to clone the following ${model_title} as a new record:</p> <br />
% if use_buefy:
<b-notification :closable="false">
You are about to clone the following ${model_title} as a new record:
</b-notification>
% else:
<p>You are about to clone the following ${model_title} as a new record:</p>
% endif
<div class="form-wrapper"> ${parent.render_buefy_form()}
${form.render()|n} </%def>
</div><!-- form-wrapper -->
<br /> <%def name="render_form_buttons()">
<p>Are you sure about this?</p> <br />
<br /> % if use_buefy:
<b-notification :closable="false">
Are you sure about this?
</b-notification>
% else:
<p>Are you sure about this?</p>
% endif
<br />
${h.form(request.current_route_url(), class_='autodisable')} ${h.form(request.current_route_url(), class_=None if use_buefy else 'autodisable')}
${h.csrf_token(request)} ${h.csrf_token(request)}
${h.hidden('clone', value='clone')} ${h.hidden('clone', value='clone')}
<div class="buttons"> <div class="buttons">
${h.link_to("Whoops, nevermind...", form.cancel_url, class_='button autodisable')} % if use_buefy:
${h.submit('submit', "Yes, please clone away")} <once-button tag="a" href="${form.cancel_url}"
</div> text="Whoops, nevermind...">
${h.end_form()} </once-button>
<once-button type="is-primary"
native-type="submit"
text="Yes, please clone away">
</once-button>
% else:
${h.link_to("Whoops, nevermind...", form.cancel_url, class_='button autodisable')}
${h.submit('submit', "Yes, please clone away")}
% endif
</div>
${h.end_form()}
</%def>
${parent.body()}

View file

@ -44,7 +44,7 @@
% endif % endif
<br /> <br />
${h.form(request.current_route_url(), class_=None if form.use_buefy else 'autodisable')} ${h.form(request.current_route_url(), class_=None if use_buefy else 'autodisable')}
${h.csrf_token(request)} ${h.csrf_token(request)}
<div class="buttons"> <div class="buttons">
% if use_buefy: % if use_buefy:

View file

@ -36,19 +36,29 @@
</script> </script>
</%def> </%def>
${parent.body()} <%def name="render_form_buttons()">
% if not instance.executed and instance.status_code == enum.UPGRADE_STATUS_PENDING and request.has_perm('{}.execute'.format(permission_prefix)):
<div class="buttons">
% if instance.enabled and not instance.executing:
${h.form(url('{}.execute'.format(route_prefix), uuid=instance.uuid), class_='autodisable')}
${h.csrf_token(request)}
% if use_buefy:
<once-button type="is-primary"
native-type="submit"
text="Execute this upgrade">
</once-button>
% else:
${h.submit('execute', "Execute this upgrade", class_='button is-primary')}
% endif
${h.end_form()}
% elif instance.enabled:
<button type="button" class="button is-primary" disabled="disabled" title="This upgrade is currently executing">Execute this upgrade</button>
% else:
<button type="button" class="button is-primary" disabled="disabled" title="This upgrade is not enabled">Execute this upgrade</button>
% endif
</div>
% endif
</%def>
% if not instance.executed and instance.status_code == enum.UPGRADE_STATUS_PENDING and request.has_perm('{}.execute'.format(permission_prefix)):
<div class="buttons"> ${parent.body()}
% if instance.enabled and not instance.executing:
${h.form(url('{}.execute'.format(route_prefix), uuid=instance.uuid), class_='autodisable')}
${h.csrf_token(request)}
${h.submit('execute', "Execute this upgrade", class_='button is-primary')}
${h.end_form()}
% elif instance.enabled:
<button type="button" class="button is-primary" disabled="disabled" title="This upgrade is currently executing">Execute this upgrade</button>
% else:
<button type="button" class="button is-primary" disabled="disabled" title="This upgrade is not enabled">Execute this upgrade</button>
% endif
</div>
% endif