Cleanup main version history views for Buefy theme

This commit is contained in:
Lance Edgar 2020-02-28 15:45:27 -06:00
parent 6d929dd95a
commit a2277feb10
3 changed files with 47 additions and 12 deletions

View file

@ -20,12 +20,38 @@
</%def>
<%def name="content_title()">
History for ${instance_title}
Version History
</%def>
<%def name="render_this_page()">
${self.page_content()}
</%def>
<%def name="make_this_page_component()">
${parent.make_this_page_component()}
<script type="text/javascript">
TailboneGrid.data = function() { return TailboneGridData }
Vue.component('tailbone-grid', TailboneGrid)
</script>
</%def>
<%def name="render_this_page_template()">
${parent.render_this_page_template()}
## TODO: stop using |n filter
${grid.render_buefy()|n}
</%def>
<%def name="page_content()">
% if use_buefy:
<tailbone-grid :csrftoken="csrftoken">
</tailbone-grid>
% else:
${grid.render_complete()|n}
% endif
</%def>
${parent.body()}

View file

@ -252,7 +252,7 @@
<span>&raquo;</span>
${h.link_to(parent_title, parent_url)}
% elif instance_url is not Undefined:
<span>&raquo;</span>
<span>&nbsp;&raquo;</span>
${h.link_to(instance_title, instance_url)}
% endif
% if master.viewing and grid_index:

View file

@ -553,17 +553,19 @@ class MasterView(View):
Return a dictionary of kwargs to be passed to the factory when
constructing a new version grid.
"""
use_buefy = self.get_use_buefy()
instance = kwargs.get('instance') or self.get_instance()
route = '{}.version'.format(self.get_route_prefix())
defaults = {
'model_class': continuum.transaction_class(self.get_model_class()),
'width': 'full',
'pageable': True,
'url': lambda txn: self.request.route_url(route, uuid=instance.uuid, txnid=txn.id),
}
if 'main_actions' not in kwargs:
route = '{}.version'.format(self.get_route_prefix())
instance = kwargs.get('instance') or self.get_instance()
url = lambda txn, i: self.request.route_url(route, uuid=instance.uuid, txnid=txn.id)
defaults['main_actions'] = [
self.make_action('view', icon='zoomin', url=url),
self.make_action('view', icon='eye' if use_buefy else 'zoomin', url=url),
]
defaults.update(kwargs)
return defaults
@ -574,8 +576,10 @@ class MasterView(View):
g.set_label('issued_at', "Changed")
g.set_label('user', "Changed by")
g.set_label('remote_addr', "IP Address")
# TODO: why does this render '#' as url?
# g.set_link('issued_at')
g.set_link('issued_at')
g.set_link('user')
g.set_link('comment')
def render_version_comment(self, transaction, column):
return transaction.meta.get('comment', "")
@ -1181,7 +1185,12 @@ class MasterView(View):
# return grid only, if partial page was requested
if self.request.params.get('partial'):
self.request.response.content_type = b'text/html'
if use_buefy:
# render grid data only, as JSON
return render_to_response('json', grid.get_buefy_data(),
request=self.request)
else: # just do traditional thing, render grid HTML
self.request.response.content_type = str('text/html')
self.request.response.text = grid.render_grid()
return self.request.response