Refactor template content_title()
and prev/next buttons feature
those were intertwined but now are a bit more separate, much better
This commit is contained in:
parent
9f743daf07
commit
eafe3737dc
|
@ -83,7 +83,25 @@
|
||||||
</div><!-- global -->
|
</div><!-- global -->
|
||||||
|
|
||||||
<div class="page">
|
<div class="page">
|
||||||
${self.content_title()}
|
% if capture(self.content_title):
|
||||||
|
|
||||||
|
% if show_prev_next is not Undefined and show_prev_next:
|
||||||
|
<div style="float: right;">
|
||||||
|
% if prev_url:
|
||||||
|
${h.link_to("« Older", prev_url, class_='button autodisable')}
|
||||||
|
% else:
|
||||||
|
${h.link_to("« Older", '#', class_='button', disabled='disabled')}
|
||||||
|
% endif
|
||||||
|
% if next_url:
|
||||||
|
${h.link_to("Newer »", next_url, class_='button autodisable')}
|
||||||
|
% else:
|
||||||
|
${h.link_to("Newer »", '#', class_='button', disabled='disabled')}
|
||||||
|
% endif
|
||||||
|
</div>
|
||||||
|
% endif
|
||||||
|
|
||||||
|
<h1>${self.content_title()}</h1>
|
||||||
|
% endif
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
@ -136,7 +154,7 @@
|
||||||
<%def name="title()"></%def>
|
<%def name="title()"></%def>
|
||||||
|
|
||||||
<%def name="content_title()">
|
<%def name="content_title()">
|
||||||
<h1>${self.title()}</h1>
|
${self.title()}
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="header_core()">
|
<%def name="header_core()">
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="content_title()">
|
<%def name="content_title()">
|
||||||
<h1>History for ${instance_title}</h1>
|
History for ${instance_title}
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
${grid.render_complete()|n}
|
${grid.render_complete()|n}
|
||||||
|
|
|
@ -26,21 +26,7 @@
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="content_title()">
|
<%def name="content_title()">
|
||||||
% if master.supports_prev_next:
|
${instance_title}
|
||||||
<div style="float: right;">
|
|
||||||
% if prev_instance:
|
|
||||||
${h.link_to(u"« Older", url('{}.view'.format(route_prefix), uuid=prev_instance.uuid), class_='button autodisable')}
|
|
||||||
% else:
|
|
||||||
${h.link_to(u"« Older", '#', class_='button', disabled='disabled')}
|
|
||||||
% endif
|
|
||||||
% if next_instance:
|
|
||||||
${h.link_to(u"Newer »", url('{}.view'.format(route_prefix), uuid=next_instance.uuid), class_='button autodisable')}
|
|
||||||
% else:
|
|
||||||
${h.link_to(u"Newer »", '#', class_='button', disabled='disabled')}
|
|
||||||
% endif
|
|
||||||
</div>
|
|
||||||
% endif
|
|
||||||
<h1>${instance_title}</h1>
|
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="context_menu_items()">
|
<%def name="context_menu_items()">
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<%def name="title()">${model_title}</%def>
|
<%def name="title()">${model_title}</%def>
|
||||||
|
|
||||||
<%def name="content_title()">
|
<%def name="content_title()">
|
||||||
<h1>${row_title}</h1>
|
${row_title}
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="context_menu_items()">
|
<%def name="context_menu_items()">
|
||||||
|
|
|
@ -5,22 +5,6 @@
|
||||||
|
|
||||||
## TODO: this was basically copied from Revel diff template..need to abstract
|
## TODO: this was basically copied from Revel diff template..need to abstract
|
||||||
|
|
||||||
<%def name="content_title()">
|
|
||||||
<div style="float: right;">
|
|
||||||
% if previous_transaction:
|
|
||||||
${h.link_to(u"« Older", url('{}.version'.format(route_prefix), uuid=instance.uuid, txnid=previous_transaction.id), class_='button')}
|
|
||||||
% else:
|
|
||||||
${h.link_to(u"« Older", '#', class_='button', disabled='disabled')}
|
|
||||||
% endif
|
|
||||||
% if next_transaction:
|
|
||||||
${h.link_to(u"Newer »", url('{}.version'.format(route_prefix), uuid=instance.uuid, txnid=next_transaction.id), class_='button')}
|
|
||||||
% else:
|
|
||||||
${h.link_to(u"Newer »", '#', class_='button', disabled='disabled')}
|
|
||||||
% endif
|
|
||||||
</div>
|
|
||||||
<h1>${self.title()}</h1>
|
|
||||||
</%def>
|
|
||||||
|
|
||||||
<div class="form-wrapper">
|
<div class="form-wrapper">
|
||||||
|
|
||||||
<div class="form">
|
<div class="form">
|
||||||
|
|
|
@ -160,7 +160,25 @@
|
||||||
## Page Title
|
## Page Title
|
||||||
<section id="content-title" class="hero is-primary">
|
<section id="content-title" class="hero is-primary">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
${self.content_title()}
|
% if capture(self.content_title):
|
||||||
|
|
||||||
|
% if show_prev_next is not Undefined and show_prev_next:
|
||||||
|
<div style="float: right;">
|
||||||
|
% if prev_url:
|
||||||
|
${h.link_to("« Older", prev_url, class_='button autodisable')}
|
||||||
|
% else:
|
||||||
|
${h.link_to("« Older", '#', class_='button', disabled='disabled')}
|
||||||
|
% endif
|
||||||
|
% if next_url:
|
||||||
|
${h.link_to("Newer »", next_url, class_='button autodisable')}
|
||||||
|
% else:
|
||||||
|
${h.link_to("Newer »", '#', class_='button', disabled='disabled')}
|
||||||
|
% endif
|
||||||
|
</div>
|
||||||
|
% endif
|
||||||
|
|
||||||
|
<h1 class="title">${self.content_title()}</h1>
|
||||||
|
% endif
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -208,7 +226,7 @@
|
||||||
<%def name="title()"></%def>
|
<%def name="title()"></%def>
|
||||||
|
|
||||||
<%def name="content_title()">
|
<%def name="content_title()">
|
||||||
<h1 class="title">${self.title()}</h1>
|
${self.title()}
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="header_core()">
|
<%def name="header_core()">
|
||||||
|
|
|
@ -1041,6 +1041,7 @@ class MasterView(View):
|
||||||
"""
|
"""
|
||||||
instance = self.get_instance()
|
instance = self.get_instance()
|
||||||
model_class = self.get_model_class()
|
model_class = self.get_model_class()
|
||||||
|
route_prefix = self.get_route_prefix()
|
||||||
Transaction = continuum.transaction_class(model_class)
|
Transaction = continuum.transaction_class(model_class)
|
||||||
transactions = model_transaction_query(self.Session(), instance, model_class,
|
transactions = model_transaction_query(self.Session(), instance, model_class,
|
||||||
child_classes=self.normalize_version_child_classes())
|
child_classes=self.normalize_version_child_classes())
|
||||||
|
@ -1058,6 +1059,13 @@ class MasterView(View):
|
||||||
.first()
|
.first()
|
||||||
|
|
||||||
instance_title = self.get_instance_title(instance)
|
instance_title = self.get_instance_title(instance)
|
||||||
|
|
||||||
|
prev_url = next_url = None
|
||||||
|
if older:
|
||||||
|
prev_url = self.request.route_url('{}.version'.format(route_prefix), uuid=instance.uuid, txnid=older.id)
|
||||||
|
if newer:
|
||||||
|
next_url = self.request.route_url('{}.version'.format(route_prefix), uuid=instance.uuid, txnid=newer.id)
|
||||||
|
|
||||||
return self.render_to_response('view_version', {
|
return self.render_to_response('view_version', {
|
||||||
'instance': instance,
|
'instance': instance,
|
||||||
'instance_title': "{} (history)".format(instance_title),
|
'instance_title': "{} (history)".format(instance_title),
|
||||||
|
@ -1066,6 +1074,9 @@ class MasterView(View):
|
||||||
'transaction': transaction,
|
'transaction': transaction,
|
||||||
'changed': localtime(self.rattail_config, transaction.issued_at, from_utc=True),
|
'changed': localtime(self.rattail_config, transaction.issued_at, from_utc=True),
|
||||||
'versions': self.get_relevant_versions(transaction, instance),
|
'versions': self.get_relevant_versions(transaction, instance),
|
||||||
|
'show_prev_next': True,
|
||||||
|
'prev_url': prev_url,
|
||||||
|
'next_url': next_url,
|
||||||
'previous_transaction': older,
|
'previous_transaction': older,
|
||||||
'next_transaction': newer,
|
'next_transaction': newer,
|
||||||
'title_for_version': self.title_for_version,
|
'title_for_version': self.title_for_version,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2018 Lance Edgar
|
# Copyright © 2010-2019 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -68,7 +68,6 @@ class UpgradeView(MasterView):
|
||||||
executable = True
|
executable = True
|
||||||
execute_progress_template = '/upgrade.mako'
|
execute_progress_template = '/upgrade.mako'
|
||||||
execute_progress_initial_msg = "Upgrading"
|
execute_progress_initial_msg = "Upgrading"
|
||||||
supports_prev_next = True
|
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
'executed_by': "Executed by",
|
'executed_by': "Executed by",
|
||||||
|
@ -142,14 +141,25 @@ class UpgradeView(MasterView):
|
||||||
|
|
||||||
def template_kwargs_view(self, **kwargs):
|
def template_kwargs_view(self, **kwargs):
|
||||||
upgrade = kwargs['instance']
|
upgrade = kwargs['instance']
|
||||||
|
|
||||||
|
kwargs['show_prev_next'] = True
|
||||||
|
kwargs['prev_url'] = None
|
||||||
|
kwargs['next_url'] = None
|
||||||
|
|
||||||
upgrades = self.Session.query(model.Upgrade)\
|
upgrades = self.Session.query(model.Upgrade)\
|
||||||
.filter(model.Upgrade.uuid != upgrade.uuid)
|
.filter(model.Upgrade.uuid != upgrade.uuid)
|
||||||
kwargs['prev_instance'] = upgrades.filter(model.Upgrade.created <= upgrade.created)\
|
older = upgrades.filter(model.Upgrade.created <= upgrade.created)\
|
||||||
.order_by(model.Upgrade.created.desc())\
|
.order_by(model.Upgrade.created.desc())\
|
||||||
.first()
|
.first()
|
||||||
kwargs['next_instance'] = upgrades.filter(model.Upgrade.created >= upgrade.created)\
|
newer = upgrades.filter(model.Upgrade.created >= upgrade.created)\
|
||||||
.order_by(model.Upgrade.created)\
|
.order_by(model.Upgrade.created)\
|
||||||
.first()
|
.first()
|
||||||
|
|
||||||
|
if older:
|
||||||
|
kwargs['prev_url'] = self.get_action_url('view', older)
|
||||||
|
if newer:
|
||||||
|
kwargs['next_url'] = self.get_action_url('view', newer)
|
||||||
|
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
def configure_form(self, f):
|
def configure_form(self, f):
|
||||||
|
|
Loading…
Reference in a new issue