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

View file

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

View file

@ -73,6 +73,10 @@ class MasterView(View):
pageable = True pageable = True
checkboxes = False 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 # set to True in order to encode search values as utf-8
use_byte_string_filters = False use_byte_string_filters = False
@ -399,6 +403,7 @@ class MasterView(View):
'url': lambda obj: self.get_action_url('view', obj), 'url': lambda obj: self.get_action_url('view', obj),
'checkboxes': checkboxes, 'checkboxes': checkboxes,
'checked': self.checked, 'checked': self.checked,
'clicking_row_checks_box': self.clicking_row_checks_box,
'assume_local_times': self.has_local_times, 'assume_local_times': self.has_local_times,
} }
if 'main_actions' not in kwargs and 'more_actions' not in kwargs: if 'main_actions' not in kwargs and 'more_actions' not in kwargs: