fix: add pager stats to all grid vue data (fixes view history)
also various other tweaks to modernize
This commit is contained in:
parent
41945c5e37
commit
15ab0c9592
|
@ -237,7 +237,7 @@ class Grid(WuttaGrid):
|
||||||
kwargs.setdefault('sort_defaults', [(sortkey, sortdir)])
|
kwargs.setdefault('sort_defaults', [(sortkey, sortdir)])
|
||||||
|
|
||||||
if kwargs.get('pageable'):
|
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",
|
"please use vue_tagname param instead",
|
||||||
DeprecationWarning, stacklevel=2)
|
DeprecationWarning, stacklevel=2)
|
||||||
kwargs.setdefault('paginated', kwargs.pop('pageable'))
|
kwargs.setdefault('paginated', kwargs.pop('pageable'))
|
||||||
|
@ -1703,6 +1703,10 @@ class Grid(WuttaGrid):
|
||||||
results['checked_rows_code'] = '[{}]'.format(
|
results['checked_rows_code'] = '[{}]'.format(
|
||||||
', '.join(['{}[{}]'.format(var, i) for i in checked]))
|
', '.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:
|
if self.paginated and self.pager is not None:
|
||||||
results['total_items'] = self.pager.item_count
|
results['total_items'] = self.pager.item_count
|
||||||
results['per_page'] = self.pager.items_per_page
|
results['per_page'] = self.pager.items_per_page
|
||||||
|
|
|
@ -115,7 +115,7 @@
|
||||||
## paging
|
## paging
|
||||||
% if grid.paginated:
|
% if grid.paginated:
|
||||||
paginated
|
paginated
|
||||||
pagination-size="is-small"
|
pagination-size="${'small' if request.use_oruga else 'is-small'}"
|
||||||
:per-page="perPage"
|
:per-page="perPage"
|
||||||
:current-page="currentPage"
|
:current-page="currentPage"
|
||||||
@page-change="onPageChange"
|
@page-change="onPageChange"
|
||||||
|
|
|
@ -120,9 +120,7 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<versions-grid ref="versionsGrid"
|
${versions_grid.render_vue_tag(ref='versionsGrid', **{'@view-revision': 'viewRevision'})}
|
||||||
@view-revision="viewRevision">
|
|
||||||
</versions-grid>
|
|
||||||
|
|
||||||
<${b}-modal :width="1200"
|
<${b}-modal :width="1200"
|
||||||
% if request.use_oruga:
|
% if request.use_oruga:
|
||||||
|
@ -237,17 +235,16 @@
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="render_row_grid_component()">
|
<%def name="render_row_grid_component()">
|
||||||
<tailbone-grid ref="rowGrid" id="rowGrid"></tailbone-grid>
|
${rows_grid.render_vue_tag(id='rowGrid', ref='rowGrid')}
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="render_this_page_template()">
|
<%def name="render_this_page_template()">
|
||||||
% if getattr(master, 'has_rows', False):
|
% if getattr(master, 'has_rows', False):
|
||||||
## TODO: stop using |n filter
|
${rows_grid.render_vue_template(allow_save_defaults=False, tools=capture(self.render_row_grid_tools))}
|
||||||
${rows_grid.render_complete(allow_save_defaults=False, tools=capture(self.render_row_grid_tools))|n}
|
|
||||||
% endif
|
% endif
|
||||||
${parent.render_this_page_template()}
|
${parent.render_this_page_template()}
|
||||||
% if expose_versions:
|
% if expose_versions:
|
||||||
${versions_grid.render_complete()|n}
|
${versions_grid.render_vue_template()}
|
||||||
% endif
|
% endif
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
|
@ -338,19 +335,12 @@
|
||||||
|
|
||||||
<%def name="finalize_this_page_vars()">
|
<%def name="finalize_this_page_vars()">
|
||||||
${parent.finalize_this_page_vars()}
|
${parent.finalize_this_page_vars()}
|
||||||
<script type="text/javascript">
|
% if getattr(master, 'has_rows', False):
|
||||||
|
${rows_grid.render_vue_finalize()}
|
||||||
% if getattr(master, 'has_rows', False):
|
% endif
|
||||||
TailboneGrid.data = function() { return TailboneGridData }
|
% if expose_versions:
|
||||||
Vue.component('tailbone-grid', TailboneGrid)
|
${versions_grid.render_vue_finalize()}
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
% if expose_versions:
|
|
||||||
VersionsGrid.data = function() { return VersionsGridData }
|
|
||||||
Vue.component('versions-grid', VersionsGrid)
|
|
||||||
% endif
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -347,8 +347,6 @@ class MasterView(View):
|
||||||
# return grid data only, if partial page was requested
|
# return grid data only, if partial page was requested
|
||||||
if self.request.GET.get('partial'):
|
if self.request.GET.get('partial'):
|
||||||
context = grid.get_table_data()
|
context = grid.get_table_data()
|
||||||
if grid.paginated and grid.paginate_on_backend:
|
|
||||||
context['pager_stats'] = grid.get_vue_pager_stats()
|
|
||||||
return self.json_response(context)
|
return self.json_response(context)
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
|
@ -587,7 +585,8 @@ class MasterView(View):
|
||||||
'filterable': self.rows_filterable,
|
'filterable': self.rows_filterable,
|
||||||
'use_byte_string_filters': self.use_byte_string_filters,
|
'use_byte_string_filters': self.use_byte_string_filters,
|
||||||
'sortable': self.rows_sortable,
|
'sortable': self.rows_sortable,
|
||||||
'pageable': self.rows_pageable,
|
'sort_multiple': not self.request.use_oruga,
|
||||||
|
'paginated': self.rows_pageable,
|
||||||
'extra_row_class': self.row_grid_extra_class,
|
'extra_row_class': self.row_grid_extra_class,
|
||||||
'url': lambda obj: self.get_row_action_url('view', obj),
|
'url': lambda obj: self.get_row_action_url('view', obj),
|
||||||
}
|
}
|
||||||
|
@ -675,7 +674,7 @@ class MasterView(View):
|
||||||
defaults = {
|
defaults = {
|
||||||
'model_class': continuum.transaction_class(self.get_model_class()),
|
'model_class': continuum.transaction_class(self.get_model_class()),
|
||||||
'width': 'full',
|
'width': 'full',
|
||||||
'pageable': True,
|
'paginated': True,
|
||||||
'url': lambda txn: self.request.route_url(route, uuid=instance.uuid, txnid=txn.id),
|
'url': lambda txn: self.request.route_url(route, uuid=instance.uuid, txnid=txn.id),
|
||||||
}
|
}
|
||||||
if 'actions' not in kwargs:
|
if 'actions' not in kwargs:
|
||||||
|
@ -1387,8 +1386,8 @@ class MasterView(View):
|
||||||
'vue_tagname': 'versions-grid',
|
'vue_tagname': 'versions-grid',
|
||||||
'ajax_data_url': self.get_action_url('revisions_data', obj),
|
'ajax_data_url': self.get_action_url('revisions_data', obj),
|
||||||
'sortable': True,
|
'sortable': True,
|
||||||
'default_sortkey': 'changed',
|
'sort_multiple': not self.request.use_oruga,
|
||||||
'default_sortdir': 'desc',
|
'sort_defaults': ('changed', 'desc'),
|
||||||
'actions': [
|
'actions': [
|
||||||
self.make_action('view', icon='eye', url='#',
|
self.make_action('view', icon='eye', url='#',
|
||||||
click_handler='viewRevision(props.row)'),
|
click_handler='viewRevision(props.row)'),
|
||||||
|
|
Loading…
Reference in a new issue