diff --git a/frontend/package.json b/frontend/package.json index 0d75051..0fb782f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -31,6 +31,7 @@ "clsx": "^2.1.1", "lucide-svelte": "^0.575.0", "mode-watcher": "^1.1.0", + "svelte-dnd-action": "^0.9.69", "tailwind-merge": "^3.5.0" } } diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index f5aa872..abe2517 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -23,6 +23,9 @@ importers: mode-watcher: specifier: ^1.1.0 version: 1.1.0(svelte@5.53.5) + svelte-dnd-action: + specifier: ^0.9.69 + version: 0.9.69(svelte@5.53.5) tailwind-merge: specifier: ^3.5.0 version: 3.5.0 @@ -968,6 +971,11 @@ packages: svelte: ^4.0.0 || ^5.0.0-next.0 typescript: '>=5.0.0' + svelte-dnd-action@0.9.69: + resolution: {integrity: sha512-NAmSOH7htJoYraTQvr+q5whlIuVoq88vEuHr4NcFgscDRUxfWPPxgie2OoxepBCQCikrXZV4pqV86aun60wVyw==} + peerDependencies: + svelte: '>=3.23.0 || ^5.0.0-next.0' + svelte-toolbelt@0.10.6: resolution: {integrity: sha512-YWuX+RE+CnWYx09yseAe4ZVMM7e7GRFZM6OYWpBKOb++s+SQ8RBIMMe+Bs/CznBMc0QPLjr+vDBxTAkozXsFXQ==} engines: {node: '>=18', pnpm: '>=8.7.0'} @@ -1828,6 +1836,10 @@ snapshots: transitivePeerDependencies: - picomatch + svelte-dnd-action@0.9.69(svelte@5.53.5): + dependencies: + svelte: 5.53.5 + svelte-toolbelt@0.10.6(@sveltejs/kit@2.53.2(@sveltejs/vite-plugin-svelte@6.2.4(svelte@5.53.5)(vite@7.3.1(@types/node@25.3.3)(jiti@2.6.1)(lightningcss@1.31.1)))(svelte@5.53.5)(typescript@5.9.3)(vite@7.3.1(@types/node@25.3.3)(jiti@2.6.1)(lightningcss@1.31.1)))(svelte@5.53.5): dependencies: clsx: 2.1.1 diff --git a/frontend/src/routes/routines/[id]/+page.svelte b/frontend/src/routes/routines/[id]/+page.svelte index 767349f..e8cc4e4 100644 --- a/frontend/src/routes/routines/[id]/+page.svelte +++ b/frontend/src/routes/routines/[id]/+page.svelte @@ -1,5 +1,8 @@ Routine {routine.routine_date} {routine.part_of_day.toUpperCase()} — innercontext @@ -43,7 +127,7 @@
-

{m.routines_steps({ count: routine.steps.length })}

+

{m.routines_steps({ count: steps.length })}

@@ -89,33 +173,143 @@ {/if} - {#if routine.steps.length} -
- {#each routine.steps.toSorted((a, b) => a.order_index - b.order_index) as step (step.id)} -
-
- {step.order_index} -
- {#if step.product_id} - {@const product = products.find((p) => p.id === step.product_id)} -

{product?.name ?? step.product_id}

- {#if product?.brand}

{product.brand}

{/if} - {:else if step.action_type} -

{step.action_type.replace(/_/g, ' ')}

+ {#if steps.length} +
+ {#each steps as step (step.id)} +
+ {#if editingStepId === step.id} + +
+ {#if step.product_id !== undefined} + +
+ + +
+
+
+ + (editDraft.dose = e.currentTarget.value)} + placeholder={m["routines_dosePlaceholder"]()} + /> +
+
+ + (editDraft.region = e.currentTarget.value)} + placeholder={m["routines_regionPlaceholder"]()} + /> +
+
{:else} -

{m["routines_unknownStep"]()}

+ +
+ + +
+
+ + (editDraft.action_notes = e.currentTarget.value)} + placeholder="optional notes" + /> +
{/if} + + {#if editError} +

{editError}

+ {/if} + +
+ + +
- {#if step.dose} - {step.dose} - {/if} -
-
- - -
+ {:else} + +
+ ⋮⋮ + {step.order_index + 1}. +
+ {#if step.product_id} + {@const product = products.find((p) => p.id === step.product_id)} +

{product?.name ?? step.product_id}

+ {#if product?.brand}

{product.brand}

{/if} + {:else if step.action_type} +

{step.action_type.replace(/_/g, ' ')}

+ {:else} +

{m["routines_unknownStep"]()}

+ {/if} +
+ {#if step.dose} + {step.dose} + {/if} + +
+ + +
+
+ {/if}
{/each}
@@ -126,8 +320,14 @@ -
{ if (!confirm(m["routines_confirmDelete"]())) e.preventDefault(); }}> + { + if (!confirm(m["routines_confirmDelete"]())) e.preventDefault(); + }} + >