2018-06-02 19:22:57 +02:00
|
|
|
{% extends "base.html" %}
|
|
|
|
|
|
|
|
{% block title %}
|
|
|
|
Topics to be Added
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block content %}
|
2018-12-25 16:20:58 +01:00
|
|
|
<div class="float-right btn-group">
|
|
|
|
{% if current_user.rank.atLeast(current_user.rank.EDITOR) %}
|
|
|
|
{% if n >= 10000 %}
|
|
|
|
<a class="btn btn-primary"
|
2018-12-25 17:40:19 +01:00
|
|
|
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=100, sort=sort_by) }}">
|
2018-12-25 16:20:58 +01:00
|
|
|
Paginiated List
|
|
|
|
</a>
|
|
|
|
{% else %}
|
|
|
|
<a class="btn btn-primary"
|
2018-12-25 17:40:19 +01:00
|
|
|
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=10000, sort=sort_by) }}">
|
2018-12-25 16:20:58 +01:00
|
|
|
Unlimited List
|
|
|
|
</a>
|
|
|
|
{% endif %}
|
2018-12-24 00:49:49 +01:00
|
|
|
{% endif %}
|
2018-12-25 17:40:19 +01:00
|
|
|
{% if sort_by == "name" %}
|
|
|
|
<a class="btn btn-primary"
|
|
|
|
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=n, sort='date') }}">
|
|
|
|
Sort by date
|
|
|
|
</a>
|
|
|
|
{% else %}
|
|
|
|
<a class="btn btn-primary"
|
|
|
|
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=n, sort='name') }}">
|
|
|
|
Sort by name
|
|
|
|
</a>
|
|
|
|
{% endif %}
|
|
|
|
<a class="btn btn-primary" href="{{ url_for('todo_topics_page', q=query, show_discarded=not show_discarded, n=n, sort=sort_by) }}">
|
2018-12-25 16:20:58 +01:00
|
|
|
{% if not show_discarded %}
|
|
|
|
Show
|
|
|
|
{% else %}
|
|
|
|
Hide
|
|
|
|
{% endif %}
|
2018-12-24 00:49:49 +01:00
|
|
|
|
2018-12-25 16:20:58 +01:00
|
|
|
Discarded Topics
|
|
|
|
</a>
|
|
|
|
</div>
|
2018-12-24 00:49:49 +01:00
|
|
|
|
2018-06-02 19:22:57 +02:00
|
|
|
<h1>Topics to be Added</h1>
|
|
|
|
|
|
|
|
<p>
|
2018-12-24 01:27:55 +01:00
|
|
|
{{ total - topic_count }} / {{ total }} topics have been added as packages to CDB.
|
2018-12-24 00:49:49 +01:00
|
|
|
{{ topic_count }} remaining.
|
2018-06-02 19:22:57 +02:00
|
|
|
</p>
|
2018-12-24 01:27:55 +01:00
|
|
|
<div class="progress">
|
|
|
|
{% set perc = 100 * (total - topic_count) / total %}
|
|
|
|
<div class="progress-bar bg-success" role="progressbar"
|
|
|
|
style="width: {{ perc }}%" aria-valuenow="{{ perc }}" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
|
</div>
|
2018-06-02 19:22:57 +02:00
|
|
|
|
2018-12-23 19:03:23 +01:00
|
|
|
<form method="GET" action="{{ url_for('todo_topics_page') }}" class="my-4">
|
|
|
|
<input class="" name="q" type="text" placeholder="Search topics" value="{{ query or ''}}">
|
|
|
|
<input class="btn btn-secondary my-2 my-sm-0 mr-sm-2" type="submit" value="Search" />
|
|
|
|
</form>
|
|
|
|
|
2018-08-25 19:20:45 +02:00
|
|
|
{% from "macros/topics.html" import render_topics_table %}
|
2018-12-24 00:49:49 +01:00
|
|
|
{{ render_topics_table(topics, show_discard=True) }}
|
2018-12-23 19:03:23 +01:00
|
|
|
|
|
|
|
<ul class="pagination mt-4">
|
|
|
|
<li class="page-item {% if not prev_url %}disabled{% endif %}">
|
|
|
|
<a class="page-link" {% if prev_url %}href="{{ prev_url }}"{% endif %}>«</a>
|
|
|
|
</li>
|
|
|
|
{% for n in range(1, page_max+1) %}
|
|
|
|
<li class="page-item {% if n == page %}active{% endif %}">
|
|
|
|
<a class="page-link"
|
|
|
|
href="{{ url_for('todo_topics_page', page=n) }}">
|
|
|
|
{{ n }}
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
<li class="page-item {% if not next_url %}disabled{% endif %}">
|
|
|
|
<a class="page-link" {% if next_url %}href="{{ next_url }}"{% endif %}>»</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
2018-06-02 19:22:57 +02:00
|
|
|
{% endblock %}
|
2018-12-24 00:49:49 +01:00
|
|
|
|
|
|
|
{% block scriptextra %}
|
|
|
|
<script>
|
|
|
|
var csrf_token = "{{ csrf_token() }}";
|
|
|
|
</script>
|
|
|
|
<script>
|
|
|
|
$(".topic-discard").click(function() {
|
|
|
|
var ele = $(this);
|
|
|
|
var tid = ele.attr("data-tid");
|
|
|
|
var discard = !ele.parent().parent().hasClass("discardtopic");
|
|
|
|
fetch(new Request("{{ url_for('topic_set_discard') }}?tid=" + tid +
|
|
|
|
"&discard=" + (discard ? "true" : "false"), {
|
|
|
|
method: "post",
|
|
|
|
credentials: "same-origin",
|
|
|
|
headers: {
|
|
|
|
"Accept": "application/json",
|
|
|
|
"X-CSRFToken": csrf_token,
|
|
|
|
},
|
|
|
|
})).then(function(response) {
|
|
|
|
response.text().then(function(txt) {
|
|
|
|
console.log(JSON.parse(txt));
|
|
|
|
if (JSON.parse(txt).discarded) {
|
|
|
|
ele.parent().parent().addClass("discardtopic");
|
|
|
|
ele.removeClass("btn-danger");
|
|
|
|
ele.addClass("btn-success");
|
|
|
|
ele.text("Show");
|
|
|
|
} else {
|
|
|
|
ele.parent().parent().removeClass("discardtopic");
|
|
|
|
ele.removeClass("btn-success");
|
|
|
|
ele.addClass("btn-danger");
|
|
|
|
ele.text("Discard");
|
|
|
|
}
|
|
|
|
}).catch(console.log)
|
|
|
|
}).catch(console.log)
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
{% endblock %}
|