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:
parent
f25e4fab28
commit
796170100f
|
@ -1,5 +1,5 @@
|
|||
## -*- coding: utf-8; -*-
|
||||
<%inherit file="/form.mako" />
|
||||
<%inherit file="/master/form.mako" />
|
||||
|
||||
<%def name="title()">Edit: ${instance_title}</%def>
|
||||
|
||||
|
@ -24,9 +24,7 @@
|
|||
% if master.viewable and request.has_perm('{}.view'.format(permission_prefix)):
|
||||
<li>${h.link_to("View this {}".format(model_title), action_url('view', 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))}</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>
|
||||
|
|
22
tailbone/templates/master/form.mako
Normal file
22
tailbone/templates/master/form.mako
Normal file
|
@ -0,0 +1,22 @@
|
|||
## -*- coding: utf-8; -*-
|
||||
<%inherit file="/form.mako" />
|
||||
|
||||
<%def name="context_menu_item_delete()">
|
||||
% if master.deletable and instance_deletable and request.has_perm('{}.delete'.format(permission_prefix)):
|
||||
% if master.delete_confirm == 'simple':
|
||||
<li>
|
||||
${h.form(action_url('delete', instance))}
|
||||
${h.csrf_token(request)}
|
||||
<a href="#" class="delete-instance">
|
||||
Delete this ${model_title}
|
||||
</a>
|
||||
${h.end_form()}
|
||||
</li>
|
||||
% else:
|
||||
## assuming here that: delete_confirm == 'full'
|
||||
<li>${h.link_to("Delete this {}".format(model_title), action_url('delete', instance))}</li>
|
||||
% endif
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
${parent.body()}
|
|
@ -1,10 +1,28 @@
|
|||
## -*- coding: utf-8; -*-
|
||||
<%inherit file="/form.mako" />
|
||||
<%inherit file="/master/form.mako" />
|
||||
|
||||
<%def name="title()">${index_title} » ${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>
|
||||
|
|
|
@ -83,6 +83,7 @@ class MasterView(View):
|
|||
viewable = True
|
||||
editable = True
|
||||
deletable = True
|
||||
delete_confirm = 'full'
|
||||
bulk_deletable = False
|
||||
set_deletable = False
|
||||
supports_set_enabled_toggle = False
|
||||
|
|
Loading…
Reference in a new issue