Allow master view to decide whether each grid checkbox is checked

aka. un-break what the v3 grids broke..
This commit is contained in:
Lance Edgar 2017-07-26 17:10:09 -05:00
parent f1bb603f93
commit 39cf32bb0a
2 changed files with 5 additions and 8 deletions

View file

@ -56,7 +56,7 @@ class Grid(object):
joiners={}, filterable=False, filters={}, joiners={}, filterable=False, filters={},
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, main_actions=[], more_actions=[], checkboxes=False, checked=None, main_actions=[], more_actions=[],
**kwargs): **kwargs):
self.key = key self.key = key
@ -90,6 +90,9 @@ class Grid(object):
self.default_page = default_page self.default_page = default_page
self.checkboxes = checkboxes self.checkboxes = checkboxes
self.checked = checked
if self.checked is None:
self.checked = lambda item: False
self.main_actions = main_actions self.main_actions = main_actions
self.more_actions = more_actions self.more_actions = more_actions
@ -882,13 +885,6 @@ class Grid(object):
""" """
return True return True
def checked(self, item):
"""
Returns boolean indicating whether the given item's row checkbox should
be checked, for initial page load.
"""
return False
def render_checkbox(self, item): def render_checkbox(self, item):
""" """
Renders a checkbox cell for the given item, if applicable. Renders a checkbox cell for the given item, if applicable.

View file

@ -258,6 +258,7 @@ class MasterView2(MasterView):
'url': lambda obj: self.get_action_url('view', obj), 'url': lambda obj: self.get_action_url('view', obj),
'checkboxes': self.checkboxes or ( 'checkboxes': self.checkboxes or (
self.mergeable and self.request.has_perm('{}.merge'.format(self.get_permission_prefix()))), self.mergeable and self.request.has_perm('{}.merge'.format(self.get_permission_prefix()))),
'checked': self.checked,
} }
if 'main_actions' not in kwargs and 'more_actions' not in kwargs: if 'main_actions' not in kwargs and 'more_actions' not in kwargs:
main, more = self.get_grid_actions() main, more = self.get_grid_actions()