Skip to content

Commit 74030cb

Browse files
support plan WIP, fix updateCategorStatus endpoint
1 parent 5c0e641 commit 74030cb

9 files changed

Lines changed: 353 additions & 271 deletions

File tree

school_data_hub_client/lib/src/protocol/client.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ class EndpointLearningSupportPlan extends _i1.EndpointRef {
12281228

12291229
_i2.Future<_i29.SupportCategoryStatus> updateCategoryStatus(
12301230
int pupilId,
1231-
int supportCategoryId,
1231+
int statusId,
12321232
int? status,
12331233
String? comment,
12341234
String? createdBy,
@@ -1239,7 +1239,7 @@ class EndpointLearningSupportPlan extends _i1.EndpointRef {
12391239
'updateCategoryStatus',
12401240
{
12411241
'pupilId': pupilId,
1242-
'supportCategoryId': supportCategoryId,
1242+
'statusId': statusId,
12431243
'status': status,
12441244
'comment': comment,
12451245
'createdBy': createdBy,

school_data_hub_flutter/lib/features/learning_support/domain/learning_support_manager.dart

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -186,36 +186,50 @@ class LearningSupportManager {
186186
_pupilManager.updatePupilProxyWithPupilData(updatedPupil);
187187
return;
188188
}
189-
// Future<void> updateSupportCategoryStatusProperty({
190-
// required PupilProxy pupil,
191-
// required String statusId,
192-
// String? state,
193-
// String? comment,
194-
// String? createdBy,
195-
// String? createdAt,
196-
// }) async {
197-
// final PupilData responsePupil =
198-
// await _learningSupportApiService.updateCategoryStatusProperty(
199-
// pupil, statusId, state, comment, createdBy, createdAt);
200-
201-
// locator<PupilManager>().updatePupilProxyWithPupilData(responsePupil);
202189

203-
// _notificationService.showSnackBar(
204-
// NotificationType.success, 'Status aktualisiert');
205-
206-
// return;
207-
// }
190+
Future<void> updateSupportCategoryStatus({
191+
required int pupilId,
192+
required int statusId,
193+
int? score,
194+
String? comment,
195+
String? createdBy,
196+
DateTime? createdAt,
197+
}) async {
198+
final updatedStatus = await _learningSupportApiService.updateCategoryStatus(
199+
pupilId,
200+
statusId,
201+
score,
202+
comment,
203+
createdBy,
204+
createdAt,
205+
);
208206

209-
// Future<void> deleteSupportCategoryStatus(String statusId) async {
210-
// final PupilData responsePupil =
211-
// await _learningSupportApiService.deleteCategoryStatus(statusId);
207+
if (updatedStatus == null) {
208+
_notificationService.showSnackBar(
209+
NotificationType.error,
210+
'Fehler beim Aktualisieren des Status.',
211+
);
212+
return;
213+
}
212214

213-
// _notificationService.showSnackBar(
214-
// NotificationType.success, 'Status gelöscht');
215+
// Update the status in-place on the pupil proxy
216+
final pupil = _pupilManager.getPupilByPupilId(pupilId);
217+
if (pupil != null) {
218+
final statuses = pupil.supportCategoryStatuses;
219+
if (statuses != null) {
220+
final index = statuses.indexWhere((s) => s.id == statusId);
221+
if (index != -1) {
222+
statuses[index] = updatedStatus;
223+
pupil.notifyChanged();
224+
}
225+
}
226+
}
215227

216-
// locator<PupilManager>().updatePupilProxyWithPupilData(responsePupil);
217-
// return;
218-
// }
228+
_notificationService.showSnackBar(
229+
NotificationType.success,
230+
'Status aktualisiert',
231+
);
232+
}
219233

220234
Future<void> postNewSupportCategoryGoal({
221235
required int goalCategoryId,

school_data_hub_flutter/lib/features/learning_support/presentation/widgets/learning_support_plan_card.dart

Lines changed: 50 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter_it/flutter_it.dart';
23
import 'package:gap/gap.dart';
34
import 'package:school_data_hub_client/school_data_hub_client.dart';
45
import 'package:school_data_hub_flutter/common/services/notification_service.dart';
@@ -8,7 +9,6 @@ import 'package:school_data_hub_flutter/features/learning_support/domain/learnin
89
import 'package:school_data_hub_flutter/features/learning_support/domain/support_category_manager.dart';
910
import 'package:school_data_hub_flutter/features/learning_support/services/pdf/learning_support_plan_pdf_generator.dart';
1011
import 'package:school_data_hub_flutter/features/pupil/domain/models/pupil_proxy.dart';
11-
import 'package:flutter_it/flutter_it.dart';
1212

1313
/// A card widget for displaying and editing a learning support plan.
1414
///
@@ -51,14 +51,18 @@ class _LearningSupportPlanCardState extends State<LearningSupportPlanCard> {
5151

5252
void _initControllers() {
5353
_commentController = TextEditingController(text: plan.comment ?? '');
54-
_socialPedagogueController =
55-
TextEditingController(text: plan.socialPedagogue ?? '');
56-
_professionalsInvolvedController =
57-
TextEditingController(text: plan.proffesionalsInvolved ?? '');
58-
_strengthsDescriptionController =
59-
TextEditingController(text: plan.strengthsDescription ?? '');
60-
_problemsDescriptionController =
61-
TextEditingController(text: plan.problemsDescription ?? '');
54+
_socialPedagogueController = TextEditingController(
55+
text: plan.socialPedagogue ?? '',
56+
);
57+
_professionalsInvolvedController = TextEditingController(
58+
text: plan.proffesionalsInvolved ?? '',
59+
);
60+
_strengthsDescriptionController = TextEditingController(
61+
text: plan.strengthsDescription ?? '',
62+
);
63+
_problemsDescriptionController = TextEditingController(
64+
text: plan.problemsDescription ?? '',
65+
);
6266
}
6367

6468
@override
@@ -67,12 +71,9 @@ class _LearningSupportPlanCardState extends State<LearningSupportPlanCard> {
6771
if (oldWidget.plan != widget.plan && !_isEditing) {
6872
_commentController.text = plan.comment ?? '';
6973
_socialPedagogueController.text = plan.socialPedagogue ?? '';
70-
_professionalsInvolvedController.text =
71-
plan.proffesionalsInvolved ?? '';
72-
_strengthsDescriptionController.text =
73-
plan.strengthsDescription ?? '';
74-
_problemsDescriptionController.text =
75-
plan.problemsDescription ?? '';
74+
_professionalsInvolvedController.text = plan.proffesionalsInvolved ?? '';
75+
_strengthsDescriptionController.text = plan.strengthsDescription ?? '';
76+
_problemsDescriptionController.text = plan.problemsDescription ?? '';
7677
}
7778
}
7879

@@ -90,12 +91,9 @@ class _LearningSupportPlanCardState extends State<LearningSupportPlanCard> {
9091
setState(() {
9192
_commentController.text = plan.comment ?? '';
9293
_socialPedagogueController.text = plan.socialPedagogue ?? '';
93-
_professionalsInvolvedController.text =
94-
plan.proffesionalsInvolved ?? '';
95-
_strengthsDescriptionController.text =
96-
plan.strengthsDescription ?? '';
97-
_problemsDescriptionController.text =
98-
plan.problemsDescription ?? '';
94+
_professionalsInvolvedController.text = plan.proffesionalsInvolved ?? '';
95+
_strengthsDescriptionController.text = plan.strengthsDescription ?? '';
96+
_problemsDescriptionController.text = plan.problemsDescription ?? '';
9997
_isEditing = true;
10098
});
10199
}
@@ -118,16 +116,14 @@ class _LearningSupportPlanCardState extends State<LearningSupportPlanCard> {
118116
: _socialPedagogueController.text.trim(),
119117
proffesionalsInvolved:
120118
_professionalsInvolvedController.text.trim().isEmpty
121-
? null
122-
: _professionalsInvolvedController.text.trim(),
123-
strengthsDescription:
124-
_strengthsDescriptionController.text.trim().isEmpty
125-
? null
126-
: _strengthsDescriptionController.text.trim(),
127-
problemsDescription:
128-
_problemsDescriptionController.text.trim().isEmpty
129-
? null
130-
: _problemsDescriptionController.text.trim(),
119+
? null
120+
: _professionalsInvolvedController.text.trim(),
121+
strengthsDescription: _strengthsDescriptionController.text.trim().isEmpty
122+
? null
123+
: _strengthsDescriptionController.text.trim(),
124+
problemsDescription: _problemsDescriptionController.text.trim().isEmpty
125+
? null
126+
: _problemsDescriptionController.text.trim(),
131127
);
132128

133129
final success = await di<LearningSupportManager>()
@@ -150,10 +146,10 @@ class _LearningSupportPlanCardState extends State<LearningSupportPlanCard> {
150146

151147
final file =
152148
await LearningSupportPlanPdfGenerator.generateLearningSupportPlanPdf(
153-
plan: plan,
154-
pupil: pupil,
155-
supportCategories: supportCategories,
156-
);
149+
plan: plan,
150+
pupil: pupil,
151+
supportCategories: supportCategories,
152+
);
157153

158154
if (mounted) {
159155
Navigator.of(context).push(
@@ -173,7 +169,7 @@ class _LearningSupportPlanCardState extends State<LearningSupportPlanCard> {
173169
@override
174170
Widget build(BuildContext context) {
175171
return Card(
176-
margin: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0),
172+
margin: const EdgeInsets.symmetric(horizontal: 5.0, vertical: 4.0),
177173
child: Padding(
178174
padding: const EdgeInsets.all(16.0),
179175
child: Column(
@@ -199,34 +195,11 @@ class _LearningSupportPlanCardState extends State<LearningSupportPlanCard> {
199195
children: [
200196
Expanded(
201197
child: Text(
202-
plan.planId,
203-
style: const TextStyle(
204-
fontSize: 16,
205-
fontWeight: FontWeight.bold,
206-
),
207-
),
208-
),
209-
Container(
210-
padding: const EdgeInsets.symmetric(
211-
horizontal: 8.0,
212-
vertical: 4.0,
213-
),
214-
decoration: BoxDecoration(
215-
color: AppColors.backgroundColor.withValues(alpha: 0.1),
216-
borderRadius: BorderRadius.circular(12.0),
217-
border: Border.all(
218-
color: AppColors.backgroundColor.withValues(alpha: 0.3),
219-
),
220-
),
221-
child: Text(
222-
'Förderebene ${plan.learningSupportLevelId}',
223-
style: TextStyle(
224-
fontSize: 12,
225-
fontWeight: FontWeight.w500,
226-
color: AppColors.backgroundColor,
227-
),
198+
'Förderplan Nr. ${plan.planId}',
199+
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
228200
),
229201
),
202+
230203
const Gap(10),
231204
// Edit Button
232205
InkWell(
@@ -299,15 +272,6 @@ class _LearningSupportPlanCardState extends State<LearningSupportPlanCard> {
299272
return Column(
300273
crossAxisAlignment: CrossAxisAlignment.start,
301274
children: [
302-
if (plan.comment?.isNotEmpty ?? false) ...[
303-
const Gap(8),
304-
const Text(
305-
'Kommentar:',
306-
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500),
307-
),
308-
const Gap(2),
309-
Text(plan.comment!, style: const TextStyle(fontSize: 12)),
310-
],
311275
if (plan.socialPedagogue?.isNotEmpty ?? false) ...[
312276
const Gap(8),
313277
const Text(
@@ -348,10 +312,16 @@ class _LearningSupportPlanCardState extends State<LearningSupportPlanCard> {
348312
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500),
349313
),
350314
const Gap(2),
351-
Text(
352-
plan.problemsDescription!,
353-
style: const TextStyle(fontSize: 12),
315+
Text(plan.problemsDescription!, style: const TextStyle(fontSize: 12)),
316+
],
317+
if (plan.comment?.isNotEmpty ?? false) ...[
318+
const Gap(8),
319+
const Text(
320+
'Ergänzende Hinweise und Absprachen:',
321+
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500),
354322
),
323+
const Gap(2),
324+
Text(plan.comment!, style: const TextStyle(fontSize: 12)),
355325
],
356326
],
357327
);
@@ -366,14 +336,15 @@ class _LearningSupportPlanCardState extends State<LearningSupportPlanCard> {
366336
const Gap(8),
367337

368338
// Comment field
369-
const Text('Kommentar:', style: AppStyles.textLabel),
339+
const Text(
340+
'Ergänze Hinweise und Absprachen:',
341+
style: AppStyles.textLabel,
342+
),
370343
const Gap(4),
371344
TextField(
372345
controller: _commentController,
373346
maxLines: 3,
374-
decoration: AppStyles.textFieldDecoration(
375-
labelText: 'Kommentar',
376-
),
347+
decoration: AppStyles.textFieldDecoration(labelText: 'Kommentar'),
377348
),
378349

379350
const Gap(12),
@@ -456,10 +427,7 @@ class _LearningSupportPlanCardState extends State<LearningSupportPlanCard> {
456427
color: Colors.white,
457428
),
458429
)
459-
: const Text(
460-
'SPEICHERN',
461-
style: AppStyles.buttonTextStyle,
462-
),
430+
: const Text('SPEICHERN', style: AppStyles.buttonTextStyle),
463431
),
464432
),
465433
],

0 commit comments

Comments
 (0)