Skip to content

Commit da6759b

Browse files
client, server: implement support check documents
1 parent 75f7c52 commit da6759b

10 files changed

Lines changed: 658 additions & 43 deletions

File tree

school_data_hub_client/lib/src/protocol/client.dart

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,38 @@ class EndpointLearningSupportPlan extends _i1.EndpointRef {
12951295
'supportGoalCheckId': supportGoalCheckId,
12961296
},
12971297
);
1298+
1299+
_i2.Future<_i30.SupportGoal> addFileToSupportGoalCheck(
1300+
int supportGoalId,
1301+
int supportGoalCheckId,
1302+
String filePath,
1303+
String createdBy,
1304+
) =>
1305+
caller.callServerEndpoint<_i30.SupportGoal>(
1306+
'learningSupportPlan',
1307+
'addFileToSupportGoalCheck',
1308+
{
1309+
'supportGoalId': supportGoalId,
1310+
'supportGoalCheckId': supportGoalCheckId,
1311+
'filePath': filePath,
1312+
'createdBy': createdBy,
1313+
},
1314+
);
1315+
1316+
_i2.Future<_i30.SupportGoal> removeFileFromSupportGoalCheck(
1317+
int supportGoalId,
1318+
int supportGoalCheckId,
1319+
String documentId,
1320+
) =>
1321+
caller.callServerEndpoint<_i30.SupportGoal>(
1322+
'learningSupportPlan',
1323+
'removeFileFromSupportGoalCheck',
1324+
{
1325+
'supportGoalId': supportGoalId,
1326+
'supportGoalCheckId': supportGoalCheckId,
1327+
'documentId': documentId,
1328+
},
1329+
);
12981330
}
12991331

13001332
/// {@category Endpoint}

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
import 'dart:io';
2+
13
import 'package:school_data_hub_client/school_data_hub_client.dart';
4+
import 'package:school_data_hub_flutter/common/data/file_upload_service.dart';
5+
import 'package:school_data_hub_flutter/common/models/enums.dart';
26
import 'package:school_data_hub_flutter/core/client/client_helper.dart';
37
import 'package:flutter_it/flutter_it.dart';
48

@@ -228,4 +232,47 @@ class LearningSupportApiService {
228232
);
229233
return response;
230234
}
235+
236+
//- GOAL CHECK DOCUMENTS ---------------------------------------------------
237+
238+
Future<SupportGoal?> addFileToSupportGoalCheck({
239+
required int supportGoalId,
240+
required int supportGoalCheckId,
241+
required File file,
242+
required String createdBy,
243+
String? fileInfo,
244+
}) async {
245+
final path = await ClientFileUpload.uploadFile(
246+
file: file,
247+
fileInfo: fileInfo,
248+
storageId: StorageId.private,
249+
folder: ServerStorageFolder.documents,
250+
);
251+
final result = await ClientHelper.apiCall(
252+
call: () => _client.learningSupportPlan.addFileToSupportGoalCheck(
253+
supportGoalId,
254+
supportGoalCheckId,
255+
path.path!,
256+
createdBy,
257+
),
258+
errorMessage: 'Fehler beim Hinzufügen der Datei zum Ziel-Check',
259+
);
260+
return result;
261+
}
262+
263+
Future<SupportGoal?> removeFileFromSupportGoalCheck({
264+
required int supportGoalId,
265+
required int supportGoalCheckId,
266+
required String documentId,
267+
}) async {
268+
final result = await ClientHelper.apiCall(
269+
call: () => _client.learningSupportPlan.removeFileFromSupportGoalCheck(
270+
supportGoalId,
271+
supportGoalCheckId,
272+
documentId,
273+
),
274+
errorMessage: 'Fehler beim Entfernen der Datei vom Ziel-Check',
275+
);
276+
return result;
277+
}
231278
}

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

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,67 @@ class LearningSupportManager {
310310
final goalIndex = goals.indexWhere((g) => g.id == updatedGoal.id);
311311
if (goalIndex != -1) {
312312
goals[goalIndex] = updatedGoal;
313-
// Trigger UI update by marking the pupil as dirty
314-
pupil.pupilIsDirty = true;
313+
pupil.notifyChanged();
315314
}
316315
}
317316

317+
//- GOAL CHECK DOCUMENTS --------------------------------------------------
318+
319+
Future<void> addFileToSupportGoalCheck({
320+
required int supportGoalId,
321+
required int supportGoalCheckId,
322+
required int pupilId,
323+
required File file,
324+
String? fileInfo,
325+
}) async {
326+
final encryptedFile = await customEncrypter.encryptFile(file);
327+
final createdBy = _hubSessionManager.userName!;
328+
final updatedGoal = await _learningSupportApiService
329+
.addFileToSupportGoalCheck(
330+
supportGoalId: supportGoalId,
331+
supportGoalCheckId: supportGoalCheckId,
332+
file: encryptedFile,
333+
createdBy: createdBy,
334+
fileInfo: fileInfo,
335+
);
336+
337+
if (updatedGoal == null) {
338+
return;
339+
}
340+
341+
_updatePupilSupportGoal(pupilId, updatedGoal);
342+
343+
_notificationService.showSnackBar(
344+
NotificationType.success,
345+
'Datei hinzugefügt',
346+
);
347+
}
348+
349+
Future<void> removeFileFromSupportGoalCheck({
350+
required int supportGoalId,
351+
required int supportGoalCheckId,
352+
required int pupilId,
353+
required String documentId,
354+
}) async {
355+
final updatedGoal = await _learningSupportApiService
356+
.removeFileFromSupportGoalCheck(
357+
supportGoalId: supportGoalId,
358+
supportGoalCheckId: supportGoalCheckId,
359+
documentId: documentId,
360+
);
361+
362+
if (updatedGoal == null) {
363+
return;
364+
}
365+
366+
_updatePupilSupportGoal(pupilId, updatedGoal);
367+
368+
_notificationService.showSnackBar(
369+
NotificationType.success,
370+
'Datei entfernt',
371+
);
372+
}
373+
318374
//- BULK IMPORT SUPPORT LEVELS ------------------------------------------
319375

320376
Future<void> importSupportLevelsFromFile() async {

0 commit comments

Comments
 (0)