From f612dbd7642ec1bbdade76dec8916c6c445f73c3 Mon Sep 17 00:00:00 2001 From: Romulus21 Date: Fri, 13 Nov 2026 19:15:06 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Remplace=20=C2=AB=20Arr=C3=AAter=20=C2=BB?= =?UTF-8?q?=20par=20un=20picto=20stop=20dans=20le=20timer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bouton rond avec l'icône stop ; en mobile, l'horloge et le stop passent sous la description, côte à côte, sans déborder. Co-Authored-By: Claude Opus 5.5 --- static/app.css | 4 +++- templates/_timer.html | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/static/app.css b/static/app.css index bad72d6..119464d 100644 --- a/static/app.css +++ b/static/app.css @@ -123,6 +123,8 @@ a.btn { color: var(--text); text-decoration: none; } .timer-start { margin-top: .35rem; font-size: .9rem; } .timer-start input { width: 11rem; } .clock { font-size: 2rem; font-weight: 600; font-variant-numeric: tabular-nums; } +.btn.icon.timer-stop { width: 3rem; height: 3rem; border-radius: 50%; } +.timer-stop svg { width: 20px; height: 20px; } .start { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) auto; gap: .5rem; } .note { color: var(--muted); font-size: .9rem; } @@ -188,7 +190,7 @@ input[type="color"] { @media (max-width: 640px) { .current { grid-template-columns: 1fr auto; } - .current .btn { grid-column: 1 / -1; } + .current-label { grid-column: 1 / -1; min-width: 0; } .start { grid-template-columns: 1fr; } .report .label { width: auto; } .bar-cell { width: 30%; } diff --git a/templates/_timer.html b/templates/_timer.html index 80a043d..7908e79 100644 --- a/templates/_timer.html +++ b/templates/_timer.html @@ -1,3 +1,4 @@ +{% import "_icons.html" as icons %}
{% if let Some(e) = running %}
@@ -11,7 +12,7 @@
{{ e.duration() }}
- + {% endif %} {% if groups.is_empty() %} From 2ff27b2a65e1e0278f1f98c847cf8d01aaa4f7cc Mon Sep 17 00:00:00 2001 From: Romulus21 Date: Fri, 13 Nov 2026 19:15:06 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Ajoute=20un=20bouton=20play=20sur=20les=20e?= =?UTF-8?q?ntr=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit En tête du groupe d'actions : ▶ arrête le timer en cours et en relance un sur le même projet et la même note (POST /ui/entries/{id}/relancer) ; sur l'entrée en cours, ■ l'arrête. Les deux émettent timer-changed. Co-Authored-By: Claude Opus 5.5 --- src/routes/pages.rs | 26 ++++++++++++++++------- static/app.css | 1 + templates/_entry_row.html | 5 +++++ templates/_icons.html | 1 + tests/api.rs | 43 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 7 deletions(-) diff --git a/src/routes/pages.rs b/src/routes/pages.rs index fd39c3e..8d2df6a 100644 --- a/src/routes/pages.rs +++ b/src/routes/pages.rs @@ -46,6 +46,7 @@ pub fn router() -> Router { get(entry_row).put(update_entry).delete(delete_entry), ) .route("/ui/entries/{id}/edit", get(entry_edit)) + .route("/ui/entries/{id}/relancer", post(restart_entry)) .route( "/ui/entries/{id}/dupliquer", get(entry_duplicate).post(duplicate_entry), @@ -99,6 +100,16 @@ fn with_entries_changed(resp: Response) -> Response { (AppendHeaders([("HX-Trigger", "entries-changed")]), resp).into_response() } +/// Same, plus `timer-changed` so the dashboard timer follows a start/stop +/// made elsewhere (header, entry lists). +fn with_timer_changed(resp: Response) -> Response { + ( + AppendHeaders([("HX-Trigger", "entries-changed, timer-changed")]), + resp, + ) + .into_response() +} + struct ProjectOption { id: i64, name: String, @@ -363,13 +374,7 @@ async fn stop_timer(State(pool): State) -> PageResult { Ok(_) | Err(AppError::Conflict(_)) => {} Err(e) => return Err(e.into()), } - // `timer-changed` refreshes the dashboard timer when stopped from the header. - let resp = render(timer_state(&pool).await?)?; - Ok(( - AppendHeaders([("HX-Trigger", "entries-changed, timer-changed")]), - resp, - ) - .into_response()) + Ok(with_timer_changed(render(timer_state(&pool).await?)?)) } #[derive(Deserialize)] @@ -727,6 +732,13 @@ async fn update_entry( Ok(with_entries_changed(render(EntryRowTpl { e })?)) } +/// Stops the running timer and starts a new one on this entry's project and note. +async fn restart_entry(State(pool): State, Path(id): Path) -> PageResult { + let e = entries::get(&pool, id).await?; + entries::start(&pool, e.project_id, &e.note).await?; + Ok(with_timer_changed(StatusCode::OK.into_response())) +} + async fn delete_entry(State(pool): State, Path(id): Path) -> PageResult { entries::delete(&pool, id).await?; // htmx swaps the row with this empty body, removing it. diff --git a/static/app.css b/static/app.css index 119464d..e0ec7dc 100644 --- a/static/app.css +++ b/static/app.css @@ -99,6 +99,7 @@ a.btn { color: var(--text); text-decoration: none; } .btn:hover { border-color: var(--muted); } .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; } .btn.danger { color: var(--danger); } +.btn.play { color: var(--accent); } .btn.small { padding: .2rem .55rem; font-size: .85rem; } .btn.icon { display: inline-flex; align-items: center; justify-content: center; flex: none; diff --git a/templates/_entry_row.html b/templates/_entry_row.html index 52efb75..933acee 100644 --- a/templates/_entry_row.html +++ b/templates/_entry_row.html @@ -9,6 +9,11 @@ {{ e.duration() }}
+ {% if e.running() %} + + {% else %} + + {% endif %} diff --git a/templates/_icons.html b/templates/_icons.html index e6251d3..2021988 100644 --- a/templates/_icons.html +++ b/templates/_icons.html @@ -6,6 +6,7 @@ {%- else if name == "check" -%} {%- else if name == "plus" -%} {%- else if name == "reset" -%} +{%- else if name == "play" -%} {%- else if name == "stop" -%} {%- else if name == "link" -%} {%- else if name == "archive" -%} diff --git a/tests/api.rs b/tests/api.rs index d205765..f758a63 100644 --- a/tests/api.rs +++ b/tests/api.rs @@ -802,3 +802,46 @@ async fn header_mini_timer() { let (_, html) = get_html(&app, "/ui/timer/entete").await; assert!(html.contains("Site web")); } + +#[tokio::test] +async fn restart_entry_from_list() { + let app = app().await; + let a = project(&app, "Acme", "Site web").await; + let b = project(&app, "Globex", "API").await; + add_entry(&app, a, local(2026, 3, 10, 9, 0), local(2026, 3, 10, 10, 0)).await; + send( + &app, + "PATCH", + "/api/entries/1", + Some(json!({ "note": "réunion" })), + ) + .await; + send( + &app, + "POST", + "/api/timer/start", + Some(json!({ "project_id": b })), + ) + .await; + + // ▶ on entry 1: the Globex timer stops, a new one runs on Acme / "réunion". + let (status, _) = send_form(&app, "/ui/entries/1/relancer", "").await; + assert_eq!(status, StatusCode::OK); + let (_, running) = send(&app, "GET", "/api/timer", None).await; + assert_eq!(running["project_id"], a); + assert_eq!(running["note"], "réunion"); + let (_, list) = send( + &app, + "GET", + "/api/entries?from=2020-01-01&to=2100-01-01", + None, + ) + .await; + let open = list + .as_array() + .unwrap() + .iter() + .filter(|e| e["ended_at"].is_null()) + .count(); + assert_eq!(open, 1); +}