Add generic support for "enable/disable selection" of grid records
This commit is contained in:
parent
05bb8a2df0
commit
13ec46b145
2 changed files with 120 additions and 18 deletions
tailbone/templates/master
|
@ -57,6 +57,38 @@
|
|||
|
||||
% endif
|
||||
|
||||
% if master.supports_set_enabled_toggle and request.has_perm('{}.enable_disable_set'.format(permission_prefix)):
|
||||
$('form[name="enable-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 enable.");
|
||||
return false;
|
||||
}
|
||||
if (! confirm("Are you sure you wish to ENABLE the " + uuids.length + " selected objects?")) {
|
||||
return false;
|
||||
}
|
||||
form.find('[name="uuids"]').val(uuids.toString());
|
||||
disable_button(this);
|
||||
form.submit();
|
||||
});
|
||||
|
||||
$('form[name="disable-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 disable.");
|
||||
return false;
|
||||
}
|
||||
if (! confirm("Are you sure you wish to DISABLE the " + uuids.length + " selected objects?")) {
|
||||
return false;
|
||||
}
|
||||
form.find('[name="uuids"]').val(uuids.toString());
|
||||
disable_button(this);
|
||||
form.submit();
|
||||
});
|
||||
% 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');
|
||||
|
@ -65,7 +97,7 @@
|
|||
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?")) {
|
||||
if (! confirm("Are you sure you wish to DELETE the " + uuids.length + " selected objects?")) {
|
||||
return false;
|
||||
}
|
||||
form.find('[name="uuids"]').val(uuids.toString());
|
||||
|
@ -104,11 +136,18 @@
|
|||
${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')}
|
||||
## enable / disable selected objects
|
||||
% if master.supports_set_enabled_toggle and request.has_perm('{}.enable_disable_set'.format(permission_prefix)):
|
||||
${h.form(url('{}.enable_set'.format(route_prefix)), name='enable-set')}
|
||||
${h.csrf_token(request)}
|
||||
<button type="button">Delete Results</button>
|
||||
${h.hidden('uuids')}
|
||||
<button type="button">Enable Selected</button>
|
||||
${h.end_form()}
|
||||
|
||||
${h.form(url('{}.disable_set'.format(route_prefix)), name='disable-set')}
|
||||
${h.csrf_token(request)}
|
||||
${h.hidden('uuids')}
|
||||
<button type="button">Disable Selected</button>
|
||||
${h.end_form()}
|
||||
% endif
|
||||
|
||||
|
@ -121,6 +160,14 @@
|
|||
${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
|
||||
|
||||
</%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