From a2277feb105d11b1c27c15426da6009f590f0abc Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Fri, 28 Feb 2020 15:45:27 -0600 Subject: [PATCH] Cleanup main version history views for Buefy theme --- tailbone/templates/master/versions.mako | 32 +++++++++++++++++++-- tailbone/templates/themes/falafel/base.mako | 2 +- tailbone/views/master.py | 25 ++++++++++------ 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/tailbone/templates/master/versions.mako b/tailbone/templates/master/versions.mako index ccd0c6b8..2d1b4db3 100644 --- a/tailbone/templates/master/versions.mako +++ b/tailbone/templates/master/versions.mako @@ -20,12 +20,38 @@ <%def name="content_title()"> - History for ${instance_title} + Version History + + +<%def name="render_this_page()"> + ${self.page_content()} + + +<%def name="make_this_page_component()"> + ${parent.make_this_page_component()} + + + +<%def name="render_this_page_template()"> + ${parent.render_this_page_template()} + + ## TODO: stop using |n filter + ${grid.render_buefy()|n} <%def name="page_content()"> - ${grid.render_complete()|n} + % if use_buefy: + + + % else: + ${grid.render_complete()|n} + % endif - ${parent.body()} diff --git a/tailbone/templates/themes/falafel/base.mako b/tailbone/templates/themes/falafel/base.mako index b3ca7d54..0e2754f1 100644 --- a/tailbone/templates/themes/falafel/base.mako +++ b/tailbone/templates/themes/falafel/base.mako @@ -252,7 +252,7 @@ » ${h.link_to(parent_title, parent_url)} % elif instance_url is not Undefined: - » +  » ${h.link_to(instance_title, instance_url)} % endif % if master.viewing and grid_index: diff --git a/tailbone/views/master.py b/tailbone/views/master.py index da08aa62..ab8bf658 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -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,9 +1185,14 @@ 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' - self.request.response.text = grid.render_grid() - return self.request.response + 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 return self.render_to_response('versions', { 'instance': instance,