feat: app completa recordaLexia (fases 1-5)
App web familiar de rutinas visuales para niños con TDAH: muestra cada día el material del cole y las rutinas de tarde, con gamificación por monedas y tienda de recompensas. Multi-niño y bilingüe ES/CA. Uso doméstico/homelab. Backend (Spring Boot 3.5 / Java 21 / Gradle): - Dominio por capas, PostgreSQL + Liquibase, datos semilla. - API REST con DTOs: /today, toggle con monedas y bonos de bloque/día, monedero, tienda/canje, ajustes y CRUD del panel de padres. - Seguridad ligera por PIN (BCrypt + sesion en memoria), sin Keycloak. - Tests JUnit: generacion del dia, monedas/bonos con reversion, canje, seguridad. Frontend (Angular 19, standalone + signals): - Perfiles, Home (Tablero y Foco), Tienda y panel de padres (5 pestañas). - Tipografia OpenDyslexic conmutable (accesibilidad), i18n ES/CA, TTS y sonido. - Tokens de diseño fieles al handoff (paleta, animaciones, monedas voladoras). Empaquetado: - Docker multi-stage + docker-compose (PostgreSQL + backend + Nginx). - Decisiones de arquitectura documentadas en docs/adr.
This commit is contained in:
122
frontend/src/app/features/parents/routines-tab.component.ts
Normal file
122
frontend/src/app/features/parents/routines-tab.component.ts
Normal file
@@ -0,0 +1,122 @@
|
||||
import { Component, Input, computed, inject, signal } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { ParentApiService } from '../../core/parent-api.service';
|
||||
import { I18nService } from '../../core/i18n.service';
|
||||
import { RoutineView } from '../../core/models';
|
||||
|
||||
const DAYS: { key: string; es: string; ca: string }[] = [
|
||||
{ key: 'MONDAY', es: 'Lunes', ca: 'Dilluns' },
|
||||
{ key: 'TUESDAY', es: 'Martes', ca: 'Dimarts' },
|
||||
{ key: 'WEDNESDAY', es: 'Miércoles', ca: 'Dimecres' },
|
||||
{ key: 'THURSDAY', es: 'Jueves', ca: 'Dijous' },
|
||||
{ key: 'FRIDAY', es: 'Viernes', ca: 'Divendres' },
|
||||
];
|
||||
|
||||
/** Pestaña Rutinas de tarde por día de la semana, de un niño. */
|
||||
@Component({
|
||||
selector: 'app-routines-tab',
|
||||
imports: [FormsModule],
|
||||
template: `
|
||||
<div class="adm-card">
|
||||
<div class="adm-row">
|
||||
<span class="adm-label">{{ i18n.t('tabRoutines') }}:</span>
|
||||
@for (d of days; track d.key) {
|
||||
<button
|
||||
class="adm-chip"
|
||||
[style.background]="d.key === day() ? 'var(--accent-purple)' : ''"
|
||||
[style.color]="d.key === day() ? '#fff' : ''"
|
||||
(click)="day.set(d.key)"
|
||||
>
|
||||
{{ i18n.label(d.es, d.ca) }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="adm-card">
|
||||
<p class="adm-label">Nueva rutina</p>
|
||||
<div class="adm-row">
|
||||
<input class="adm-input adm-input--sm" [(ngModel)]="icon" placeholder="🎹" maxlength="4" />
|
||||
<input class="adm-input" [(ngModel)]="labelEs" placeholder="Rutina (ES)" />
|
||||
<input class="adm-input" [(ngModel)]="labelCa" placeholder="Rutina (CA)" />
|
||||
<input class="adm-input adm-input--sm" type="color" [(ngModel)]="color" />
|
||||
<button class="adm-btn" [disabled]="!labelEs || !labelCa || !icon" (click)="add()">+ {{ i18n.t('add') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="adm-card">
|
||||
<div class="adm-list">
|
||||
@for (r of routinesForDay(); track r.id; let i = $index; let last = $last) {
|
||||
<div class="adm-item">
|
||||
<span>{{ r.icon }}</span>
|
||||
<span class="adm-item__grow">{{ i18n.label(r.labelEs, r.labelCa) }}</span>
|
||||
<button class="adm-del" [disabled]="i === 0" (click)="move(i, -1)" aria-label="Subir">▲</button>
|
||||
<button class="adm-del" [disabled]="last" (click)="move(i, 1)" aria-label="Bajar">▼</button>
|
||||
<button class="adm-del" (click)="remove(r)">✕</button>
|
||||
</div>
|
||||
} @empty {
|
||||
<p class="adm-empty">{{ i18n.t('none') }}</p>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
})
|
||||
export class RoutinesTabComponent {
|
||||
@Input({ required: true }) set childId(value: number) {
|
||||
this._childId = value;
|
||||
this.reload();
|
||||
}
|
||||
private _childId!: number;
|
||||
|
||||
private readonly api = inject(ParentApiService);
|
||||
protected readonly i18n = inject(I18nService);
|
||||
|
||||
protected readonly days = DAYS;
|
||||
protected readonly day = signal('MONDAY');
|
||||
protected readonly routines = signal<RoutineView[]>([]);
|
||||
protected readonly routinesForDay = computed(() =>
|
||||
this.routines().filter((r) => r.dayOfWeek === this.day()),
|
||||
);
|
||||
|
||||
protected icon = '';
|
||||
protected labelEs = '';
|
||||
protected labelCa = '';
|
||||
protected color = '#a78bd0';
|
||||
|
||||
private reload(): void {
|
||||
this.api.listRoutines(this._childId).subscribe((l) => this.routines.set(l));
|
||||
}
|
||||
|
||||
add(): void {
|
||||
const order = this.routinesForDay().length;
|
||||
this.api
|
||||
.createRoutine({
|
||||
childId: this._childId,
|
||||
dayOfWeek: this.day(),
|
||||
labelEs: this.labelEs,
|
||||
labelCa: this.labelCa,
|
||||
icon: this.icon,
|
||||
color: this.color,
|
||||
orderIndex: order,
|
||||
})
|
||||
.subscribe(() => {
|
||||
this.labelEs = this.labelCa = this.icon = '';
|
||||
this.reload();
|
||||
});
|
||||
}
|
||||
|
||||
/** Mueve una rutina del día arriba (-1) o abajo (+1) y persiste el nuevo orden. */
|
||||
move(index: number, delta: number): void {
|
||||
const list = [...this.routinesForDay()];
|
||||
const target = index + delta;
|
||||
if (target < 0 || target >= list.length) {
|
||||
return;
|
||||
}
|
||||
[list[index], list[target]] = [list[target], list[index]];
|
||||
this.api.reorderRoutines(list.map((r) => r.id)).subscribe(() => this.reload());
|
||||
}
|
||||
|
||||
remove(r: RoutineView): void {
|
||||
this.api.deleteRoutine(r.id).subscribe(() => this.reload());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user