Commit 90680b91 authored by Miquel Torres's avatar Miquel Torres Committed by GitHub
Browse files

Merge pull request #226 from str4d/174-changes-navigation

Add previous and next revision nav links to Changes view
parents 7be8ea97 43a95a36
......@@ -165,6 +165,18 @@ div#configbar span.options {
padding-right: 1.8em; font-size: 90%; white-space: nowrap; }
div#configbar input { margin-right: 0; vertical-align: middle; }
div#contentnav a {
font-size: small;
padding-bottom: 0.25em;
}
div#contentnav a:hover { text-decoration: underline; }
div#contentnav #previous {
float: left;
}
div#contentnav #next {
float: right;
}
div#content, div.about_content {
margin-left: 14.5em;
text-align: center;
......
......@@ -5,10 +5,10 @@ var TIMELINE_URL = window.TIMELINE_URL, getLoadText = window.getLoadText;
var currentproject, changethres, trendthres, projectmatrix, revisionboxes = {};
function getConfiguration() {
function getConfiguration(revision) {
return {
tre: $("#trend option:selected").val(),
rev: $("#revision option:selected").val(),
rev: revision || $("#revision option:selected").val(),
exe: $("input[name='executable']:checked").val(),
env: $("input[name='environment']:checked").val()
};
......@@ -66,14 +66,40 @@ function updateTable() {
//Configure table as tablesorter
$(".tablesorter").tablesorter({widgets: ['zebra']});
// Set prev and next links
$("#previous").click(function() {
refreshContentRev(
$("#previous").data("revision"),
$("#previous").data("desc")
);
});
$("#next").click(function() {
refreshContentRev(
$("#next").data("revision"),
$("#next").data("desc")
);
});
}
function refreshContent() {
refreshContentTable($("#revision option:selected").val());
}
function refreshContentRev(revision, desc) {
if ($('#revision option[value='+revision+']').length == 0) {
$("#revision").append($("<option value='" + revision + "'>" + desc + "</option>"));
}
$("#revision").val(revision);
refreshContentTable(revision);
}
function refreshContentTable(revision) {
var h = $("#content").height();//get height for loading text
$("#contentwrap").fadeOut("fast", function() {
$(this).show();
$(this).html(getLoadText("Loading...", h));
$(this).load("table/", $.param(getConfiguration()), function() { updateTable(); });
$(this).load("table/", $.param(getConfiguration(revision)), function() { updateTable(); });
});
}
......
{% load percentages %}
<div id="contentnav">
{% if prev %}<a id="previous" href="#" data-revision="{{ prev.rev }}" data-desc="{{ prev.desc }}">← {{ prev.short_rev }}{% if prev.summary %} ({{ prev.summary }}){% endif %}</a>{% endif %}
{% if next %}<a id="next" href="#" data-revision="{{ next.rev }}" data-desc="{{ next.desc }}">{{ next.short_rev }}{% if next.summary %} ({{ next.summary }}){% endif %} →</a>{% endif %}
</div>
{% for units in tablelist %}
<table class="tablesorter" data-lessisbetter="{{ units.lessisbetter }}">
<thead>
......
......@@ -516,6 +516,47 @@ def getchangestable(request):
raise Http404()
selectedrev = get_object_or_404(Revision, commitid=request.GET.get('rev'),
branch__project=executable.project)
prevrev = Revision.objects.filter(
branch=selectedrev.branch,
date__lt=selectedrev.date,
).order_by('-date').first()
if prevrev:
try:
summary = Report.objects.get(
revision=prevrev,
executable=executable,
environment=environment).item_description
except Report.DoesNotExist:
summary = ''
prevrev = {
'desc': str(prevrev),
'rev': prevrev.commitid,
'short_rev': prevrev.get_short_commitid(),
'summary': summary,
}
else:
prevrev = None
nextrev = Revision.objects.filter(
branch=selectedrev.branch,
date__gt=selectedrev.date,
).order_by('date').first()
if nextrev:
try:
summary = Report.objects.get(
revision=nextrev,
executable=executable,
environment=environment).item_description
except Report.DoesNotExist:
summary = ''
nextrev = {
'desc': str(nextrev),
'rev': nextrev.commitid,
'short_rev': nextrev.get_short_commitid(),
'summary': summary,
}
else:
nextrev = None
report, created = Report.objects.get_or_create(
executable=executable, environment=environment, revision=selectedrev
......@@ -534,6 +575,8 @@ def getchangestable(request):
'rev': selectedrev,
'exe': executable,
'env': environment,
'prev': prevrev,
'next': nextrev,
}, context_instance=RequestContext(request))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment