Add due_time field to Todo tasks
Deploy HouseHub / deploy (push) Successful in 1s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
perco
2026-05-12 14:52:04 +02:00
co-authored by Claude Sonnet 4.6
parent 7790375c01
commit 6ef3b26153
4 changed files with 20 additions and 8 deletions
+1
View File
@@ -334,6 +334,7 @@ CREATE TABLE IF NOT EXISTS pf_todos (
title VARCHAR(500) NOT NULL,
notes TEXT DEFAULT NULL,
due_date DATE DEFAULT NULL,
due_time TIME DEFAULT NULL,
priority ENUM('none','low','medium','high') DEFAULT 'none',
done TINYINT(1) DEFAULT 0,
done_at DATETIME DEFAULT NULL,
+4 -3
View File
@@ -109,12 +109,13 @@ if ($action === 'todos') {
if ($method === 'POST') {
$d = tBody();
$title = trim($d['title'] ?? ''); if (!$title) tErr('Titre requis');
$pdo->prepare("INSERT INTO pf_todos (list_id, title, notes, due_date, priority) VALUES (?,?,?,?,?)")
$pdo->prepare("INSERT INTO pf_todos (list_id, title, notes, due_date, due_time, priority) VALUES (?,?,?,?,?,?)")
->execute([
$d['list_id'] ?: null,
$title,
$d['notes'] ?? null,
$d['due_date'] ?: null,
$d['due_time'] ?: null,
$d['priority'] ?? 'none'
]);
$id = (int)$pdo->lastInsertId();
@@ -144,8 +145,8 @@ if ($action === 'todos') {
// Full update
$title = trim($d['title'] ?? ''); if (!$title) tErr('Titre requis');
$pdo->prepare("UPDATE pf_todos SET list_id=?, title=?, notes=?, due_date=?, priority=?, updated_at=NOW() WHERE id=?")
->execute([$d['list_id'] ?: null, $title, $d['notes'] ?? null, $d['due_date'] ?: null, $d['priority'] ?? 'none', $id]);
$pdo->prepare("UPDATE pf_todos SET list_id=?, title=?, notes=?, due_date=?, due_time=?, priority=?, updated_at=NOW() WHERE id=?")
->execute([$d['list_id'] ?: null, $title, $d['notes'] ?? null, $d['due_date'] ?: null, $d['due_time'] ?: null, $d['priority'] ?? 'none', $id]);
tOk(['updated' => true]);
}
+6 -1
View File
@@ -4,6 +4,7 @@ const API = '/modules/todo/api.php';
// ─── Helpers ─────────────────────────────────────────────────────────────────
function escHtml(s){const d=document.createElement('div');d.textContent=String(s??'');return d.innerHTML;}
function fmtDate(d){if(!d)return null;const dt=new Date(d+'T00:00:00');return dt.toLocaleDateString('fr-FR',{day:'2-digit',month:'2-digit'});}
function fmtTime(t){if(!t)return null;return t.slice(0,5);}
function isToday(d){if(!d)return false;return d===new Date().toISOString().slice(0,10);}
function isOverdue(d){if(!d)return false;return d<new Date().toISOString().slice(0,10);}
function toast(msg,type='success'){
@@ -157,7 +158,8 @@ function todoItemHtml(t){
const checkClass='todo-check'+(isDone?' checked':'');
const itemClass='todo-item'+(isDone?' done':'');
const dueCls=isOverdue(t.due_date)&&!isDone?' overdue':isToday(t.due_date)&&!isDone?' today':'';
const dueLabel=t.due_date?(isToday(t.due_date)?'Aujourd\'hui':isOverdue(t.due_date)?'En retard '+fmtDate(t.due_date):fmtDate(t.due_date)):null;
const timeLabel=t.due_time?fmtTime(t.due_time):null;
const dueLabel=t.due_date?(isToday(t.due_date)?'Aujourd\'hui'+(timeLabel?' à '+timeLabel:''):isOverdue(t.due_date)?'En retard '+fmtDate(t.due_date)+(timeLabel?' '+timeLabel:''):fmtDate(t.due_date)+(timeLabel?' à '+timeLabel:'')):null;
const priBadge=t.priority&&t.priority!=='none'?
`<span class="todo-priority-badge pri-${t.priority}">${t.priority==='high'?'Urgent':t.priority==='medium'?'Normal':'Bas'}</span>`:'';
const listBadge=t.list_name?
@@ -219,6 +221,7 @@ function openAddTodo(){
document.getElementById('todo-form-title').value='';
document.getElementById('todo-form-notes').value='';
document.getElementById('todo-form-due').value='';
document.getElementById('todo-form-time').value='';
document.getElementById('todo-delete-btn').style.display='none';
const sel=document.getElementById('todo-form-list');
sel.innerHTML='<option value="">— Aucune —</option>'+lists.map(l=>`<option value="${l.id}">${escHtml(l.icon)} ${escHtml(l.name)}</option>`).join('');
@@ -238,6 +241,7 @@ async function openEditTodo(id){
document.getElementById('todo-form-title').value=t.title;
document.getElementById('todo-form-notes').value=t.notes||'';
document.getElementById('todo-form-due').value=t.due_date||'';
document.getElementById('todo-form-time').value=t.due_time?t.due_time.slice(0,5):'';
document.getElementById('todo-delete-btn').style.display='';
const sel=document.getElementById('todo-form-list');
sel.innerHTML='<option value="">— Aucune —</option>'+lists.map(l=>`<option value="${l.id}">${escHtml(l.icon)} ${escHtml(l.name)}</option>`).join('');
@@ -262,6 +266,7 @@ async function saveTodo(){
title,
notes:document.getElementById('todo-form-notes').value||null,
due_date:document.getElementById('todo-form-due').value||null,
due_time:document.getElementById('todo-form-time').value||null,
list_id:document.getElementById('todo-form-list').value||null,
priority:selectedPriority
};
+6 -1
View File
@@ -77,13 +77,18 @@ require __DIR__ . '/header.php';
<label class="form-label">Date limite</label>
<input type="date" id="todo-form-due" class="form-control">
</div>
<div class="form-group">
<label class="form-label">Heure</label>
<input type="time" id="todo-form-time" class="form-control">
</div>
</div>
<div class="form-group">
<label class="form-label">Liste</label>
<select id="todo-form-list" class="form-control">
<option value="">— Aucune —</option>
</select>
</div>
</div>
<div class="form-group">
<label class="form-label">Priorité</label>