Add template support for "delete selected objects" feature

whoops, should have been part of last commit
This commit is contained in:
Lance Edgar 2019-02-02 19:43:47 -06:00
parent 84fc3e7d50
commit 22c71d832e

View file

@ -56,6 +56,23 @@
});
% endif
% if master.set_deletable and request.has_perm('{}.delete_set'.format(permission_prefix)):
$('form[name="delete-set"] button').click(function() {
var form = $(this).parents('form');
var uuids = $('.grid').gridcore('selected_uuids');
if (! uuids.length) {
alert("You must first select one or more objects to delete.");
return false;
}
if (! confirm("Are you sure you wish to delete the " + uuids.length + " selected objects?")) {
return false;
}
form.find('[name="uuids"]').val(uuids.toString());
disable_button(this);
form.submit();
});
% endif
});
</script>
</%def>
@ -77,6 +94,8 @@
</%def>
<%def name="grid_tools()">
## merge 2 objects
% if master.mergeable and request.has_perm('{}.merge'.format(permission_prefix)):
${h.form(url('{}.merge'.format(route_prefix)), name='merge-things')}
${h.csrf_token(request)}
@ -84,12 +103,24 @@
<button type="submit">Merge 2 ${model_title_plural}</button>
${h.end_form()}
% endif
## delete search results
% if master.bulk_deletable and request.has_perm('{}.bulk_delete'.format(permission_prefix)):
${h.form(url('{}.bulk_delete'.format(route_prefix)), name='bulk-delete')}
${h.csrf_token(request)}
<button type="button">Delete Results</button>
${h.end_form()}
% endif
## delete selected objects
% if request.has_perm('{}.delete_set'.format(permission_prefix)):
${h.form(url('{}.delete_set'.format(route_prefix)), name='delete-set')}
${h.csrf_token(request)}
${h.hidden('uuids')}
<button type="button">Delete Selected</button>
${h.end_form()}
% endif
</%def>
${grid.render_complete(tools=capture(self.grid_tools).strip(), context_menu=capture(self.context_menu_items).strip())|n}