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; -*-
<%inherit file="/base.mako" />
<%inherit file="/form.mako" />
<%def name="title()">Clone ${model_title}: ${instance_title}</%def>
<br />
<p>You are about to clone the following ${model_title} as a new record:</p>
<%def name="render_buefy_form()">
<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">
${form.render()|n}
</div><!-- form-wrapper -->
${parent.render_buefy_form()}
</%def>
<br />
<p>Are you sure about this?</p>
<br />
<%def name="render_form_buttons()">
<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.csrf_token(request)}
${h.hidden('clone', value='clone')}
<div class="buttons">
${h.link_to("Whoops, nevermind...", form.cancel_url, class_='button autodisable')}
${h.submit('submit', "Yes, please clone away")}
</div>
${h.end_form()}
${h.form(request.current_route_url(), class_=None if use_buefy else 'autodisable')}
${h.csrf_token(request)}
${h.hidden('clone', value='clone')}
<div class="buttons">
% if use_buefy:
<once-button tag="a" href="${form.cancel_url}"
text="Whoops, nevermind...">
</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
<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)}
<div class="buttons">
% if use_buefy:

View file

@ -36,19 +36,29 @@
</script>
</%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">
% 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
${parent.body()}