Spaces:
Running
Running
The user is unable to set a reminder and or delete the task. Please fix.
Browse files- components/task-card.js +7 -7
- script.js +31 -27
components/task-card.js
CHANGED
|
@@ -142,8 +142,7 @@ this.shadowRoot.innerHTML = `
|
|
| 142 |
<div class="task-card ${completed ? 'completed' : ''}">
|
| 143 |
<div class="flex items-start gap-3">
|
| 144 |
<div class="task-checkbox ${completed ? 'checked' : ''}" data-action="toggle"></div>
|
| 145 |
-
|
| 146 |
-
<div class="flex-1">
|
| 147 |
<h3 class="task-text font-semibold text-gray-800 mb-2">${text}</h3>
|
| 148 |
|
| 149 |
<div class="flex flex-wrap items-center gap-2 mb-3">
|
|
@@ -162,21 +161,22 @@ this.shadowRoot.innerHTML = `
|
|
| 162 |
`<span class="badge badge-reminder">Active (${reminderFrequency || 'daily'})</span>` : ''}
|
| 163 |
${reminderStopped ?
|
| 164 |
'<span class="badge badge-stopped">Reminder Stopped</span>' : ''}
|
| 165 |
-
|
| 166 |
-
<div class="flex items-center gap-1">
|
| 167 |
${!completed ? `
|
| 168 |
<button class="action-btn reminder-btn ${hasReminder && !reminderStopped ? 'active' : ''}"
|
| 169 |
data-action="reminder"
|
| 170 |
-
title="${hasReminder && !reminderStopped ? 'Stop Reminder' : 'Set Reminder'}"
|
|
|
|
| 171 |
<i data-feather="bell" class="w-4 h-4"></i>
|
| 172 |
${hasReminder && !reminderStopped ? '<div class="reminder-pulse"></div>' : ''}
|
| 173 |
</button>
|
| 174 |
` : ''}
|
| 175 |
-
<button class="action-btn delete" data-action="delete" title="Delete Task">
|
| 176 |
<i data-feather="trash-2" class="w-4 h-4"></i>
|
| 177 |
</button>
|
| 178 |
</div>
|
| 179 |
-
|
| 180 |
</div>
|
| 181 |
</div>
|
| 182 |
</div>
|
|
|
|
| 142 |
<div class="task-card ${completed ? 'completed' : ''}">
|
| 143 |
<div class="flex items-start gap-3">
|
| 144 |
<div class="task-checkbox ${completed ? 'checked' : ''}" data-action="toggle"></div>
|
| 145 |
+
<div class="flex-1">
|
|
|
|
| 146 |
<h3 class="task-text font-semibold text-gray-800 mb-2">${text}</h3>
|
| 147 |
|
| 148 |
<div class="flex flex-wrap items-center gap-2 mb-3">
|
|
|
|
| 161 |
`<span class="badge badge-reminder">Active (${reminderFrequency || 'daily'})</span>` : ''}
|
| 162 |
${reminderStopped ?
|
| 163 |
'<span class="badge badge-stopped">Reminder Stopped</span>' : ''}
|
| 164 |
+
</div>
|
| 165 |
+
<div class="flex items-center gap-1">
|
| 166 |
${!completed ? `
|
| 167 |
<button class="action-btn reminder-btn ${hasReminder && !reminderStopped ? 'active' : ''}"
|
| 168 |
data-action="reminder"
|
| 169 |
+
title="${hasReminder && !reminderStopped ? 'Stop Reminder' : 'Set Reminder'}"
|
| 170 |
+
type="button">
|
| 171 |
<i data-feather="bell" class="w-4 h-4"></i>
|
| 172 |
${hasReminder && !reminderStopped ? '<div class="reminder-pulse"></div>' : ''}
|
| 173 |
</button>
|
| 174 |
` : ''}
|
| 175 |
+
<button class="action-btn delete" data-action="delete" title="Delete Task" type="button">
|
| 176 |
<i data-feather="trash-2" class="w-4 h-4"></i>
|
| 177 |
</button>
|
| 178 |
</div>
|
| 179 |
+
</div>
|
| 180 |
</div>
|
| 181 |
</div>
|
| 182 |
</div>
|
script.js
CHANGED
|
@@ -148,26 +148,24 @@ addTask() {
|
|
| 148 |
if (task) {
|
| 149 |
if (task.completed) {
|
| 150 |
this.showToast('Cannot set reminder for completed task', 'error');
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
}
|
| 167 |
}
|
| 168 |
}
|
| 169 |
-
|
| 170 |
-
setReminderFrequency(frequency) {
|
| 171 |
if (!this.currentReminderTaskId) return;
|
| 172 |
|
| 173 |
const task = this.tasks.find(t => t.id === this.currentReminderTaskId);
|
|
@@ -354,20 +352,26 @@ showToast(message, type = 'info') {
|
|
| 354 |
return saved ? JSON.parse(saved) : [];
|
| 355 |
}
|
| 356 |
}
|
| 357 |
-
|
| 358 |
// Custom event delegation for dynamic task cards
|
| 359 |
document.addEventListener('click', (e) => {
|
| 360 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 361 |
const card = e.target.closest('task-card');
|
| 362 |
-
|
| 363 |
-
|
|
|
|
| 364 |
const card = e.target.closest('task-card');
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
|
|
|
|
|
|
|
|
|
| 369 |
}
|
| 370 |
});
|
| 371 |
-
|
| 372 |
// Initialize the app
|
| 373 |
const taskManager = new TaskManager();
|
|
|
|
| 148 |
if (task) {
|
| 149 |
if (task.completed) {
|
| 150 |
this.showToast('Cannot set reminder for completed task', 'error');
|
| 151 |
+
return;
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
this.currentReminderTaskId = id;
|
| 155 |
+
|
| 156 |
+
if (task.hasReminder && !task.reminderStopped) {
|
| 157 |
+
// Show stop reminder option
|
| 158 |
+
document.getElementById('reminderModal').classList.remove('hidden');
|
| 159 |
+
document.getElementById('stopExistingReminder').classList.remove('hidden');
|
| 160 |
+
document.querySelectorAll('.frequency-btn').forEach(btn => btn.style.display = 'none');
|
| 161 |
+
} else {
|
| 162 |
+
// Show frequency selection
|
| 163 |
+
document.getElementById('reminderModal').classList.remove('hidden');
|
| 164 |
+
document.getElementById('stopExistingReminder').classList.add('hidden');
|
| 165 |
+
document.querySelectorAll('.frequency-btn').forEach(btn => btn.style.display = 'block');
|
|
|
|
| 166 |
}
|
| 167 |
}
|
| 168 |
+
setReminderFrequency(frequency) {
|
|
|
|
| 169 |
if (!this.currentReminderTaskId) return;
|
| 170 |
|
| 171 |
const task = this.tasks.find(t => t.id === this.currentReminderTaskId);
|
|
|
|
| 352 |
return saved ? JSON.parse(saved) : [];
|
| 353 |
}
|
| 354 |
}
|
|
|
|
| 355 |
// Custom event delegation for dynamic task cards
|
| 356 |
document.addEventListener('click', (e) => {
|
| 357 |
+
const toggleBtn = e.target.closest('[data-action="toggle"]');
|
| 358 |
+
const reminderBtn = e.target.closest('[data-action="reminder"]');
|
| 359 |
+
const deleteBtn = e.target.closest('[data-action="delete"]');
|
| 360 |
+
|
| 361 |
+
if (toggleBtn) {
|
| 362 |
const card = e.target.closest('task-card');
|
| 363 |
+
if (card) {
|
| 364 |
+
taskManager.toggleTask(parseInt(card.getAttribute('id'))));
|
| 365 |
+
} else if (reminderBtn) {
|
| 366 |
const card = e.target.closest('task-card');
|
| 367 |
+
if (card) {
|
| 368 |
+
taskManager.toggleReminder(parseInt(card.getAttribute('id'))));
|
| 369 |
+
} else if (deleteBtn) {
|
| 370 |
+
const card = e.target.closest('task-card');
|
| 371 |
+
if (card) {
|
| 372 |
+
taskManager.deleteTask(parseInt(card.getAttribute('id'))));
|
| 373 |
+
}
|
| 374 |
}
|
| 375 |
});
|
|
|
|
| 376 |
// Initialize the app
|
| 377 |
const taskManager = new TaskManager();
|