Add topic searching and topic discarding
This commit is contained in:
@@ -5,11 +5,21 @@ Topics to be Added
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<a class="btn btn-primary float-right" href="{{ url_for('todo_topics_page', q=query, show_discarded=not show_discarded) }}">
|
||||
{% if not show_discarded %}
|
||||
Show
|
||||
{% else %}
|
||||
Hide
|
||||
{% endif %}
|
||||
|
||||
Discarded Topics
|
||||
</a>
|
||||
|
||||
<h1>Topics to be Added</h1>
|
||||
|
||||
<p>
|
||||
{{ total - (topic_count) }} / {{ total }} packages have been added.
|
||||
{{ topics | count }} remaining.
|
||||
{{ total - (topic_count) }} / {{ total }} topics have been added as packages to CDB.
|
||||
{{ topic_count }} remaining.
|
||||
</p>
|
||||
|
||||
<form method="GET" action="{{ url_for('todo_topics_page') }}" class="my-4">
|
||||
@@ -18,7 +28,7 @@ Topics to be Added
|
||||
</form>
|
||||
|
||||
{% from "macros/topics.html" import render_topics_table %}
|
||||
{{ render_topics_table(topics) }}
|
||||
{{ render_topics_table(topics, show_discard=True) }}
|
||||
|
||||
<ul class="pagination mt-4">
|
||||
<li class="page-item {% if not prev_url %}disabled{% endif %}">
|
||||
@@ -37,3 +47,40 @@ Topics to be Added
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
{% 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 %}
|
||||
|
||||
Reference in New Issue
Block a user