fix: misc. bugfixes per recent changes

This commit is contained in:
Lance Edgar 2024-08-22 15:14:11 -05:00
parent f292850d05
commit 7b40c527c8
2 changed files with 14 additions and 20 deletions

View file

@ -260,6 +260,9 @@ class Grid(WuttaGrid):
# reference grid.vue_component etc.
kwargs.setdefault('vue_tagname', 'tailbone-grid')
# nb. these must be set before super init, as they are
# referenced when constructing filters
self.assume_local_times = assume_local_times
self.use_byte_string_filters = use_byte_string_filters
kwargs['key'] = key
@ -279,7 +282,6 @@ class Grid(WuttaGrid):
self.width = width
self.enums = enums or {}
self.assume_local_times = assume_local_times
self.renderers = self.make_default_renderers(self.renderers)
self.raw_renderers = raw_renderers or {}
self.invisible = invisible or []
@ -476,23 +478,16 @@ class Grid(WuttaGrid):
def set_filter(self, key, *args, **kwargs):
""" """
if len(args) == 1:
if args[0] is None:
warnings.warn("specifying None is deprecated for Grid.set_filter(); "
"please use Grid.remove_filter() instead",
DeprecationWarning, stacklevel=2)
self.remove_filter(key)
else:
super().set_filter(key, args[0], **kwargs)
return
elif len(args) == 0:
super().set_filter(key, **kwargs)
else:
warnings.warn("multiple args are deprecated for Grid.set_filter(); "
"please refactor your code accordingly",
DeprecationWarning, stacklevel=2)
# TODO: our make_filter() signature differs from upstream,
# so must call it explicitly instead of delegating to super
kwargs.setdefault('label', self.get_label(key))
self.filters[key] = self.make_filter(key, *args, **kwargs)
@ -1230,7 +1225,7 @@ class Grid(WuttaGrid):
context['data_prop'] = data_prop
context['empty_labels'] = empty_labels
if 'grid_columns' not in context:
context['grid_columns'] = self.get_table_columns()
context['grid_columns'] = self.get_vue_columns()
context.setdefault('paginated', False)
if context['paginated']:
context.setdefault('per_page', 20)

View file

@ -116,11 +116,12 @@ class EmailSettingView(MasterView):
return data
def configure_grid(self, g):
g.sorters['key'] = g.make_simple_sorter('key', foldcase=True)
g.sorters['prefix'] = g.make_simple_sorter('prefix', foldcase=True)
g.sorters['subject'] = g.make_simple_sorter('subject', foldcase=True)
g.sorters['enabled'] = g.make_simple_sorter('enabled')
super().configure_grid(g)
g.sort_on_backend = False
g.sort_multiple = False
g.set_sort_defaults('key')
g.set_type('enabled', 'boolean')
g.set_link('key')
g.set_link('subject')
@ -130,11 +131,9 @@ class EmailSettingView(MasterView):
# to
g.set_renderer('to', self.render_to_short)
g.sorters['to'] = g.make_simple_sorter('to', foldcase=True)
# hidden
if self.has_perm('configure'):
g.sorters['hidden'] = g.make_simple_sorter('hidden')
g.set_type('hidden', 'boolean')
else:
g.remove('hidden')