Add support for "simple confirm" of object deletion

i.e. can just use `window.confirm()` instead of showing full confirm page

note, this is jquery-only for now
This commit is contained in:
Lance Edgar 2019-06-08 18:39:52 -05:00
parent f25e4fab28
commit 796170100f
4 changed files with 45 additions and 8 deletions

View file

@ -1,10 +1,28 @@
## -*- coding: utf-8; -*-
<%inherit file="/form.mako" />
<%inherit file="/master/form.mako" />
<%def name="title()">${index_title} &raquo; ${instance_title}</%def>
<%def name="extra_javascript()">
${parent.extra_javascript()}
% if master.deletable and instance_deletable and request.has_perm('{}.delete'.format(permission_prefix)) and master.delete_confirm == 'simple':
% if not use_buefy:
<script type="text/javascript">
$(function () {
$('#context-menu a.delete-instance').on('click', function() {
if (confirm("Are you sure you wish to delete this ${model_title}?")) {
$(this).parents('form').submit();
}
return false;
});
});
</script>
% endif
% endif
% if master.has_rows:
% if use_buefy:
${h.javascript_link(request.static_url('tailbone:static/js/tailbone.buefy.grid.js') + '?ver={}'.format(tailbone.__version__))}
@ -41,9 +59,7 @@
% if master.editable and instance_editable and request.has_perm('{}.edit'.format(permission_prefix)):
<li>${h.link_to("Edit this {}".format(model_title), action_url('edit', instance))}</li>
% endif
% if master.deletable and instance_deletable and request.has_perm('{}.delete'.format(permission_prefix)):
<li>${h.link_to("Delete this {}".format(model_title), action_url('delete', instance), class_='delete-instance')}</li>
% endif
${self.context_menu_item_delete()}
% if master.creatable and master.show_create_link and request.has_perm('{}.create'.format(permission_prefix)):
% if master.creates_multiple:
<li>${h.link_to("Create new {}".format(model_title_plural), url('{}.create'.format(route_prefix)))}</li>