Add generic support for "delete w/ simple confirm" in master index template
jquery only, for now
This commit is contained in:
parent
e715794f04
commit
3775c53df3
|
@ -16,12 +16,24 @@
|
||||||
${parent.extra_javascript()}
|
${parent.extra_javascript()}
|
||||||
% if use_buefy:
|
% if use_buefy:
|
||||||
${h.javascript_link(request.static_url('tailbone:static/js/tailbone.buefy.grid.js') + '?ver={}'.format(tailbone.__version__))}
|
${h.javascript_link(request.static_url('tailbone:static/js/tailbone.buefy.grid.js') + '?ver={}'.format(tailbone.__version__))}
|
||||||
% endif
|
% else:
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
% if not use_buefy:
|
|
||||||
$('.grid-wrapper').gridwrapper();
|
$('.grid-wrapper').gridwrapper();
|
||||||
|
|
||||||
|
% if master.deletable and request.has_perm('{}.delete'.format(permission_prefix)) and master.delete_confirm == 'simple':
|
||||||
|
|
||||||
|
$('.grid-wrapper').on('click', '.grid .actions a.delete', function() {
|
||||||
|
if (confirm("Are you sure you wish to delete this ${model_title}?")) {
|
||||||
|
var link = $(this).get(0);
|
||||||
|
var form = $('#delete-object-form').get(0);
|
||||||
|
form.action = link.href;
|
||||||
|
form.submit();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
% if master.mergeable and request.has_perm('{}.merge'.format(permission_prefix)):
|
% if master.mergeable and request.has_perm('{}.merge'.format(permission_prefix)):
|
||||||
|
@ -45,7 +57,7 @@
|
||||||
|
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
% if not use_buefy and master.bulk_deletable and request.has_perm('{}.bulk_delete'.format(permission_prefix)):
|
% if master.bulk_deletable and request.has_perm('{}.bulk_delete'.format(permission_prefix)):
|
||||||
|
|
||||||
$('form[name="bulk-delete"] button').click(function() {
|
$('form[name="bulk-delete"] button').click(function() {
|
||||||
var count = $('.grid-wrapper').gridwrapper('results_count', true);
|
var count = $('.grid-wrapper').gridwrapper('results_count', true);
|
||||||
|
@ -112,6 +124,7 @@
|
||||||
% endif
|
% endif
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
% endif
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="context_menu_items()">
|
<%def name="context_menu_items()">
|
||||||
|
@ -228,4 +241,9 @@
|
||||||
## no buefy, so do the traditional thing
|
## no buefy, so do the traditional thing
|
||||||
${grid.render_complete(tools=capture(self.grid_tools).strip(), context_menu=capture(self.context_menu_items).strip())|n}
|
${grid.render_complete(tools=capture(self.grid_tools).strip(), context_menu=capture(self.context_menu_items).strip())|n}
|
||||||
|
|
||||||
|
% if master.deletable and request.has_perm('{}.delete'.format(permission_prefix)) and master.delete_confirm == 'simple':
|
||||||
|
${h.form('#', id='delete-object-form')}
|
||||||
|
${h.csrf_token(request)}
|
||||||
|
${h.end_form()}
|
||||||
|
% endif
|
||||||
% endif
|
% endif
|
||||||
|
|
Loading…
Reference in a new issue