From 012a1dc35c69cb51ff15b21f8303787b5299a626 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Sat, 12 Sep 2026 10:58:39 +0200 Subject: improve projects layout on mobile --- src/routes/projects/[id]/+page.server.ts | 16 +-- src/routes/projects/[id]/+page.svelte | 135 ++++----------------- .../routine/[routineId]/+page.server.ts | 5 + .../[projectId]/routine/[routineId]/+page.svelte | 55 ++++++++- 4 files changed, 79 insertions(+), 132 deletions(-) (limited to 'src/routes') diff --git a/src/routes/projects/[id]/+page.server.ts b/src/routes/projects/[id]/+page.server.ts index 19aea9b..3321bcd 100644 --- a/src/routes/projects/[id]/+page.server.ts +++ b/src/routes/projects/[id]/+page.server.ts @@ -8,11 +8,7 @@ import { loadProjectDashboard, loadArchived, } from '$lib/server/services/routines'; -import { - archiveRoutineAction, - completeRoutineAction, - editRoutineAction, -} from '$lib/server/services/routine-actions'; +import { completeRoutineAction } from '$lib/server/services/routine-actions'; import { numericId, parseFormString, @@ -56,21 +52,11 @@ export const actions: Actions = { return { success: true }; }, - editRoutine: async ({ request }) => { - const data = await request.formData(); - return editRoutineAction(data, numericId(data.get('id'))); - }, - complete: async ({ request }) => { const data = await request.formData(); return completeRoutineAction(data, numericId(data.get('id'))); }, - archiveRoutine: async ({ request }) => { - const data = await request.formData(); - return archiveRoutineAction(numericId(data.get('id'))); - }, - archiveProject: async ({ params }) => { await archiveProject(numericId(params.id)); throw redirect(303, '/'); diff --git a/src/routes/projects/[id]/+page.svelte b/src/routes/projects/[id]/+page.svelte index 9931f40..8a3561b 100644 --- a/src/routes/projects/[id]/+page.svelte +++ b/src/routes/projects/[id]/+page.svelte @@ -15,12 +15,8 @@ let name = $state(''); let frequency = $state(''); - let editingId = $state(null); - let editName = $state(''); - let editFrequency = $state(''); const frequencyDays = $derived(parseIntervalToDays(frequency)); - const editFrequencyDays = $derived(parseIntervalToDays(editFrequency)); let showArchived = $state(false); let archiveFilter = $state(''); @@ -36,12 +32,6 @@ (a, b) => b.overdueRatio - a.overdueRatio || a.name.localeCompare(b.name), ); } - - function startEdit(routine: RoutineState) { - editingId = routine.id; - editName = routine.name; - editFrequency = `${routine.frequencyDays}d`; - }
@@ -113,94 +103,30 @@
    {#each sorted(data.routines) as routine (routine.id)}
  • - {#if editingId === routine.id} -
    { - return async ({ result, update }) => { - if (result.type === 'failure') { - // Keep the edit form open so the error is visible. - await update({ reset: false }); - return; - } - editingId = null; - await update({ reset: false }); - }; - }} - > - {#if form?.error} -

    {form.error}

    - {/if} - - - + + - -
    - {:else} - -
    - {routine.name} - - {formatFrequency(routine.frequencyDays)} - {#if routine.lastDoneAt} - · fait le {formatDayMonth(routine.lastDoneAt)} - {:else} - · jamais fait - {/if} - -
    -
    - - -
    - + +
    + {routine.name} -
    - - -
    - {/if} + + {formatFrequency(routine.frequencyDays)} + {#if routine.lastDoneAt} + · fait le {formatDayMonth(routine.lastDoneAt)} + {:else} + · jamais fait + {/if} + +
  • {/each}
@@ -303,23 +229,6 @@ color: var(--text-secondary); } - .edit-form { - display: flex; - flex-grow: 1; - gap: 0.5rem; - align-items: center; - flex-wrap: wrap; - } - - .edit-error { - width: 100%; - } - - .edit-form .form-input { - flex: 1; - padding: 0.5rem 0.75rem; - } - .frequency-input { width: 4.5rem; flex-shrink: 0; diff --git a/src/routes/projects/[projectId]/routine/[routineId]/+page.server.ts b/src/routes/projects/[projectId]/routine/[routineId]/+page.server.ts index bdfa452..891a7b6 100644 --- a/src/routes/projects/[projectId]/routine/[routineId]/+page.server.ts +++ b/src/routes/projects/[projectId]/routine/[routineId]/+page.server.ts @@ -2,6 +2,7 @@ import { error } from '@sveltejs/kit'; import { getById } from '$lib/server/services/projects'; import { loadCurrent, loadCompletions } from '$lib/server/services/routines'; import { + archiveRoutineAction, completeRoutineAction, editRoutineAction, } from '$lib/server/services/routine-actions'; @@ -49,4 +50,8 @@ export const actions: Actions = { const data = await request.formData(); return completeRoutineAction(data, numericId(params.routineId)); }, + + archive: async ({ params }) => { + return archiveRoutineAction(numericId(params.routineId)); + }, }; diff --git a/src/routes/projects/[projectId]/routine/[routineId]/+page.svelte b/src/routes/projects/[projectId]/routine/[routineId]/+page.svelte index e593ad1..74880cb 100644 --- a/src/routes/projects/[projectId]/routine/[routineId]/+page.svelte +++ b/src/routes/projects/[projectId]/routine/[routineId]/+page.svelte @@ -103,7 +103,7 @@ class="form-input desc" name="description" bind:value={description} - rows={3} + rows={6} placeholder="Pourquoi, comment, quand..." autocomplete="off" > @@ -112,13 +112,15 @@

Intervalle invalide — ex : 1d, 2w, 3m, 1y

{/if} -

✓ Enregistré

{/if} @@ -188,6 +190,14 @@ {#if data.completions.length === 0}

Aucune réalisation pour l'instant.

{/if} + + {#if !data.routine.archived} +
+
+ +
+
+ {/if}
-- cgit v1.3