mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 20:01:09 +02:00
i18n(goals): wire GoalEditor to namespace — 15 strings cleared
Patches form labels, event type options (now reactive via $derived), source/comparison/period selectors, action buttons. Locale JSONs landed in the previous commit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
421a49a2a8
commit
b06d950c4f
2 changed files with 68 additions and 38 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
GoalEditor — Modal for creating custom goals with metric + target.
|
GoalEditor — Modal for creating custom goals with metric + target.
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { _ } from 'svelte-i18n';
|
||||||
import { X } from '@mana/shared-icons';
|
import { X } from '@mana/shared-icons';
|
||||||
import { goalStore } from '$lib/companion/goals';
|
import { goalStore } from '$lib/companion/goals';
|
||||||
|
|
||||||
|
|
@ -24,21 +25,37 @@
|
||||||
let moduleId = $state('todo');
|
let moduleId = $state('todo');
|
||||||
let pending = $state(false);
|
let pending = $state(false);
|
||||||
|
|
||||||
const EVENT_OPTIONS = [
|
const EVENT_OPTIONS = $derived([
|
||||||
{ value: 'TaskCompleted', label: 'Tasks erledigt', module: 'todo' },
|
{ value: 'TaskCompleted', label: $_('goals.editor.event_task_completed'), module: 'todo' },
|
||||||
{ value: 'TaskCreated', label: 'Tasks erstellt', module: 'todo' },
|
{ value: 'TaskCreated', label: $_('goals.editor.event_task_created'), module: 'todo' },
|
||||||
{ value: 'DrinkLogged', label: 'Getraenk geloggt', module: 'drink' },
|
{ value: 'DrinkLogged', label: $_('goals.editor.event_drink_logged'), module: 'drink' },
|
||||||
{ value: 'MealLogged', label: 'Mahlzeit geloggt', module: 'food' },
|
{ value: 'MealLogged', label: $_('goals.editor.event_meal_logged'), module: 'food' },
|
||||||
{ value: 'HabitLogged', label: 'Habit geloggt', module: 'habits' },
|
{ value: 'HabitLogged', label: $_('goals.editor.event_habit_logged'), module: 'habits' },
|
||||||
{ value: 'JournalEntryCreated', label: 'Journal-Eintrag', module: 'journal' },
|
{
|
||||||
{ value: 'NoteCreated', label: 'Notiz erstellt', module: 'notes' },
|
value: 'JournalEntryCreated',
|
||||||
{ value: 'PlaceVisited', label: 'Ort besucht', module: 'places' },
|
label: $_('goals.editor.event_journal_entry_created'),
|
||||||
{ value: 'WorkoutFinished', label: 'Workout beendet', module: 'body' },
|
module: 'journal',
|
||||||
{ value: 'MeditationCompleted', label: 'Meditation', module: 'meditate' },
|
},
|
||||||
{ value: 'SleepLogged', label: 'Schlaf geloggt', module: 'sleep' },
|
{ value: 'NoteCreated', label: $_('goals.editor.event_note_created'), module: 'notes' },
|
||||||
{ value: 'CalendarEventCreated', label: 'Termin erstellt', module: 'calendar' },
|
{ value: 'PlaceVisited', label: $_('goals.editor.event_place_visited'), module: 'places' },
|
||||||
{ value: 'TransactionCreated', label: 'Transaktion', module: 'finance' },
|
{ value: 'WorkoutFinished', label: $_('goals.editor.event_workout_finished'), module: 'body' },
|
||||||
];
|
{
|
||||||
|
value: 'MeditationCompleted',
|
||||||
|
label: $_('goals.editor.event_meditation_completed'),
|
||||||
|
module: 'meditate',
|
||||||
|
},
|
||||||
|
{ value: 'SleepLogged', label: $_('goals.editor.event_sleep_logged'), module: 'sleep' },
|
||||||
|
{
|
||||||
|
value: 'CalendarEventCreated',
|
||||||
|
label: $_('goals.editor.event_calendar_event_created'),
|
||||||
|
module: 'calendar',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'TransactionCreated',
|
||||||
|
label: $_('goals.editor.event_transaction_created'),
|
||||||
|
module: 'finance',
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
function onEventTypeChange() {
|
function onEventTypeChange() {
|
||||||
const opt = EVENT_OPTIONS.find((o) => o.value === eventType);
|
const opt = EVENT_OPTIONS.find((o) => o.value === eventType);
|
||||||
|
|
@ -88,7 +105,7 @@
|
||||||
onclick={(e) => e.stopPropagation()}
|
onclick={(e) => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
<div class="editor-header">
|
<div class="editor-header">
|
||||||
<h3>Eigenes Ziel erstellen</h3>
|
<h3>{$_('goals.editor.title')}</h3>
|
||||||
<button class="close-btn" onclick={onClose}><X size={16} /></button>
|
<button class="close-btn" onclick={onClose}><X size={16} /></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -99,18 +116,18 @@
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="label">Titel</span>
|
<span class="label">{$_('goals.editor.label_title')}</span>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
bind:value={title}
|
bind:value={title}
|
||||||
placeholder="z.B. 4x Sport pro Woche"
|
placeholder={$_('goals.editor.placeholder_title')}
|
||||||
required
|
required
|
||||||
maxlength="60"
|
maxlength="60"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="label">Was zaehlen?</span>
|
<span class="label">{$_('goals.editor.label_what_to_count')}</span>
|
||||||
<select bind:value={eventType} onchange={onEventTypeChange}>
|
<select bind:value={eventType} onchange={onEventTypeChange}>
|
||||||
{#each EVENT_OPTIONS as opt}
|
{#each EVENT_OPTIONS as opt}
|
||||||
<option value={opt.value}>{opt.label}</option>
|
<option value={opt.value}>{opt.label}</option>
|
||||||
|
|
@ -119,56 +136,70 @@
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="label">Wie zaehlen?</span>
|
<span class="label">{$_('goals.editor.label_how_to_count')}</span>
|
||||||
<select bind:value={source}>
|
<select bind:value={source}>
|
||||||
<option value="event_count">Anzahl zaehlen</option>
|
<option value="event_count">{$_('goals.editor.source_count')}</option>
|
||||||
<option value="event_sum">Wert summieren</option>
|
<option value="event_sum">{$_('goals.editor.source_sum')}</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
{#if source === 'event_sum'}
|
{#if source === 'event_sum'}
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="label">Summen-Feld</span>
|
<span class="label">{$_('goals.editor.label_sum_field')}</span>
|
||||||
<input type="text" bind:value={sumField} placeholder="z.B. quantityMl, calories" />
|
<input
|
||||||
|
type="text"
|
||||||
|
bind:value={sumField}
|
||||||
|
placeholder={$_('goals.editor.placeholder_sum_field')}
|
||||||
|
/>
|
||||||
</label>
|
</label>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="field-row">
|
<div class="field-row">
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="label">Filter (optional)</span>
|
<span class="label">{$_('goals.editor.label_filter')}</span>
|
||||||
<input type="text" bind:value={filterField} placeholder="Feld z.B. drinkType" />
|
<input
|
||||||
|
type="text"
|
||||||
|
bind:value={filterField}
|
||||||
|
placeholder={$_('goals.editor.placeholder_filter_field')}
|
||||||
|
/>
|
||||||
</label>
|
</label>
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="label">Wert</span>
|
<span class="label">{$_('goals.editor.label_filter_value')}</span>
|
||||||
<input type="text" bind:value={filterValue} placeholder="z.B. water" />
|
<input
|
||||||
|
type="text"
|
||||||
|
bind:value={filterValue}
|
||||||
|
placeholder={$_('goals.editor.placeholder_filter_value')}
|
||||||
|
/>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field-row">
|
<div class="field-row">
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="label">Ziel</span>
|
<span class="label">{$_('goals.editor.label_target')}</span>
|
||||||
<div class="target-row">
|
<div class="target-row">
|
||||||
<select bind:value={comparison}>
|
<select bind:value={comparison}>
|
||||||
<option value="gte">Mindestens</option>
|
<option value="gte">{$_('goals.editor.comparison_gte')}</option>
|
||||||
<option value="lte">Hoechstens</option>
|
<option value="lte">{$_('goals.editor.comparison_lte')}</option>
|
||||||
</select>
|
</select>
|
||||||
<input type="number" bind:value={targetValue} min={1} max={10000} />
|
<input type="number" bind:value={targetValue} min={1} max={10000} />
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="label">Zeitraum</span>
|
<span class="label">{$_('goals.editor.label_period')}</span>
|
||||||
<select bind:value={period}>
|
<select bind:value={period}>
|
||||||
<option value="day">Pro Tag</option>
|
<option value="day">{$_('goals.editor.period_day')}</option>
|
||||||
<option value="week">Pro Woche</option>
|
<option value="week">{$_('goals.editor.period_week')}</option>
|
||||||
<option value="month">Pro Monat</option>
|
<option value="month">{$_('goals.editor.period_month')}</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<button type="button" class="btn-cancel" onclick={onClose}>Abbrechen</button>
|
<button type="button" class="btn-cancel" onclick={onClose}
|
||||||
|
>{$_('goals.editor.action_cancel')}</button
|
||||||
|
>
|
||||||
<button type="submit" class="btn-create" disabled={!title.trim() || pending}>
|
<button type="submit" class="btn-create" disabled={!title.trim() || pending}>
|
||||||
{pending ? '...' : 'Erstellen'}
|
{pending ? '...' : $_('goals.editor.action_create')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,6 @@
|
||||||
"apps/mana/apps/web/src/lib/modules/drink/ListView.svelte": 5,
|
"apps/mana/apps/web/src/lib/modules/drink/ListView.svelte": 5,
|
||||||
"apps/mana/apps/web/src/lib/modules/finance/ListView.svelte": 6,
|
"apps/mana/apps/web/src/lib/modules/finance/ListView.svelte": 6,
|
||||||
"apps/mana/apps/web/src/lib/modules/firsts/ListView.svelte": 15,
|
"apps/mana/apps/web/src/lib/modules/firsts/ListView.svelte": 15,
|
||||||
"apps/mana/apps/web/src/lib/modules/goals/GoalEditor.svelte": 15,
|
|
||||||
"apps/mana/apps/web/src/lib/modules/goals/ListView.svelte": 1,
|
"apps/mana/apps/web/src/lib/modules/goals/ListView.svelte": 1,
|
||||||
"apps/mana/apps/web/src/lib/modules/guides/ListView.svelte": 1,
|
"apps/mana/apps/web/src/lib/modules/guides/ListView.svelte": 1,
|
||||||
"apps/mana/apps/web/src/lib/modules/guides/views/DetailView.svelte": 7,
|
"apps/mana/apps/web/src/lib/modules/guides/views/DetailView.svelte": 7,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue