Require explicit opt-in for "clicking grid row checks box" feature

sometimes it makes sense *not* to enable that, in which case disabled
probably should be the default
This commit is contained in:
Lance Edgar 2021-08-23 19:26:50 -05:00
parent a881b310bc
commit 3cf4c0f8e4
3 changed files with 9 additions and 0 deletions

View file

@ -75,6 +75,7 @@ class Grid(object):
sortable=False, sorters={}, default_sortkey=None, default_sortdir='asc',
pageable=False, default_pagesize=20, default_page=1,
checkboxes=False, checked=None, check_handler=None, check_all_handler=None,
clicking_row_checks_box=False,
main_actions=[], more_actions=[], delete_speedbump=False,
ajax_data_url=None, component='tailbone-grid',
**kwargs):
@ -128,6 +129,7 @@ class Grid(object):
self.checked = lambda item: False
self.check_handler = check_handler
self.check_all_handler = check_all_handler
self.clicking_row_checks_box = clicking_row_checks_box
self.main_actions = main_actions or []
self.more_actions = more_actions or []

View file

@ -143,8 +143,10 @@
:checkable="checkable"
% if grid.checkboxes:
:checked-rows.sync="checkedRows"
% if grid.clicking_row_checks_box:
@click="rowClick"
% endif
% endif
% if grid.check_handler:
@check="${grid.check_handler}"
% endif

View file

@ -73,6 +73,10 @@ class MasterView(View):
pageable = True
checkboxes = False
# set to True to allow user to click "anywhere" in a row in order
# to toggle its checkbox
clicking_row_checks_box = False
# set to True in order to encode search values as utf-8
use_byte_string_filters = False
@ -399,6 +403,7 @@ class MasterView(View):
'url': lambda obj: self.get_action_url('view', obj),
'checkboxes': checkboxes,
'checked': self.checked,
'clicking_row_checks_box': self.clicking_row_checks_box,
'assume_local_times': self.has_local_times,
}
if 'main_actions' not in kwargs and 'more_actions' not in kwargs: