fix: move "searchable columns" grid feature to wuttaweb
This commit is contained in:
parent
1d00fe994a
commit
ffa724ef37
|
@ -200,7 +200,6 @@ class Grid(WuttaGrid):
|
|||
filterable=False,
|
||||
filters={},
|
||||
use_byte_string_filters=False,
|
||||
searchable={},
|
||||
checkboxes=False,
|
||||
checked=None,
|
||||
check_handler=None,
|
||||
|
@ -254,6 +253,12 @@ class Grid(WuttaGrid):
|
|||
DeprecationWarning, stacklevel=2)
|
||||
kwargs.setdefault('page', kwargs.pop('default_page'))
|
||||
|
||||
if 'searchable' in kwargs:
|
||||
warnings.warn("searchable param is deprecated for Grid(); "
|
||||
"please use searchable_columns param instead",
|
||||
DeprecationWarning, stacklevel=2)
|
||||
kwargs.setdefault('searchable_columns', kwargs.pop('searchable'))
|
||||
|
||||
# TODO: this should not be needed once all templates correctly
|
||||
# reference grid.vue_component etc.
|
||||
kwargs.setdefault('vue_tagname', 'tailbone-grid')
|
||||
|
@ -287,8 +292,6 @@ class Grid(WuttaGrid):
|
|||
self.use_byte_string_filters = use_byte_string_filters
|
||||
self.filters = self.make_filters(filters)
|
||||
|
||||
self.searchable = searchable or {}
|
||||
|
||||
self.checkboxes = checkboxes
|
||||
self.checked = checked
|
||||
if self.checked is None:
|
||||
|
@ -481,15 +484,6 @@ class Grid(WuttaGrid):
|
|||
kwargs['label'] = self.labels[key]
|
||||
self.filters[key] = self.make_filter(key, *args, **kwargs)
|
||||
|
||||
def set_searchable(self, key, searchable=True):
|
||||
if searchable:
|
||||
self.searchable[key] = True
|
||||
else:
|
||||
self.searchable.pop(key, None)
|
||||
|
||||
def is_searchable(self, key):
|
||||
return self.searchable.get(key, False)
|
||||
|
||||
def remove_filter(self, key):
|
||||
self.filters.pop(key, None)
|
||||
|
||||
|
@ -1587,6 +1581,7 @@ class Grid(WuttaGrid):
|
|||
'field': name,
|
||||
'label': self.get_label(name),
|
||||
'sortable': self.is_sortable(name),
|
||||
'searchable': self.is_searchable(name),
|
||||
'visible': name not in self.invisible,
|
||||
})
|
||||
return columns
|
||||
|
|
|
@ -136,10 +136,8 @@
|
|||
<${b}-table-column field="${column['field']}"
|
||||
label="${column['label']}"
|
||||
v-slot="props"
|
||||
:sortable="${json.dumps(column.get('sortable', False))}"
|
||||
% if hasattr(grid, 'is_searchable') and grid.is_searchable(column['field']):
|
||||
searchable
|
||||
% endif
|
||||
:sortable="${json.dumps(column.get('sortable', False))|n}"
|
||||
:searchable="${json.dumps(column.get('searchable', False))|n}"
|
||||
cell-class="c_${column['field']}"
|
||||
:visible="${json.dumps(column.get('visible', True))}">
|
||||
% if hasattr(grid, 'raw_renderers') and column['field'] in grid.raw_renderers:
|
||||
|
|
|
@ -57,6 +57,12 @@ class TestGrid(WebTestCase):
|
|||
grid = self.make_grid(default_page=42)
|
||||
self.assertEqual(grid.page, 42)
|
||||
|
||||
# searchable
|
||||
grid = self.make_grid()
|
||||
self.assertEqual(grid.searchable_columns, set())
|
||||
grid = self.make_grid(searchable={'foo': True})
|
||||
self.assertEqual(grid.searchable_columns, {'foo'})
|
||||
|
||||
def test_vue_tagname(self):
|
||||
|
||||
# default
|
||||
|
|
Loading…
Reference in a new issue