diff --git a/src/routes/(app)/devices/[id]/+page.server.ts b/src/routes/(app)/devices/[id]/+page.server.ts index a9b1616..e627de1 100644 --- a/src/routes/(app)/devices/[id]/+page.server.ts +++ b/src/routes/(app)/devices/[id]/+page.server.ts @@ -325,11 +325,11 @@ export const actions: Actions = { saveChecklistValue: async ({ request }) => { const formData = await request.formData(); const itemId = formData.get('itemId') as string; - const value = formData.get('value') as string; + const value = (formData.get('value') as string)?.trim(); await db .update(checklistItems) - .set({ value: value || null }) + .set({ value: value || null, checked: !!value }) .where(eq(checklistItems.id, itemId)); return { valueSaved: true }; diff --git a/src/routes/(app)/devices/[id]/+page.svelte b/src/routes/(app)/devices/[id]/+page.svelte index 2b0c64f..c407d93 100644 --- a/src/routes/(app)/devices/[id]/+page.svelte +++ b/src/routes/(app)/devices/[id]/+page.svelte @@ -385,7 +385,7 @@

{checklist.title}

- {checklist.items.filter((i: any) => i.checked).length}/{checklist.items.length} + {checklist.items.filter((i: any) => i.itemType === 'input' ? !!i.value : i.checked).length}/{checklist.items.length}
@@ -400,7 +400,8 @@ {#if checklist.items.length > 0} - {@const pct = Math.round((checklist.items.filter((i: any) => i.checked).length / checklist.items.length) * 100)} + {@const completed = checklist.items.filter((i: any) => i.itemType === 'input' ? !!i.value : i.checked).length} + {@const pct = Math.round((completed / checklist.items.length) * 100)}
@@ -409,12 +410,24 @@
{#each checklist.items as item} - {#if item.itemType === 'input'} - -
- {item.text} - +
+ {#if item.itemType === 'input'} + + {@const filled = !!item.value} + + {#if filled} + + + + {/if} + + + {item.text} @@ -423,18 +436,8 @@ {/if} -
- - -
-
- {:else} - -
+ {:else} +
@@ -450,19 +453,19 @@ {/if}
- + {item.text} -
- - -
-
- {/if} + {/if} +
+ + +
+
{/each}