fixed guardian login edge cases and misleading placeholders on failed loads

This commit is contained in:
2026-09-20 19:03:45 +02:00
parent 2423c1a75e
commit 630497abdd
23 changed files with 299 additions and 72 deletions
@@ -106,6 +106,18 @@ class _AbsenceFormState extends State<_AbsenceForm> {
// The child's identity is the whole point of the form, so a failed
// prefill is an error here, not a degraded start.
final prefill = await AbsencePrefill().run(childId: _childId);
// Name and class are readOnly in this mode, so a gap in the prefill
// cannot be filled by the user — say so instead of offering a form that
// can never be submitted.
if (prefill.firstName.trim().isEmpty ||
prefill.lastName.trim().isEmpty ||
prefill.className.trim().isEmpty) {
throw AbsencePrefillIncompleteException(
technicalDetails:
'childId=$_childId, class="${prefill.className}", '
'name="${prefill.firstName} ${prefill.lastName}"',
);
}
_classes = [prefill.className];
_applyPrefill(prefill, _classes);
return;
@@ -25,10 +25,17 @@ class ParentLetterFormPolicy {
final List<ParentLetterField> fields;
final bool signatureRequired;
/// The letter asks for something this app version drops from [fields].
/// Only a required one blocks the form ([ParentLetterFormMode.unsupported]);
/// an optional one still has to be named, or the response looks complete
/// while a question went unanswered.
final bool hasUnsupportedFields;
const ParentLetterFormPolicy._(
this.mode,
this.fields,
this.signatureRequired,
this.hasUnsupportedFields,
);
bool get canSubmit =>
@@ -89,6 +96,11 @@ class ParentLetterFormPolicy {
? ParentLetterFormMode.change
: ParentLetterFormMode.open;
}
return ParentLetterFormPolicy._(mode, supported, request.signatureRequired);
return ParentLetterFormPolicy._(
mode,
supported,
request.signatureRequired,
supported.length != request.fields.length,
);
}
}
@@ -101,10 +101,14 @@ class _ParentLetterResponseCardState extends State<ParentLetterResponseCard> {
ParentLetterFormMode.open ||
ParentLetterFormMode.change => _form(policy),
ParentLetterFormMode.done => _result(theme, policy),
// The server locks a response for other reasons too (withdrawn,
// finalised), so only name the deadline when there is one.
ParentLetterFormMode.closed => [
_note(
'Die Frist ist abgelaufen. Eine Rückmeldung ist nicht mehr '
'möglich.',
deadline != null
? 'Die Frist ist abgelaufen. Eine Rückmeldung ist nicht '
'mehr möglich.'
: 'Eine Rückmeldung ist nicht mehr möglich.',
),
],
ParentLetterFormMode.unsupported => [
@@ -157,6 +161,15 @@ class _ParentLetterResponseCardState extends State<ParentLetterResponseCard> {
),
),
],
if (policy.hasUnsupportedFields)
Padding(
padding: const EdgeInsets.only(bottom: 8),
child: _note(
'Dieser Elternbrief enthält zusätzlich eine Abfrage, die diese '
'App-Version nicht anzeigen kann. Bitte aktualisiere die App, um '
'vollständig zu antworten.',
),
),
Padding(
padding: const EdgeInsets.fromLTRB(16, 4, 16, 0),
child: AsyncActionButton(
+15 -12
View File
@@ -12,7 +12,6 @@ import '../../../state/app/modules/timetable/bloc/timetable_state.dart';
import '../../../state/app/modules/timetable/policy/timetable_policy.dart';
import '../../../state/app/modules/timetable/subject/timetable_subject.dart';
import '../../../utils/haptics.dart';
import '../../../widget/app_progress_indicator.dart';
import '../../../widget/child_switcher.dart';
import '../../../widget/demo_restricted.dart';
import 'custom_events/custom_event_edit_dialog.dart';
@@ -29,6 +28,11 @@ class Timetable extends StatefulWidget {
}
class _TimetableState extends State<Timetable> {
/// One calendar key per subject: a new subject (child switch, foreign plan)
/// must not inherit the displayed week of the previous one, but coming back
/// to a subject should find its calendar where it was left.
final Map<TimetableSubject, GlobalKey<TimetableCalendarViewState>>
_calendarKeys = {};
GlobalKey<TimetableCalendarViewState> _calendarKey =
GlobalKey<TimetableCalendarViewState>();
TimetableSubject? _calendarSubject;
@@ -107,7 +111,10 @@ class _TimetableState extends State<Timetable> {
// previous calendar state.
if (subject != _calendarSubject) {
_calendarSubject = subject;
_calendarKey = GlobalKey<TimetableCalendarViewState>();
_calendarKey = _calendarKeys.putIfAbsent(
subject,
GlobalKey<TimetableCalendarViewState>.new,
);
}
final innerState = context.watch<B>().state.data;
final atToday = innerState != null && _isOnInitialWeek(innerState);
@@ -204,20 +211,16 @@ class _TimetableState extends State<Timetable> {
}
/// Shown instead of a plan when the session has none, i.e. a guardian whose
/// children are not known (yet).
/// children are not known (yet). [NoChildrenPlaceholder] tells a pending or
/// failed capability load apart from a confirmed empty list.
class _NoTimetableView extends StatelessWidget {
const _NoTimetableView();
@override
Widget build(BuildContext context) {
final capabilities = context.watch<CapabilitiesCubit>().state;
return Scaffold(
appBar: AppBar(title: const Text('Stunden & Vertretungsplan')),
body: capabilities.loaded
? const NoChildrenPlaceholder()
: const Center(child: AppProgressIndicator.large()),
);
}
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('Stunden & Vertretungsplan')),
body: const NoChildrenPlaceholder(),
);
}
/// Slim banner shown at the top of the timetable while a foreign element's plan