From 03f3516196c4f4a7a98251d683e7220acf659cc6 Mon Sep 17 00:00:00 2001
From: terryli710
Date: Tue, 12 Mar 2024 09:57:58 -0700
Subject: [PATCH] fixed duration display bug
---
src/ui/Duration.svelte | 9 +++++----
src/ui/StaticTaskCard.svelte | 26 ++++++++++++--------------
2 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/src/ui/Duration.svelte b/src/ui/Duration.svelte
index b9c5574..d1030a6 100644
--- a/src/ui/Duration.svelte
+++ b/src/ui/Duration.svelte
@@ -15,8 +15,10 @@
export let params: TaskDisplayParams;
export let displayDuration: boolean;
+ const interactiveMode = interactive;
+
let duration: Duration;
- if (interactive) {
+ if (interactiveMode) {
duration = taskSyncManager.obsidianTask.hasDuration() ? taskSyncManager.obsidianTask.duration : undefined;
} else {
duration = taskItem.duration;
@@ -105,7 +107,6 @@
new Notice(`[TaskCard] Invalid duration format: ${durationInputString}`);
}
}
-
taskSyncManager.updateObsidianTaskAttribute('duration', duration);
origDurationInputString = durationInputString;
@@ -138,7 +139,7 @@ function parseDurationInput(input: string): { hours: number, minutes: number } |
}
$: {
- if (interactive) {
+ if (interactiveMode) {
displayDuration = taskSyncManager.obsidianTask.hasDuration() || taskSyncManager.getTaskCardStatus('durationStatus') === 'editing';
} else {
displayDuration = !!taskItem.duration; // The double bang '!!' converts a truthy/falsy value to a boolean true/false
@@ -162,7 +163,7 @@ function parseDurationInput(input: string): { hours: number, minutes: number } |
- {#if taskSyncManager.getTaskCardStatus('durationStatus') === 'editing'}
+ {#if interactiveMode && taskSyncManager.getTaskCardStatus('durationStatus') === 'editing'}
elements, ensuring 'task-list-item'
* class is present on relevant
elements, and adjusting elements inside these list items to have the
* appropriate attributes.
- *
+ *
* @param {string} taskDescriptionHTML - The HTML string generated by the markdown parser for a task description.
* @returns {string} The transformed HTML string with the updated structure.
*/
@@ -144,8 +144,7 @@
wrapperDiv.appendChild(ulElement);
let lis = doc.body.querySelectorAll('li');
- console.log('doc', doc);
- // console.log("lis", lis);
+
lis.forEach((li, index) => {
let newLi = document.createElement('li');
let lineIndex = index + 1;
@@ -154,7 +153,8 @@
newLi.setAttribute('data-line', lineIndex.toString());
newLi.setAttribute('data-real-line', lineIndex.toString());
- if (input instanceof HTMLInputElement) { // Ensure input is an HTMLInputElement
+ if (input instanceof HTMLInputElement) {
+ // Ensure input is an HTMLInputElement
let clonedInput = input.cloneNode(true) as HTMLInputElement; // Cast the cloned node
clonedInput.setAttribute('class', 'task-list-item-checkbox');
clonedInput.setAttribute('data-line', lineIndex.toString());
@@ -183,7 +183,6 @@
}
ulElement.appendChild(newLi);
-
});
// Use XMLSerializer to convert the document back to a string
@@ -192,7 +191,6 @@
return transformedHTML;
}
-
{#if taskDisplayParams.mode === 'single-line'}
@@ -321,7 +319,7 @@
@@ -329,13 +327,13 @@
interactive={false}
params={{ mode: 'multi-line' }}
taskItem={task}
- {displayDuration}
+ displayDuration={displayDuration}
/>