Mise à jour du contrôleur des niveaux pour retourner tous les niveaux dans la vue des tâches et ajout d'un filtre par priorité dans la vue index.
This commit is contained in:
@@ -11,11 +11,7 @@ class LevelController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index() {}
|
||||||
{
|
|
||||||
$level = Level::all();
|
|
||||||
return view('index', compact('level'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for creating a new resource.
|
* Show the form for creating a new resource.
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
|||||||
use App\Http\Requests\StoreTaskRequest;
|
use App\Http\Requests\StoreTaskRequest;
|
||||||
use App\Http\Requests\UpdateTaskRequest;
|
use App\Http\Requests\UpdateTaskRequest;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
|
use App\Models\Level;
|
||||||
|
|
||||||
class TaskController extends Controller
|
class TaskController extends Controller
|
||||||
{
|
{
|
||||||
@@ -14,7 +15,8 @@ class TaskController extends Controller
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$tasks = Task::with('level')->get();
|
$tasks = Task::with('level')->get();
|
||||||
return view('index', compact('tasks'));
|
$levels = Level::pluck('name');
|
||||||
|
return view('index', compact('tasks', 'levels'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,14 +3,17 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Tasks !</title>
|
<title>Tasks !</title>
|
||||||
<style>
|
<link rel="stylesheet" href="{{ asset('styles.css') }}">
|
||||||
.termine { color: green; font-weight: bold; }
|
|
||||||
.encours { color: red; font-weight: bold; }
|
|
||||||
</style>
|
|
||||||
{{-- <link rel="stylesheet" href="https://cdn.datatables.net/2.3.2/css/dataTables.dataTables.min.css"> --}}
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="contenu">
|
<div id="contenu">
|
||||||
|
<label for="priority-filter">Filtrer par priorité :</label>
|
||||||
|
<select id="priority-filter">
|
||||||
|
<option value="">Toutes</option>
|
||||||
|
@foreach($levels as $level)
|
||||||
|
<option value="{{ $level }}">{{ $level }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
<table id="tasks">
|
<table id="tasks">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -38,10 +41,19 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
{{-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
||||||
<script src="https://cdn.datatables.net/2.3.2/js/dataTables.min.js"></script>
|
|
||||||
<script>
|
<script>
|
||||||
new DataTable("#tasks")
|
document.getElementById('priority-filter').addEventListener('change', function() {
|
||||||
</script> --}}
|
let filter = this.value;
|
||||||
|
let rows = document.querySelectorAll('#tasks tbody tr');
|
||||||
|
rows.forEach(row => {
|
||||||
|
let priority = row.children[0].textContent;
|
||||||
|
if (!filter || priority === filter) {
|
||||||
|
row.style.display = '';
|
||||||
|
} else {
|
||||||
|
row.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user