Add generic "bulk delete" support to MasterView
This commit is contained in:
parent
9712868406
commit
6ed752d477
3 changed files with 59 additions and 5 deletions
|
@ -43,6 +43,25 @@
|
|||
|
||||
% endif
|
||||
|
||||
% if master.bulk_deletable and request.has_perm('{}.bulk_delete'.format(permission_prefix)):
|
||||
|
||||
$('form[name="bulk-delete"] button').click(function() {
|
||||
var count = 0;
|
||||
var match = /showing \d+ thru \d+ of (\S+)/.exec($('.pager .showing').text());
|
||||
if (match) {
|
||||
count = match[1];
|
||||
} else {
|
||||
alert("There don't seem to be any results to delete!");
|
||||
return;
|
||||
}
|
||||
if (! confirm("You are about to delete " + count + " ${model_title_plural}.\n\nAre you sure?")) {
|
||||
return
|
||||
}
|
||||
$(this).button('disable').button('option', 'label', "Deleting Results...");
|
||||
$('form[name="bulk-delete"]').submit();
|
||||
});
|
||||
|
||||
% endif
|
||||
});
|
||||
</script>
|
||||
</%def>
|
||||
|
@ -61,6 +80,12 @@
|
|||
<button type="submit">Merge 2 ${model_title_plural}</button>
|
||||
${h.end_form()}
|
||||
% endif
|
||||
% 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
|
||||
</%def>
|
||||
|
||||
${grid.render_complete(tools=capture(self.grid_tools).strip(), context_menu=capture(self.context_menu_items).strip())|n}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue