- Dashboard: Fehlzeiten-Warnung lädt Mitarbeitssitzungen einmal vorab statt pro Schüler/Eintrag einzeln nachzuschlagen (N+1 vermieden); neues IParticipationSessionRepository.GetAll() dafür. - CI: .gitea/workflows/ci.yml baut und testet bei jedem Push/PR. Dabei fehlende Release|Any CPU-Konfiguration für 6 Projekte in der .sln behoben (LehrerApp.Data.Tests wurde bei Release-Builds der Solution bislang stillschweigend übersprungen). TreatWarningsAsErrors jetzt aktiv. - SettingsViewModel (1986 Zeilen) als partial class auf 20 Themen- dateien aufgeteilt, Verhalten unverändert. - Backup: optionaler zweiter Sicherungsordner (USB-Stick/Netzlaufwerk, best-effort) und Integritätsprüfung nach jedem Backup (DatabaseEncryptionService.CanOpenAndRead). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
70 lines
2.3 KiB
C#
70 lines
2.3 KiB
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using LehrerApp.Core.Interfaces;
|
|
using LehrerApp.Core.Models;
|
|
using LehrerApp.Core.Services;
|
|
using LehrerApp.Data;
|
|
using LehrerApp.Desktop.Services;
|
|
using LehrerApp.Desktop.ViewModels.Planning;
|
|
using LehrerApp.Sync;
|
|
using LehrerApp.Sync.Crypto;
|
|
using System.Collections.ObjectModel;
|
|
using System.Globalization;
|
|
using System.Security.Cryptography;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace LehrerApp.Desktop.ViewModels.Settings;
|
|
|
|
public partial class SettingsViewModel
|
|
{
|
|
// ── Kürzel-Katalog (Stundenverlaufsplan, 4.2.2) ──────────────────────────
|
|
|
|
[ObservableProperty] private string _newShorthandCode = "";
|
|
[ObservableProperty] private string _newShorthandLabel = "";
|
|
[ObservableProperty] private string _newShorthandCodeError = "";
|
|
|
|
public ObservableCollection<ShorthandCodeListItem> ShorthandCodes { get; } = [];
|
|
|
|
// ── Kürzel-Katalog: Laden / Hinzufügen / Löschen ─────────────────────────
|
|
|
|
public void LoadShorthandCodes()
|
|
{
|
|
ShorthandCodes.Clear();
|
|
foreach (var c in _shorthandCodes.GetAll())
|
|
ShorthandCodes.Add(new ShorthandCodeListItem(c));
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void AddShorthandCode()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(NewShorthandCode)) { NewShorthandCodeError = "Kürzel erforderlich."; return; }
|
|
try
|
|
{
|
|
_shorthandCodes.Save(new ShorthandCode { Code = NewShorthandCode.Trim(), Label = NewShorthandLabel.Trim() });
|
|
}
|
|
catch (InvalidOperationException ex)
|
|
{
|
|
NewShorthandCodeError = ex.Message;
|
|
return;
|
|
}
|
|
NewShorthandCode = ""; NewShorthandLabel = ""; NewShorthandCodeError = "";
|
|
LoadShorthandCodes();
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void DeleteShorthandCode(ShorthandCodeListItem? item)
|
|
{
|
|
if (item is null) return;
|
|
_shorthandCodes.Delete(item.Id);
|
|
LoadShorthandCodes();
|
|
}
|
|
}
|
|
|
|
public class ShorthandCodeListItem(ShorthandCode c)
|
|
{
|
|
public Guid Id { get; } = c.Id;
|
|
public string Code { get; } = c.Code;
|
|
public string Label { get; } = c.Label;
|
|
}
|