fix: add pager stats to all grid vue data (fixes view history)

also various other tweaks to modernize
This commit is contained in:
Lance Edgar 2024-08-19 13:48:18 -05:00
parent 41945c5e37
commit 15ab0c9592
4 changed files with 21 additions and 28 deletions

View file

@ -237,7 +237,7 @@ class Grid(WuttaGrid):
kwargs.setdefault('sort_defaults', [(sortkey, sortdir)])
if kwargs.get('pageable'):
warnings.warn("component param is deprecated for Grid(); "
warnings.warn("pageable param is deprecated for Grid(); "
"please use vue_tagname param instead",
DeprecationWarning, stacklevel=2)
kwargs.setdefault('paginated', kwargs.pop('pageable'))
@ -1703,6 +1703,10 @@ class Grid(WuttaGrid):
results['checked_rows_code'] = '[{}]'.format(
', '.join(['{}[{}]'.format(var, i) for i in checked]))
if self.paginated and self.paginate_on_backend:
results['pager_stats'] = self.get_vue_pager_stats()
# TODO: is this actually needed now that we have pager_stats?
if self.paginated and self.pager is not None:
results['total_items'] = self.pager.item_count
results['per_page'] = self.pager.items_per_page