Skip to content

Commit b7e7afe

Browse files
client+server: support category WIP : reordered ui, pdf wip, added updateCategoryGoal method to the backend
1 parent c230817 commit b7e7afe

23 files changed

Lines changed: 406 additions & 166 deletions

File tree

school_data_hub_client/lib/src/protocol/client.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,25 @@ class EndpointLearningSupportPlan extends _i1.EndpointRef {
12791279
},
12801280
);
12811281

1282+
_i2.Future<_i5.PupilData> updateCategoryGoal(
1283+
int pupilId,
1284+
int supportGoalId,
1285+
String? description,
1286+
String? strategies,
1287+
int? supportCategoryId,
1288+
) =>
1289+
caller.callServerEndpoint<_i5.PupilData>(
1290+
'learningSupportPlan',
1291+
'updateCategoryGoal',
1292+
{
1293+
'pupilId': pupilId,
1294+
'supportGoalId': supportGoalId,
1295+
'description': description,
1296+
'strategies': strategies,
1297+
'supportCategoryId': supportCategoryId,
1298+
},
1299+
);
1300+
12821301
_i2.Future<_i5.PupilData> deleteCategoryGoal(
12831302
int pupilId,
12841303
int supportGoalId,
11.8 KB
Loading
-5.83 KB
Loading
23.2 KB
Loading

school_data_hub_flutter/lib/common/widgets/custom_expansion_tile/custom_expansion_tile.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class CustomExpansionTileController {
2525

2626
_ExpansionTileState? _state;
2727

28+
/// Whether this controller is currently attached to an [ExpansionTile].
29+
bool get isAttached => _state != null;
30+
2831
/// Whether the [ExpansionTile] built with this controller is in expanded state.
2932
///
3033
/// This property doesn't take the animation into account. It reports `true`

school_data_hub_flutter/lib/features/learning_support/data/learning_support_api_service.dart

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ class LearningSupportApiService {
2020
return response;
2121
}
2222

23-
Future<bool> updateLearningSupportPlan(
24-
LearningSupportPlan plan,
25-
) async {
23+
Future<bool> updateLearningSupportPlan(LearningSupportPlan plan) async {
2624
final response = await ClientHelper.apiCall(
2725
call: () => _client.learningSupportPlan.updateLearningSupportPlan(plan),
2826
errorMessage: 'Fehler beim Aktualisieren des Förderplans',
@@ -149,6 +147,28 @@ class LearningSupportApiService {
149147
return updatedPupil;
150148
}
151149

150+
//- update category goal
151+
152+
Future<PupilData?> updateCategoryGoal({
153+
required int pupilId,
154+
required int supportGoalId,
155+
String? description,
156+
String? strategies,
157+
int? supportCategoryId,
158+
}) async {
159+
final updatedPupil = await ClientHelper.apiCall(
160+
call: () => _client.learningSupportPlan.updateCategoryGoal(
161+
pupilId,
162+
supportGoalId,
163+
description,
164+
strategies,
165+
supportCategoryId,
166+
),
167+
errorMessage: 'Fehler beim Aktualisieren des Ziels',
168+
);
169+
return updatedPupil;
170+
}
171+
152172
//- delete category goal
153173

154174
Future<PupilData?> deleteCategoryGoal({
@@ -182,7 +202,9 @@ class LearningSupportApiService {
182202
Future<List<SupportCategory>> importSupportCategoriesFromJsonFile(
183203
String filePath,
184204
) async {
185-
return _client.adminCategories.importSupportCategoriesFromJsonFile(filePath);
205+
return _client.adminCategories.importSupportCategoriesFromJsonFile(
206+
filePath,
207+
);
186208
}
187209

188210
//- GOAL CHECKS ------------------------------------------------------------

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

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ class LearningSupportManager {
109109
Future<bool> updateLearningSupportPlan({
110110
required LearningSupportPlan plan,
111111
}) async {
112-
final success =
113-
await _learningSupportApiService.updateLearningSupportPlan(plan);
112+
final success = await _learningSupportApiService.updateLearningSupportPlan(
113+
plan,
114+
);
114115

115116
if (!success) {
116117
_notificationService.showSnackBar(
@@ -257,6 +258,32 @@ class LearningSupportManager {
257258

258259
return;
259260
}
261+
262+
Future<void> updateSupportGoal({
263+
required int pupilId,
264+
required int supportGoalId,
265+
String? description,
266+
String? strategies,
267+
int? supportCategoryId,
268+
}) async {
269+
final responsePupil = await _learningSupportApiService.updateCategoryGoal(
270+
pupilId: pupilId,
271+
supportGoalId: supportGoalId,
272+
description: description,
273+
strategies: strategies,
274+
supportCategoryId: supportCategoryId,
275+
);
276+
if (responsePupil == null) {
277+
return;
278+
}
279+
_pupilManager.updatePupilProxyWithPupilData(responsePupil);
280+
281+
_notificationService.showSnackBar(
282+
NotificationType.success,
283+
'Ziel aktualisiert',
284+
);
285+
}
286+
260287
// Future postNewSupportCategoryGoal(
261288
// {required int goalCategoryId,
262289
// required int pupilId,

school_data_hub_flutter/lib/features/learning_support/presentation/learning_support_list_page/widgets/support_goals_list.dart

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/material.dart';
22
import 'package:gap/gap.dart';
3-
import 'package:school_data_hub_flutter/features/learning_support/domain/learning_support_helper.dart';
43
import 'package:school_data_hub_flutter/features/learning_support/presentation/widgets/support_goal/support_goal_card.dart';
54
import 'package:school_data_hub_flutter/features/pupil/domain/models/pupil_proxy.dart';
65

@@ -13,41 +12,7 @@ class SupportGoalsList extends StatelessWidget {
1312
return Column(
1413
children: [
1514
const Gap(5),
16-
Row(
17-
children: [
18-
Wrap(
19-
children: [
20-
const Text('ärztl. U.: '),
21-
Text(
22-
LearningSupportHelper.preschoolRevision(
23-
pupil.preSchoolMedical?.preschoolMedicalStatus,
24-
),
25-
style: const TextStyle(
26-
fontWeight: FontWeight.bold,
27-
fontSize: 14,
28-
),
29-
),
30-
],
31-
),
32-
],
33-
),
34-
Row(
35-
children: [
36-
Wrap(
37-
children: [
38-
const Text('Kindergartenbesuch: '),
39-
Text(
40-
pupil.kindergardenInfo?.attendedMonths.toString() ??
41-
'Kein Eintrag',
42-
style: const TextStyle(
43-
fontWeight: FontWeight.bold,
44-
fontSize: 14,
45-
),
46-
),
47-
],
48-
),
49-
],
50-
),
15+
5116
const Row(
5217
children: [
5318
Text(

school_data_hub_flutter/lib/features/learning_support/presentation/new_support_category_status_page/controller/new_support_category_status_controller.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:school_data_hub_client/school_data_hub_client.dart';
23
import 'package:school_data_hub_flutter/features/learning_support/domain/learning_support_manager.dart';
34
import 'package:school_data_hub_flutter/features/learning_support/presentation/new_support_category_status_page/new_support_category_status_page.dart';
45
import 'package:flutter_it/flutter_it.dart';
@@ -8,13 +9,15 @@ class NewSupportCategoryStatus extends StatefulWidget {
89
final int pupilId;
910
final int goalCategoryId;
1011
final String elementType;
12+
final SupportGoal? existingGoal;
1113

1214
const NewSupportCategoryStatus({
1315
super.key,
1416
required this.appBarTitle,
1517
required this.pupilId,
1618
required this.goalCategoryId,
1719
required this.elementType,
20+
this.existingGoal,
1821
});
1922

2023
@override
@@ -27,10 +30,16 @@ class NewSupportCategoryStatusController
2730
LearningSupportManager get _learningSupportPlanManager =>
2831
di<LearningSupportManager>();
2932

33+
bool get isEditMode => widget.existingGoal != null;
34+
3035
@override
3136
void initState() {
3237
super.initState();
3338
goalCategoryId = widget.goalCategoryId;
39+
if (widget.existingGoal != null) {
40+
descriptionTextFieldController.text = widget.existingGoal!.description;
41+
strategiesTextField2Controller.text = widget.existingGoal!.strategies;
42+
}
3443
}
3544

3645
final TextEditingController descriptionTextFieldController =
@@ -85,6 +94,20 @@ class NewSupportCategoryStatusController
8594
);
8695
}
8796

97+
Future updateCategoryGoal() async {
98+
if (widget.existingGoal == null) {
99+
return;
100+
}
101+
102+
await _learningSupportPlanManager.updateSupportGoal(
103+
pupilId: widget.pupilId,
104+
supportGoalId: widget.existingGoal!.id!,
105+
description: descriptionTextFieldController.text,
106+
strategies: strategiesTextField2Controller.text,
107+
supportCategoryId: goalCategoryId,
108+
);
109+
}
110+
88111
@override
89112
Widget build(BuildContext context) {
90113
return NewSupportCategoryStatusPage(this);

school_data_hub_flutter/lib/features/learning_support/presentation/new_support_category_status_page/new_support_category_status_page.dart

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ class NewSupportCategoryStatusPage extends StatelessWidget {
109109
children: [
110110
Text(
111111
(controller.widget.appBarTitle ==
112-
'Neues Förderziel')
112+
'Neues Förderziel' ||
113+
controller.isEditMode)
113114
? 'Förderziel'
114115
: 'Beobachtungen',
115116
style: const TextStyle(
@@ -122,7 +123,8 @@ class NewSupportCategoryStatusPage extends StatelessWidget {
122123
),
123124
const Gap(10),
124125
if (controller.widget.appBarTitle ==
125-
'Neues Förderziel') ...[
126+
'Neues Förderziel' ||
127+
controller.isEditMode) ...[
126128
TextField(
127129
minLines: 1,
128130
maxLines: 3,
@@ -154,13 +156,16 @@ class NewSupportCategoryStatusPage extends StatelessWidget {
154156
decoration: AppStyles.textFieldDecoration(
155157
labelText:
156158
(controller.widget.appBarTitle ==
157-
'Neues Förderziel')
159+
'Neues Förderziel' ||
160+
controller.isEditMode)
158161
? 'Hilfen für das Erreichen des Zieles'
159162
: 'Beschreibung des Ist-Zustandes',
160163
),
161164
),
162165
const Gap(20),
163-
if (controller.widget.appBarTitle != 'Neues Förderziel')
166+
if (controller.widget.appBarTitle !=
167+
'Neues Förderziel' &&
168+
!controller.isEditMode)
164169
Row(
165170
crossAxisAlignment: CrossAxisAlignment.start,
166171
children: [
@@ -242,7 +247,9 @@ class NewSupportCategoryStatusPage extends StatelessWidget {
242247
ElevatedButton(
243248
style: AppStyles.successButtonStyle,
244249
onPressed: () {
245-
if (controller.widget.appBarTitle ==
250+
if (controller.isEditMode) {
251+
controller.updateCategoryGoal();
252+
} else if (controller.widget.appBarTitle ==
246253
'Neues Förderziel') {
247254
controller.postCategoryGoal();
248255
} else {
@@ -258,8 +265,8 @@ class NewSupportCategoryStatusPage extends StatelessWidget {
258265
}
259266
Navigator.pop(context);
260267
},
261-
child: const Text(
262-
'SENDEN',
268+
child: Text(
269+
controller.isEditMode ? 'SPEICHERN' : 'SENDEN',
263270
style: AppStyles.buttonTextStyle,
264271
),
265272
),

0 commit comments

Comments
 (0)