From 4b6abebe610b1b0d82bd89b4d89c851dce34bbb6 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 27 Mar 2024 14:24:57 +0100 Subject: [PATCH] still allow editing name and start time while running closes #41 --- src/tracker.ts | 10 ++++++---- test-vault/test-markdown.md | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/tracker.ts b/src/tracker.ts index e798731..a4a029e 100644 --- a/src/tracker.ts +++ b/src/tracker.ts @@ -330,14 +330,15 @@ function addEditableTableRow(tracker: Tracker, entry: Entry, table: HTMLTableEle .setClass("clickable-icon") .setTooltip("Edit") .setIcon("lucide-pencil") - .setDisabled(entryRunning) .onClick(async () => { if (nameField.editing()) { entry.name = nameField.endEdit(); startField.endEdit(); entry.startTime = startField.getTimestamp(); - endField.endEdit(); - entry.endTime = endField.getTimestamp(); + if (!entryRunning) { + endField.endEdit(); + entry.endTime = endField.getTimestamp(); + } await saveTracker(tracker, this.app, file, getSectionInfo()); editButton.setIcon("lucide-pencil"); @@ -347,7 +348,8 @@ function addEditableTableRow(tracker: Tracker, entry: Entry, table: HTMLTableEle // only allow editing start and end times if we don't have sub entries if (!entry.subEntries) { startField.beginEdit(entry.startTime); - endField.beginEdit(entry.endTime); + if (!entryRunning) + endField.beginEdit(entry.endTime); } editButton.setIcon("lucide-check"); } diff --git a/test-vault/test-markdown.md b/test-vault/test-markdown.md index ca37478..9f7d89b 100644 --- a/test-vault/test-markdown.md +++ b/test-vault/test-markdown.md @@ -1,4 +1,4 @@ Tested for #tag, *italic*, [link](test2), etc: ```simple-time-tracker -{"entries":[{"name":"`Segment 1`","startTime":"2022-09-27T19:51:18.000Z","endTime":"2022-09-27T19:51:24.000Z"},{"name":"Segment 2","startTime":"2022-09-27T19:51:25.000Z","endTime":"2022-09-27T19:51:26.000Z"},{"name":"#tag Seqment 3 *add* #tag1 text","startTime":null,"endTime":null,"subEntries":[{"name":"Part 1 #tagp1","startTime":"2024-03-17T11:16:00.382Z","endTime":"2024-03-17T11:16:15.966Z","subEntries":null},{"name":"Part 3","startTime":"2024-03-17T11:17:08.000Z","endTime":"2024-03-17T11:17:24.000Z","subEntries":null}]},{"name":"#tag3 Segment 4","startTime":null,"endTime":null,"subEntries":[{"name":"Part 1 #tag4","startTime":"2024-03-17T12:22:04.000Z","endTime":"2024-03-17T12:22:16.000Z","subEntries":null},{"name":"#tag5 Part 2 *italic*","startTime":"2024-03-17T12:22:20.000Z","endTime":"2024-03-17T12:22:24.000Z","subEntries":null}]},{"name":"*italic* Segment 5 #tag6 [test2](test2)","startTime":"2024-03-17T12:40:37.000Z","endTime":"2024-03-17T12:40:45.000Z","subEntries":null}]} +{"entries":[{"name":"`Segment 1`","startTime":"2022-09-27T19:51:18.000Z","endTime":"2022-09-27T19:51:24.000Z"},{"name":"Segment 2","startTime":"2022-09-27T19:51:25.000Z","endTime":"2022-09-27T19:51:26.000Z"},{"name":"#tag Seqment 3 *add* #tag1 text","startTime":null,"endTime":null,"subEntries":[{"name":"Part 1 #tagp1","startTime":"2024-03-17T11:16:00.382Z","endTime":"2024-03-17T11:16:15.966Z","subEntries":null},{"name":"Part 3","startTime":"2024-03-17T11:17:08.000Z","endTime":"2024-03-17T11:17:24.000Z","subEntries":null}]},{"name":"#tag3 Segment 4","startTime":null,"endTime":null,"subEntries":[{"name":"Part 1 #tag4","startTime":"2024-03-17T12:22:04.000Z","endTime":"2024-03-17T12:22:16.000Z","subEntries":null},{"name":"#tag5 Part 2 *italic*","startTime":"2024-03-17T12:22:20.000Z","endTime":"2024-03-17T12:22:24.000Z","subEntries":null}]},{"name":"*italic* Segment 5 #tag6 [test2](test2)","startTime":"2024-03-17T12:40:37.000Z","endTime":"2024-03-17T12:40:45.000Z","subEntries":null},{"name":"Segment 6","startTime":"2024-03-27T13:20:56.000Z","endTime":null,"subEntries":null}]} ```