Skip to content
Snippets Groups Projects
Commit e6635c63 authored by Benjamin Bertrand's avatar Benjamin Bertrand
Browse files

Add checkbox to display all tasks (admin only)

parent 1332808d
No related branches found
No related tags found
No related merge requests found
$(document).ready(function() {
$("#allTasks").on('change', function() {
// reload the data from the Ajax source
tasks_table.ajax.reload();
});
var tasks_table = $("#tasks_table").DataTable({
"ajax": function(data, callback, settings) {
var allTasks = $('#allTasks').prop("checked");
$.getJSON(
$SCRIPT_ROOT + "/task/_retrieve_tasks",
$SCRIPT_ROOT + "/task/_retrieve_tasks?all=" + allTasks,
function(json) {
callback(json);
});
......
......@@ -9,7 +9,8 @@ This module implements the task blueprint.
:license: BSD 2-Clause, see LICENSE for more details.
"""
from flask import Blueprint, render_template, jsonify
from flask import (Blueprint, render_template, jsonify,
request)
from flask_login import login_required, current_user
from .. import models
......@@ -32,5 +33,6 @@ def view_task(id_):
@bp.route('/_retrieve_tasks')
@login_required
def retrieve_tasks():
data = [task.to_dict() for task in current_user.get_tasks()]
all = request.args.get('all', 'false') == 'true'
data = [task.to_dict() for task in current_user.get_tasks(all=all)]
return jsonify(data=data)
......@@ -15,6 +15,17 @@
<br>
{% block tasks_main %}
{% if current_user.is_authenticated and current_user.is_admin %}
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="allTasks">
<label class="form-check-label" for="allTasks">
Show all tasks (all users)
</label>
</div>
<hr class="separator">
{%- endif %}
<table id="tasks_table" class="table table-bordered table-hover table-sm" cellspacing="0" width="100%">
<thead>
<tr>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment