Skip to content

Commit

Permalink
Quick link to last edit page
Browse files Browse the repository at this point in the history
  • Loading branch information
PonteIneptique committed Mar 29, 2018
1 parent 4fcc620 commit 7ebfb34
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
4 changes: 1 addition & 3 deletions app/templates/layouts/base.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% import 'macros/nav_macros.html' as nav %}

<!DOCTYPE html>
<html>
<head>
Expand All @@ -20,8 +19,7 @@
<div class="starter-template col-lg-10 offset-lg-1">
{% include 'partials/_flashes.html' %}
{# When extended, the content block contains all the html of the webpage #}
{% block content %}
{% endblock %}
{% block content %}{% endblock %}
</div>
</div>
</div>
Expand Down
19 changes: 17 additions & 2 deletions app/templates/macros/nav_macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,29 @@
{% endmacro %}

{%- macro quick_nav(corpus) %}
{%- if request.path != url_for("main.tokens_edit", corpus_id=corpus.id) %}
{%- if request.endpoint != 'main.tokens_edit' %}
<div class="container-fluid">
<nav style="margin-bottom: 10px;">
<span class="btn btn-sm btn-link">Quick links :</span>
<a class="btn btn-sm btn-info" href="{{ url_for("main.tokens_edit", corpus_id=corpus.id) }}">
<span class="fa fa-back"></span>
<span class="fa fa-pencil"></span>
Edit tokens
</a>
<a class="btn btn-sm btn-info d-none" href="{{ url_for("main.tokens_edit", corpus_id=corpus.id) }}" id="last-edit-link">
<span class="fa fa-history"></span>
Last Edit tokens
</a>
</nav>
</div>
<script type="text/javascript">
$(document).ready(function() {
var last_page = localStorage.getItem("corpus-{{corpus.id}}");
if (last_page) {
var lastLink = $("#last-edit-link");
lastLink.removeClass("d-none");
lastLink.attr("href", lastLink.attr("href")+"?page="+last_page);
}
});
</script>
{% endif %}
{% endmacro %}
6 changes: 6 additions & 0 deletions app/templates/main/tokens_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ <h1>Corpus {{corpus.name}} - List of tokens </h1>

{{ nav.render_pagination(pagination=tokens, corpus_id=corpus.id, endpoint="main.tokens_edit") }}

<script type="text/javascript">
// These lines allows to remember what was the last page edited.
var corpus = {{ request.view_args.get("corpus_id") }},
page = {{ request.args.get("page", 1) }};
localStorage.setItem("corpus-"+corpus.toString(), page);
</script>
{% endblock %}

0 comments on commit 7ebfb34

Please sign in to comment.