tangled
alpha
login
or
join now
shindakun.net
/
attodo.app
3
fork
atom
The attodo.app, uhh... app.
3
fork
atom
overview
issues
pulls
pipelines
list detail
Steve Layton
4 months ago
42d32765
953ebc02
+26
-2
1 changed file
expand all
collapse all
unified
split
templates
list-detail.html
+26
-2
templates/list-detail.html
···
264
<div id="toast-container" class="toast-container"></div>
265
266
<script>
267
-
// HTMX event listeners for list operations
268
document.body.addEventListener('htmx:afterRequest', function(evt) {
269
const url = evt.detail.pathInfo && evt.detail.pathInfo.requestPath;
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
270
271
// Check if this is a list operation
272
if (url && url.includes('/app/lists') && evt.detail.xhr) {
···
334
{{range .Tasks}}
335
{{if not .Completed}}
336
{{$hasIncomplete = true}}
337
-
<div class="task-item">
338
<h4>{{.Title}}</h4>
339
{{if .Description}}<p>{{.Description}}</p>{{end}}
340
<small>Created: {{formatDate .CreatedAt}}</small>
341
342
<div class="task-actions">
0
0
0
0
0
0
0
343
<button
344
hx-patch="/app/lists"
345
hx-vals='{"rkey": "{{$.RKey}}", "taskUri": "{{.URI}}", "action": "remove"}'
···
264
<div id="toast-container" class="toast-container"></div>
265
266
<script>
267
+
// HTMX event listeners for list and task operations
268
document.body.addEventListener('htmx:afterRequest', function(evt) {
269
const url = evt.detail.pathInfo && evt.detail.pathInfo.requestPath;
270
+
271
+
// Check if this is a task completion operation
272
+
if (url && url.includes('/app/tasks') && evt.detail.xhr && evt.detail.verb === 'put') {
273
+
if (evt.detail.successful) {
274
+
showToast('Task marked as complete!', 'success');
275
+
276
+
// Update the task count after a short delay to ensure DOM is updated
277
+
setTimeout(updateTaskCount, 50);
278
+
279
+
// Reload the page after a short delay to show the task in the completed tab
280
+
setTimeout(() => {
281
+
window.location.reload();
282
+
}, 1000);
283
+
} else {
284
+
showToast('Failed to mark task as complete. Please try again.', 'error');
285
+
}
286
+
}
287
288
// Check if this is a list operation
289
if (url && url.includes('/app/lists') && evt.detail.xhr) {
···
351
{{range .Tasks}}
352
{{if not .Completed}}
353
{{$hasIncomplete = true}}
354
+
<div class="task-item" id="task-{{.RKey}}">
355
<h4>{{.Title}}</h4>
356
{{if .Description}}<p>{{.Description}}</p>{{end}}
357
<small>Created: {{formatDate .CreatedAt}}</small>
358
359
<div class="task-actions">
360
+
<button
361
+
hx-put="/app/tasks"
362
+
hx-vals='{"rkey": "{{.RKey}}"}'
363
+
hx-target="#task-{{.RKey}}"
364
+
hx-swap="outerHTML">
365
+
Mark Complete
366
+
</button>
367
<button
368
hx-patch="/app/lists"
369
hx-vals='{"rkey": "{{$.RKey}}", "taskUri": "{{.URI}}", "action": "remove"}'