From 9b18fe60d6119593bd303504abd17eac7ce43d91 Mon Sep 17 00:00:00 2001 From: dabblingwithcode Date: Wed, 7 Jan 2026 14:31:16 +0100 Subject: [PATCH] client, server: add delete option to long textfield dialog --- .../lib/src/protocol/client.dart | 4 +- .../dialogs/long_textfield_dialog.dart | 44 +++++++++---------- .../widgets/atendance_list_card.dart | 27 ++++++------ .../widgets/authorization_pupil_card.dart | 25 ++++++----- .../book_infos_page/book_infos_page.dart | 20 +++++---- .../book_list_page/widgets/book_card.dart | 10 +++-- .../book_search_result_card.dart | 8 +++- .../presentation/widgets/pupil_book_card.dart | 9 ++-- .../multi_pupil_competence_check_card.dart | 30 +++++++------ .../competence_check_card.dart | 35 ++++++++------- .../support_category_status_entry.dart | 17 +++---- .../users/domain/matrix_user_manager.dart | 2 +- .../pupils_matrix_contacts_list_page.dart | 27 ++++++++---- .../pupil/data/pupil_data_api_service.dart | 9 ++-- .../features/pupil/domain/pupil_mutator.dart | 4 +- .../widgets/after_school_care_details.dart | 8 ++-- .../pupil_after_school_care_content_list.dart | 10 +++-- ...upil_content_authorization_entry_card.dart | 23 +++++----- .../pupil_profile_infos_content.dart | 13 +++--- ...profile_learning_support_content_list.dart | 9 ++-- ..._profile_school_list_pupil_entry_card.dart | 7 +-- .../widgets/school_list_pupil_entry_card.dart | 7 +-- .../widgets/pupil_workbook_card.dart | 9 ++-- .../endpooints/pupil_update_endpoint.dart | 10 ++--- .../lib/src/generated/endpoints.dart | 8 ++-- .../test_tools/serverpod_test_tools.dart | 4 +- 26 files changed, 211 insertions(+), 168 deletions(-) diff --git a/school_data_hub_client/lib/src/protocol/client.dart b/school_data_hub_client/lib/src/protocol/client.dart index 308fa9a4..459dce1c 100644 --- a/school_data_hub_client/lib/src/protocol/client.dart +++ b/school_data_hub_client/lib/src/protocol/client.dart @@ -1459,7 +1459,7 @@ class EndpointPupilUpdate extends _i1.EndpointRef { _i2.Future<_i5.PupilData> updateStringProperty( int pupilId, String property, - String? value, + ({String? value})? propertyValue, ) => caller.callServerEndpoint<_i5.PupilData>( 'pupilUpdate', @@ -1467,7 +1467,7 @@ class EndpointPupilUpdate extends _i1.EndpointRef { { 'pupilId': pupilId, 'property': property, - 'value': value, + 'propertyValue': _i16.mapRecordToJson(propertyValue), }, ); diff --git a/school_data_hub_flutter/lib/common/widgets/dialogs/long_textfield_dialog.dart b/school_data_hub_flutter/lib/common/widgets/dialogs/long_textfield_dialog.dart index a44ce9fb..85f2b81b 100644 --- a/school_data_hub_flutter/lib/common/widgets/dialogs/long_textfield_dialog.dart +++ b/school_data_hub_flutter/lib/common/widgets/dialogs/long_textfield_dialog.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:school_data_hub_flutter/common/theme/styles.dart'; -Future longTextFieldDialog({ +Future<({String? value})?> longTextFieldDialog({ required String title, required String? initialValue, required String labelText, @@ -61,36 +61,32 @@ Future longTextFieldDialog({ ), ), ), - // initialValue != null - // ? Padding( - // padding: const EdgeInsets.all(5.0), - // child: ElevatedButton( - // style: AppStyles.actionButtonStyle, - // onPressed: () { - // textEditingController.dispose(); - // Navigator.of(parentContext).pop(null); - // return; - // }, // Add onPressed - // child: const Text( - // "LÖSCHEN", - // style: AppStyles.buttonTextStyle, - // ), - // ), - // ) - // : const SizedBox.shrink(), + initialValue != null + ? Padding( + padding: const EdgeInsets.all(5.0), + child: ElevatedButton( + style: AppStyles.actionButtonStyle, + onPressed: () { + textEditingController.dispose(); + Navigator.of(parentContext).pop((value: null)); + return; + }, // Add onPressed + child: const Text( + "LÖSCHEN", + style: AppStyles.buttonTextStyle, + ), + ), + ) + : const SizedBox.shrink(), Padding( padding: const EdgeInsets.all(5.0), child: ElevatedButton( style: AppStyles.successButtonStyle, onPressed: () { - String? newSpecialInformation = textEditingController.text; - - if (newSpecialInformation.isEmpty) { - return; - } + String? newPropertyValue = textEditingController.text; textEditingController.dispose(); - Navigator.of(parentContext).pop(newSpecialInformation); + Navigator.of(parentContext).pop((value: newPropertyValue)); }, // Add onPressed child: const Text("OK", style: AppStyles.buttonTextStyle), ), diff --git a/school_data_hub_flutter/lib/features/_attendance/presentation/attendance_page/widgets/atendance_list_card.dart b/school_data_hub_flutter/lib/features/_attendance/presentation/attendance_page/widgets/atendance_list_card.dart index e5deaadf..77ea429d 100644 --- a/school_data_hub_flutter/lib/features/_attendance/presentation/attendance_page/widgets/atendance_list_card.dart +++ b/school_data_hub_flutter/lib/features/_attendance/presentation/attendance_page/widgets/atendance_list_card.dart @@ -374,21 +374,19 @@ class AttendanceCard extends WatchingWidget { Expanded( child: InkWell( onTap: () async { - final String? commentValue = - await longTextFieldDialog( - title: 'Kommentar eintragen', - labelText: 'Kommentar', - initialValue: null, - parentContext: context, - ); - if (commentValue == null || - commentValue.isEmpty || - commentValue == attendanceInfo.commentValue) { + final result = await longTextFieldDialog( + title: 'Kommentar eintragen', + labelText: 'Kommentar', + initialValue: null, + parentContext: context, + ); + if (result == null || + result.value == attendanceInfo.commentValue) { return; } _attendanceManager.updateCommentValue( pupil.pupilId, - commentValue, + result.value, thisDate, ); }, @@ -777,19 +775,20 @@ class AttendanceCard extends WatchingWidget { Expanded( child: InkWell( onTap: () async { - final String? commentValue = await longTextFieldDialog( + final result = await longTextFieldDialog( title: 'Kommentar', labelText: 'Kommentar', initialValue: attendanceInfo.commentValue, parentContext: context, ); - if (commentValue == attendanceInfo.commentValue) { + if (result == null || + result.value == attendanceInfo.commentValue) { return; } _attendanceManager.updateCommentValue( pupil.pupilId, - commentValue ?? '', + result.value, thisDate, ); }, diff --git a/school_data_hub_flutter/lib/features/authorizations/presentation/authorization_pupils_page/widgets/authorization_pupil_card.dart b/school_data_hub_flutter/lib/features/authorizations/presentation/authorization_pupils_page/widgets/authorization_pupil_card.dart index 761ef94f..4c233d29 100644 --- a/school_data_hub_flutter/lib/features/authorizations/presentation/authorization_pupils_page/widgets/authorization_pupil_card.dart +++ b/school_data_hub_flutter/lib/features/authorizations/presentation/authorization_pupils_page/widgets/authorization_pupil_card.dart @@ -224,22 +224,23 @@ class AuthorizationPupilCard extends WatchingWidget { Expanded( child: InkWell( onTap: () async { - final String? authorizationComment = - await longTextFieldDialog( - title: 'Kommentar ändern', - labelText: 'Kommentar', - initialValue: pupilAuthorization.comment, - parentContext: context, - ); - if (authorizationComment == null) return; - if (authorizationComment == '') return; + final result = await longTextFieldDialog( + title: 'Kommentar ändern', + labelText: 'Kommentar', + initialValue: pupilAuthorization.comment, + parentContext: context, + ); + if (result == null || + result.value == pupilAuthorization.comment || + result.value == '') { + return; + } + await di().updatePupilAuthorization( pupilId: pupil.pupilId, authorizationId: authorization.id!, status: null, - comment: authorizationComment == '' - ? null - : authorizationComment, + comment: result.value, ); }, child: Text( diff --git a/school_data_hub_flutter/lib/features/books/presentation/book_infos_page/book_infos_page.dart b/school_data_hub_flutter/lib/features/books/presentation/book_infos_page/book_infos_page.dart index e4d4a744..783004e2 100644 --- a/school_data_hub_flutter/lib/features/books/presentation/book_infos_page/book_infos_page.dart +++ b/school_data_hub_flutter/lib/features/books/presentation/book_infos_page/book_infos_page.dart @@ -176,22 +176,24 @@ class _BookInfosPageState extends State { const Gap(8), InkWell( onTap: () async { - final String? description = await longTextFieldDialog( + final result = await longTextFieldDialog( title: 'Beschreibung', labelText: 'Beschreibung', initialValue: bookProxy.description, parentContext: context, ); - if (description != null && - description != bookProxy.description) { - await di().updateLibraryBookAndBookProperties( - isbn: bookProxy.isbn, - libraryId: bookProxy.libraryId, - description: description, - ); - _loadBook(); // Reload to reflect changes + if (result == null || result.value == bookProxy.description) { + return; } + + await di().updateLibraryBookAndBookProperties( + isbn: bookProxy.isbn, + libraryId: bookProxy.libraryId, + description: result.value, + ); + _loadBook(); // Reload to reflect changes }, + child: Text( bookProxy.description.isNotEmpty ? bookProxy.description diff --git a/school_data_hub_flutter/lib/features/books/presentation/book_list_page/widgets/book_card.dart b/school_data_hub_flutter/lib/features/books/presentation/book_list_page/widgets/book_card.dart index a66b04f8..5fd80f80 100644 --- a/school_data_hub_flutter/lib/features/books/presentation/book_list_page/widgets/book_card.dart +++ b/school_data_hub_flutter/lib/features/books/presentation/book_list_page/widgets/book_card.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:gap/gap.dart'; import 'package:school_data_hub_client/school_data_hub_client.dart'; +import 'package:school_data_hub_flutter/app_utils/create_and_crop_image_file.dart'; import 'package:school_data_hub_flutter/app_utils/extensions/isbn_extensions.dart'; import 'package:school_data_hub_flutter/common/theme/app_colors.dart'; import 'package:school_data_hub_flutter/common/theme/styles.dart'; @@ -10,7 +11,6 @@ import 'package:school_data_hub_flutter/common/widgets/dialogs/confirmation_dial import 'package:school_data_hub_flutter/common/widgets/dialogs/information_dialog.dart'; import 'package:school_data_hub_flutter/common/widgets/dialogs/long_textfield_dialog.dart'; import 'package:school_data_hub_flutter/common/widgets/unencrypted_image_in_card.dart'; -import 'package:school_data_hub_flutter/app_utils/create_and_crop_image_file.dart'; import 'package:school_data_hub_flutter/core/session/hub_session_manager.dart'; import 'package:school_data_hub_flutter/features/books/domain/book_helper.dart'; import 'package:school_data_hub_flutter/features/books/domain/book_manager.dart'; @@ -233,16 +233,20 @@ class BookCard extends WatchingWidget { children: [ InkWell( onTap: () async { - final String? description = await longTextFieldDialog( + final result = await longTextFieldDialog( title: 'Beschreibung', labelText: 'Beschreibung', initialValue: bookProxy.description, parentContext: context, ); + if (result == null || + result.value == bookProxy.description) { + return; + } di().updateLibraryBookAndBookProperties( isbn: bookProxy.isbn, libraryId: bookProxy.libraryId, - description: description, + description: result.value, ); }, child: Text( diff --git a/school_data_hub_flutter/lib/features/books/presentation/book_search_page/book_search_result_card.dart b/school_data_hub_flutter/lib/features/books/presentation/book_search_page/book_search_result_card.dart index b3a8d3ff..f9f3e077 100644 --- a/school_data_hub_flutter/lib/features/books/presentation/book_search_page/book_search_result_card.dart +++ b/school_data_hub_flutter/lib/features/books/presentation/book_search_page/book_search_result_card.dart @@ -183,16 +183,20 @@ class SearchResultBookCard extends WatchingWidget { children: [ InkWell( onTap: () async { - final String? description = await longTextFieldDialog( + final result = await longTextFieldDialog( title: 'Beschreibung', labelText: 'Beschreibung', initialValue: bookProxy.description, parentContext: context, ); + if (result == null || + result.value == bookProxy.description) { + return; + } di().updateLibraryBookAndBookProperties( isbn: bookProxy.isbn, libraryId: bookProxy.libraryId, - description: description, + description: result.value, ); }, child: Text( diff --git a/school_data_hub_flutter/lib/features/books/presentation/widgets/pupil_book_card.dart b/school_data_hub_flutter/lib/features/books/presentation/widgets/pupil_book_card.dart index 764c0f95..8fa9bad6 100644 --- a/school_data_hub_flutter/lib/features/books/presentation/widgets/pupil_book_card.dart +++ b/school_data_hub_flutter/lib/features/books/presentation/widgets/pupil_book_card.dart @@ -187,16 +187,19 @@ class PupilBookLendingCard extends StatelessWidget { ), InkWell( onTap: () async { - final status = await longTextFieldDialog( + final result = await longTextFieldDialog( title: 'Status', labelText: 'Status', initialValue: pupilBookLending.status ?? '', parentContext: context, ); - if (status == null) return; + if (result == null || + result.value == pupilBookLending.status) { + return; + } await di().updatePupilBookLending( pupilBookLending: pupilBookLending, - status: (value: status), + status: (value: result.value), ); }, borderRadius: BorderRadius.circular(8), diff --git a/school_data_hub_flutter/lib/features/learning/presentation/multi_pupil_competence_check_page/widgets/multi_pupil_competence_check_card.dart b/school_data_hub_flutter/lib/features/learning/presentation/multi_pupil_competence_check_page/widgets/multi_pupil_competence_check_card.dart index 173e38a8..d470d560 100644 --- a/school_data_hub_flutter/lib/features/learning/presentation/multi_pupil_competence_check_page/widgets/multi_pupil_competence_check_card.dart +++ b/school_data_hub_flutter/lib/features/learning/presentation/multi_pupil_competence_check_page/widgets/multi_pupil_competence_check_card.dart @@ -3,12 +3,12 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:gap/gap.dart'; import 'package:school_data_hub_client/school_data_hub_client.dart'; +import 'package:school_data_hub_flutter/app_utils/create_and_crop_image_file.dart'; import 'package:school_data_hub_flutter/common/theme/app_colors.dart'; import 'package:school_data_hub_flutter/common/widgets/dialogs/confirmation_dialog.dart'; import 'package:school_data_hub_flutter/common/widgets/dialogs/long_textfield_dialog.dart'; import 'package:school_data_hub_flutter/common/widgets/encrypted_document_image.dart'; import 'package:school_data_hub_flutter/common/widgets/growth_dropdown.dart'; -import 'package:school_data_hub_flutter/app_utils/create_and_crop_image_file.dart'; import 'package:school_data_hub_flutter/core/session/hub_session_helper.dart'; import 'package:school_data_hub_flutter/features/app_main_navigation/domain/main_menu_bottom_nav_manager.dart'; import 'package:school_data_hub_flutter/features/learning/domain/competence_helper.dart'; @@ -288,18 +288,20 @@ class MultiPupilCompetenceCheckCard extends WatchingWidget { InkWell( onTap: () async { if (SessionHelper.isAuthorized(competenceCheck.createdBy)) { - final String? comment = await longTextFieldDialog( + final result = await longTextFieldDialog( parentContext: context, title: 'Kommentar', labelText: 'Kommentar eingeben', initialValue: competenceCheck.comment, ); - if (comment != null) { - await di().updateCompetenceCheck( - competenceCheckId: competenceCheck.checkId, - competenceComment: (value: comment), - ); + if (result == null || + result.value == competenceCheck.comment) { + return; } + await di().updateCompetenceCheck( + competenceCheckId: competenceCheck.checkId, + competenceComment: (value: result.value), + ); } }, child: Text( @@ -318,18 +320,20 @@ class MultiPupilCompetenceCheckCard extends WatchingWidget { if (SessionHelper.isAuthorized( competenceCheck.createdBy, )) { - final String? comment = await longTextFieldDialog( + final result = await longTextFieldDialog( parentContext: context, title: 'Kommentar', labelText: 'Kommentar eingeben', initialValue: competenceCheck.comment, ); - if (comment != null) { - await di().updateCompetenceCheck( - competenceCheckId: competenceCheck.checkId, - competenceComment: (value: comment), - ); + if (result == null || + result.value == competenceCheck.comment) { + return; } + await di().updateCompetenceCheck( + competenceCheckId: competenceCheck.checkId, + competenceComment: (value: result.value), + ); } }, child: Text( diff --git a/school_data_hub_flutter/lib/features/learning/presentation/pupil_competence_list_page/widgets/pupil_competence_checks/competence_check_card.dart b/school_data_hub_flutter/lib/features/learning/presentation/pupil_competence_list_page/widgets/pupil_competence_checks/competence_check_card.dart index 15b0a0d8..6fdf514b 100644 --- a/school_data_hub_flutter/lib/features/learning/presentation/pupil_competence_list_page/widgets/pupil_competence_checks/competence_check_card.dart +++ b/school_data_hub_flutter/lib/features/learning/presentation/pupil_competence_list_page/widgets/pupil_competence_checks/competence_check_card.dart @@ -3,7 +3,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:gap/gap.dart'; import 'package:school_data_hub_client/school_data_hub_client.dart'; -import 'package:school_data_hub_flutter/core/models/datetime_extensions.dart'; +import 'package:school_data_hub_flutter/app_utils/create_and_crop_image_file.dart'; import 'package:school_data_hub_flutter/common/services/notification_service.dart'; import 'package:school_data_hub_flutter/common/theme/app_colors.dart'; import 'package:school_data_hub_flutter/common/widgets/dialogs/confirmation_dialog.dart'; @@ -13,7 +13,7 @@ import 'package:school_data_hub_flutter/common/widgets/dialogs/schoolday_date_pi import 'package:school_data_hub_flutter/common/widgets/dialogs/short_textfield_dialog.dart'; import 'package:school_data_hub_flutter/common/widgets/encrypted_document_image.dart'; import 'package:school_data_hub_flutter/common/widgets/growth_dropdown.dart'; -import 'package:school_data_hub_flutter/app_utils/create_and_crop_image_file.dart'; +import 'package:school_data_hub_flutter/core/models/datetime_extensions.dart'; import 'package:school_data_hub_flutter/core/session/hub_session_helper.dart'; import 'package:school_data_hub_flutter/features/learning/domain/competence_helper.dart'; import 'package:school_data_hub_flutter/features/learning/domain/competence_manager.dart'; @@ -370,18 +370,21 @@ class CompetenceCheckCard extends StatelessWidget { InkWell( onTap: () async { if (isAuthorized) { - final String? comment = await longTextFieldDialog( + final result = await longTextFieldDialog( parentContext: context, title: 'Status', labelText: 'Status eingeben', initialValue: competenceCheck.comment, ); - if (comment != null) { - await di().updateCompetenceCheck( - competenceCheckId: competenceCheck.checkId, - competenceComment: (value: comment), - ); + if (result == null || + result.value == competenceCheck.comment) { + return; } + + await di().updateCompetenceCheck( + competenceCheckId: competenceCheck.checkId, + competenceComment: (value: result.value), + ); } }, child: Text( @@ -398,19 +401,21 @@ class CompetenceCheckCard extends StatelessWidget { child: InkWell( onTap: () async { if (isAuthorized) { - final String? comment = await longTextFieldDialog( + final result = await longTextFieldDialog( parentContext: context, title: 'Kommentar', labelText: 'Kommentar eingeben', initialValue: competenceCheck.comment, ); - if (comment != null) { - await di() - .updateCompetenceCheck( - competenceCheckId: competenceCheck.checkId, - competenceComment: (value: comment), - ); + if (result == null || + result.value == competenceCheck.comment) { + return; } + + await di().updateCompetenceCheck( + competenceCheckId: competenceCheck.checkId, + competenceComment: (value: result.value), + ); } }, child: Text( diff --git a/school_data_hub_flutter/lib/features/learning_support/presentation/widgets/support_catagory_status/widgets/support_category_status_entry/support_category_status_entry.dart b/school_data_hub_flutter/lib/features/learning_support/presentation/widgets/support_catagory_status/widgets/support_category_status_entry/support_category_status_entry.dart index 4ff08e4e..78babdf0 100644 --- a/school_data_hub_flutter/lib/features/learning_support/presentation/widgets/support_catagory_status/widgets/support_category_status_entry/support_category_status_entry.dart +++ b/school_data_hub_flutter/lib/features/learning_support/presentation/widgets/support_catagory_status/widgets/support_category_status_entry/support_category_status_entry.dart @@ -109,14 +109,15 @@ class SupportCategoryStatusEntry extends StatelessWidget { authorizedToChangeStatus ? InkWell( onTap: () async { - final String? correctedComment = - await longTextFieldDialog( - title: 'Status korrigieren', - labelText: 'Status', - initialValue: status.comment, - parentContext: context, - ); - if (correctedComment != null) { + final result = await longTextFieldDialog( + title: 'Status korrigieren', + labelText: 'Status', + initialValue: status.comment, + parentContext: context, + ); + if (result == null || + result.value == status.comment) { + return; // TODO: uncomment when ready // _learningSupportManager // .updateSupportCategoryStatusProperty( diff --git a/school_data_hub_flutter/lib/features/matrix/users/domain/matrix_user_manager.dart b/school_data_hub_flutter/lib/features/matrix/users/domain/matrix_user_manager.dart index 2f770301..e895c891 100644 --- a/school_data_hub_flutter/lib/features/matrix/users/domain/matrix_user_manager.dart +++ b/school_data_hub_flutter/lib/features/matrix/users/domain/matrix_user_manager.dart @@ -116,7 +116,7 @@ class MatrixUserManager extends ChangeNotifier { await PupilMutator().updateStringProperty( pupilId: pupil.pupilId, property: 'contact', - value: matrixId, + propertyValue: (value: matrixId), ); } else { // it's a parent related matrix account diff --git a/school_data_hub_flutter/lib/features/matrix/users/presentation/pupil_matrix_contacts_list_page/pupils_matrix_contacts_list_page.dart b/school_data_hub_flutter/lib/features/matrix/users/presentation/pupil_matrix_contacts_list_page/pupils_matrix_contacts_list_page.dart index 94efcfb1..38a1a02c 100644 --- a/school_data_hub_flutter/lib/features/matrix/users/presentation/pupil_matrix_contacts_list_page/pupils_matrix_contacts_list_page.dart +++ b/school_data_hub_flutter/lib/features/matrix/users/presentation/pupil_matrix_contacts_list_page/pupils_matrix_contacts_list_page.dart @@ -15,8 +15,8 @@ import 'package:school_data_hub_flutter/features/matrix/domain/matrix_policy_man import 'package:school_data_hub_flutter/features/matrix/users/presentation/new_matrix_user_page/new_matrix_user_page.dart'; import 'package:school_data_hub_flutter/features/pupil/domain/filters/pupils_filter.dart'; import 'package:school_data_hub_flutter/features/pupil/domain/models/pupil_proxy.dart'; -import 'package:school_data_hub_flutter/features/pupil/domain/pupil_proxy_manager.dart'; import 'package:school_data_hub_flutter/features/pupil/domain/pupil_mutator.dart'; +import 'package:school_data_hub_flutter/features/pupil/domain/pupil_proxy_manager.dart'; import 'package:school_data_hub_flutter/features/pupil/presentation/_credit/credit_list_page/widgets/credit_list_page_bottom_navbar.dart'; import 'package:school_data_hub_flutter/features/pupil/presentation/_credit/credit_list_page/widgets/credit_list_searchbar.dart'; import 'package:school_data_hub_flutter/features/pupil/presentation/pupil_profile_page/pupil_profile_page.dart'; @@ -163,20 +163,25 @@ class PupilsMatrixContactsListPage extends WatchingWidget { } }, onLongPress: () async { - final String? contact = + final result = await longTextFieldDialog( title: 'Kontakt', labelText: 'Kontakt', initialValue: pupil.contact, parentContext: context, ); - if (contact == null) return; + if (result == null || + result.value == pupil.contact) { + return; + } await PupilMutator() .updateStringProperty( pupilId: pupil.pupilId, property: 'contact', - value: contact, + propertyValue: ( + value: result.value, + ), ); }, child: Text( @@ -285,7 +290,7 @@ class PupilsMatrixContactsListPage extends WatchingWidget { } }, onLongPress: () async { - final String? tutorContact = + final result = await longTextFieldDialog( title: 'Elternkontakt', labelText: 'Elternkontakt', @@ -294,12 +299,18 @@ class PupilsMatrixContactsListPage extends WatchingWidget { ?.parentsContact, parentContext: context, ); - if (tutorContact == null) return; + if (result == null || + result.value == + pupil + .tutorInfo + ?.parentsContact) { + return; + } final TutorInfo? tutorInfo = pupil.tutorInfo == null ? TutorInfo( parentsContact: - '@$tutorContact', + '@${result.value}', createdBy: di() .signedInUser! @@ -307,7 +318,7 @@ class PupilsMatrixContactsListPage extends WatchingWidget { ) : pupil.tutorInfo!.copyWith( parentsContact: - '@$tutorContact', + '@${result.value}', ); await PupilMutator() .updateTutorInfo( diff --git a/school_data_hub_flutter/lib/features/pupil/data/pupil_data_api_service.dart b/school_data_hub_flutter/lib/features/pupil/data/pupil_data_api_service.dart index 5b5663a1..6f0253e4 100644 --- a/school_data_hub_flutter/lib/features/pupil/data/pupil_data_api_service.dart +++ b/school_data_hub_flutter/lib/features/pupil/data/pupil_data_api_service.dart @@ -87,11 +87,14 @@ class PupilDataApiService { Future updateStringProperty({ required int pupilId, required String property, - required String? value, + required ({String? value}) propertyValue, }) async { final updatedPupil = await ClientHelper.apiCall( - call: () => - _client.pupilUpdate.updateStringProperty(pupilId, property, value), + call: () => _client.pupilUpdate.updateStringProperty( + pupilId, + property, + propertyValue, + ), errorMessage: 'Die Schüler konnten nicht aktualisiert werden', ); return updatedPupil; diff --git a/school_data_hub_flutter/lib/features/pupil/domain/pupil_mutator.dart b/school_data_hub_flutter/lib/features/pupil/domain/pupil_mutator.dart index 41861e57..ab75f8a4 100644 --- a/school_data_hub_flutter/lib/features/pupil/domain/pupil_mutator.dart +++ b/school_data_hub_flutter/lib/features/pupil/domain/pupil_mutator.dart @@ -28,13 +28,13 @@ class PupilMutator { Future updateStringProperty({ required int pupilId, required String property, - required String? value, + required ({String? value}) propertyValue, }) async { final PupilData? pupilData = await _pupilDataApiService .updateStringProperty( pupilId: pupilId, property: property, - value: value, + propertyValue: propertyValue, ); if (pupilData == null) { return; diff --git a/school_data_hub_flutter/lib/features/pupil/presentation/after_school_care/widgets/after_school_care_details.dart b/school_data_hub_flutter/lib/features/pupil/presentation/after_school_care/widgets/after_school_care_details.dart index 87be2059..865f041c 100644 --- a/school_data_hub_flutter/lib/features/pupil/presentation/after_school_care/widgets/after_school_care_details.dart +++ b/school_data_hub_flutter/lib/features/pupil/presentation/after_school_care/widgets/after_school_care_details.dart @@ -502,16 +502,18 @@ class _OgsInfoCard extends StatelessWidget { const _OgsInfoCard({required this.pupil, required this.afterSchoolCare}); Future _editInfo(BuildContext context) async { - final String? ogsInfo = await longTextFieldDialog( + final result = await longTextFieldDialog( title: 'OGS Informationen', labelText: 'OGS Informationen', initialValue: afterSchoolCare.afterSchoolCareInfo ?? '', parentContext: context, ); - if (ogsInfo == null) return; + if (result == null || result.value == afterSchoolCare.afterSchoolCareInfo) { + return; + } await PupilMutator().updateAfterSchoolCare( pupilId: pupil.pupilId, - afterSchoolCareInfo: (value: ogsInfo), + afterSchoolCareInfo: (value: result.value), ); } diff --git a/school_data_hub_flutter/lib/features/pupil/presentation/after_school_care/widgets/pupil_after_school_care_content_list.dart b/school_data_hub_flutter/lib/features/pupil/presentation/after_school_care/widgets/pupil_after_school_care_content_list.dart index 7048d1f4..d8f8ada5 100644 --- a/school_data_hub_flutter/lib/features/pupil/presentation/after_school_care/widgets/pupil_after_school_care_content_list.dart +++ b/school_data_hub_flutter/lib/features/pupil/presentation/after_school_care/widgets/pupil_after_school_care_content_list.dart @@ -49,17 +49,19 @@ List pupilAfterSchoolCareContentList( const Gap(5), InkWell( onTap: () async { - final String? ogsInfo = await longTextFieldDialog( + final result = await longTextFieldDialog( title: 'OGS Informationen', labelText: 'OGS Informationen', initialValue: pupil.afterSchoolCareInfo, parentContext: context, ); - if (ogsInfo == null) return; + if (result == null || result.value == pupil.afterSchoolCareInfo) { + return; + } await PupilMutator().updateStringProperty( pupilId: pupil.internalId, property: 'afterSchoolCareInfo', - value: ogsInfo, + propertyValue: (value: result.value), ); }, onLongPress: () async { @@ -73,7 +75,7 @@ List pupilAfterSchoolCareContentList( await PupilMutator().updateStringProperty( pupilId: pupil.internalId, property: 'afterSchoolCareInfo', - value: null, + propertyValue: (value: null), ); }, child: Row( diff --git a/school_data_hub_flutter/lib/features/pupil/presentation/pupil_profile_page/widgets/pupil_profile_page_content/authorization_content/pupil_content_authorization_entry_card.dart b/school_data_hub_flutter/lib/features/pupil/presentation/pupil_profile_page/widgets/pupil_profile_page_content/authorization_content/pupil_content_authorization_entry_card.dart index 25b7273b..7a6bfb6c 100644 --- a/school_data_hub_flutter/lib/features/pupil/presentation/pupil_profile_page/widgets/pupil_profile_page_content/authorization_content/pupil_content_authorization_entry_card.dart +++ b/school_data_hub_flutter/lib/features/pupil/presentation/pupil_profile_page/widgets/pupil_profile_page_content/authorization_content/pupil_content_authorization_entry_card.dart @@ -3,12 +3,12 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:gap/gap.dart'; import 'package:school_data_hub_client/school_data_hub_client.dart'; +import 'package:school_data_hub_flutter/app_utils/create_and_crop_image_file.dart'; import 'package:school_data_hub_flutter/common/theme/app_colors.dart'; import 'package:school_data_hub_flutter/common/widgets/custom_checkbox_either_or.dart'; import 'package:school_data_hub_flutter/common/widgets/dialogs/confirmation_dialog.dart'; import 'package:school_data_hub_flutter/common/widgets/dialogs/long_textfield_dialog.dart'; import 'package:school_data_hub_flutter/common/widgets/encrypted_document_image.dart'; -import 'package:school_data_hub_flutter/app_utils/create_and_crop_image_file.dart'; import 'package:school_data_hub_flutter/features/authorizations/domain/authorization_manager.dart'; import 'package:school_data_hub_flutter/features/authorizations/presentation/authorization_pupils_page/authorization_pupils_page.dart'; import 'package:school_data_hub_flutter/features/pupil/domain/models/pupil_proxy.dart'; @@ -218,24 +218,21 @@ class PupilContentAuthorizationEntryCard extends WatchingWidget { Flexible( child: InkWell( onTap: () async { - final String? authorizationComment = - await longTextFieldDialog( - title: 'Kommentar', - labelText: 'Kommentar eintragen', - initialValue: - pupilAuthorization.comment ?? '', - parentContext: context, - ); - if (authorizationComment == null) { + final result = await longTextFieldDialog( + title: 'Kommentar', + labelText: 'Kommentar eintragen', + initialValue: pupilAuthorization.comment ?? '', + parentContext: context, + ); + if (result == null || + result.value == pupilAuthorization.comment) { return; } await di() .updatePupilAuthorization( pupilId: pupil.pupilId, authorizationId: authorization.id!, - comment: authorizationComment == '' - ? null - : authorizationComment, + comment: result.value, ); }, child: Text( diff --git a/school_data_hub_flutter/lib/features/pupil/presentation/pupil_profile_page/widgets/pupil_profile_page_content/infos_content/pupil_profile_infos_content.dart b/school_data_hub_flutter/lib/features/pupil/presentation/pupil_profile_page/widgets/pupil_profile_page_content/infos_content/pupil_profile_infos_content.dart index c1bef6c7..fbe0f087 100644 --- a/school_data_hub_flutter/lib/features/pupil/presentation/pupil_profile_page/widgets/pupil_profile_page_content/infos_content/pupil_profile_infos_content.dart +++ b/school_data_hub_flutter/lib/features/pupil/presentation/pupil_profile_page/widgets/pupil_profile_page_content/infos_content/pupil_profile_infos_content.dart @@ -55,17 +55,20 @@ class PupilProfileInfosContent extends WatchingWidget { title: 'Besondere Infos', child: InkWell( onTap: () async { - final String? specialInformation = await longTextFieldDialog( + final result = await longTextFieldDialog( title: 'Besondere Infos', labelText: 'Besondere Infos', initialValue: pupil.specialInformation ?? '', parentContext: context, ); - if (specialInformation == null) return; + if (result == null || + result.value == pupil.specialInformation) { + return; + } await PupilMutator().updateStringProperty( pupilId: pupil.pupilId, property: 'specialInformation', - value: specialInformation, + propertyValue: (value: result.value), ); }, onLongPress: () async { @@ -79,7 +82,7 @@ class PupilProfileInfosContent extends WatchingWidget { await PupilMutator().updateStringProperty( pupilId: pupil.pupilId, property: 'specialInformation', - value: null, + propertyValue: (value: null), ); }, child: Container( @@ -178,7 +181,7 @@ class PupilProfileInfosContent extends WatchingWidget { await PupilMutator().updateStringProperty( pupilId: pupil.pupilId, property: 'contact', - value: contact, + propertyValue: (value: contact), ); }, actionButton: diff --git a/school_data_hub_flutter/lib/features/pupil/presentation/pupil_profile_page/widgets/pupil_profile_page_content/learning_support_content/pupil_profile_learning_support_content_list.dart b/school_data_hub_flutter/lib/features/pupil/presentation/pupil_profile_page/widgets/pupil_profile_page_content/learning_support_content/pupil_profile_learning_support_content_list.dart index db464170..4031bad5 100644 --- a/school_data_hub_flutter/lib/features/pupil/presentation/pupil_profile_page/widgets/pupil_profile_page_content/learning_support_content/pupil_profile_learning_support_content_list.dart +++ b/school_data_hub_flutter/lib/features/pupil/presentation/pupil_profile_page/widgets/pupil_profile_page_content/learning_support_content/pupil_profile_learning_support_content_list.dart @@ -190,20 +190,21 @@ class PupilProfileLearningSupportContentList extends WatchingWidget { InkWell( //- TODO: implement long text field dialog onTap: () async { - final newKindergardenValue = await longTextFieldDialog( + final result = await longTextFieldDialog( title: 'Informationen zum Kindergartenbesuch', labelText: 'Kindergartenbesuch', initialValue: kindergarden?.name ?? 'Kein Eintrag', parentContext: context, ); - if (newKindergardenValue == null || - newKindergardenValue.isEmpty) { + if (result == null || + result.value == kindergarden?.name || + result.value!.isEmpty) { return; } await di().updateStringProperty( pupilId: pupil.pupilId, property: 'kindergarden', - value: newKindergardenValue, + propertyValue: (value: result.value), ); }, child: Text( diff --git a/school_data_hub_flutter/lib/features/pupil/presentation/pupil_profile_page/widgets/pupil_profile_page_content/school_list_content/widgets/pupil_profile_school_list_pupil_entry_card.dart b/school_data_hub_flutter/lib/features/pupil/presentation/pupil_profile_page/widgets/pupil_profile_page_content/school_list_content/widgets/pupil_profile_school_list_pupil_entry_card.dart index c744918c..528d32c4 100644 --- a/school_data_hub_flutter/lib/features/pupil/presentation/pupil_profile_page/widgets/pupil_profile_page_content/school_list_content/widgets/pupil_profile_school_list_pupil_entry_card.dart +++ b/school_data_hub_flutter/lib/features/pupil/presentation/pupil_profile_page/widgets/pupil_profile_page_content/school_list_content/widgets/pupil_profile_school_list_pupil_entry_card.dart @@ -155,18 +155,19 @@ class PupilProfileSchoolListPupilEntryCard extends WatchingWidget { Flexible( child: InkWell( onTap: () async { - final String? comment = await longTextFieldDialog( + final result = await longTextFieldDialog( title: 'Kommentar', initialValue: pupilListEntry.comment ?? '', labelText: 'Kommentar eintragen', parentContext: context, ); - if (comment == null) { + if (result == null || + result.value == pupilListEntry.comment) { return; } await _schoolListManager.updatePupilListEntry( entry: pupilListEntry, - comment: (value: comment), + comment: (value: result.value), ); }, child: Text( diff --git a/school_data_hub_flutter/lib/features/school_lists/presentation/school_list_pupil_entries_page/widgets/school_list_pupil_entry_card.dart b/school_data_hub_flutter/lib/features/school_lists/presentation/school_list_pupil_entries_page/widgets/school_list_pupil_entry_card.dart index becfe75d..f4230e1b 100644 --- a/school_data_hub_flutter/lib/features/school_lists/presentation/school_list_pupil_entries_page/widgets/school_list_pupil_entry_card.dart +++ b/school_data_hub_flutter/lib/features/school_lists/presentation/school_list_pupil_entries_page/widgets/school_list_pupil_entry_card.dart @@ -115,18 +115,19 @@ class SchoolListPupilEntryCard extends WatchingWidget { const Gap(5), InkWell( onTap: () async { - final listComment = await longTextFieldDialog( + final result = await longTextFieldDialog( title: 'Kommentar ändern', labelText: 'Kommentar', initialValue: pupilEntry.comment ?? '', parentContext: context, ); - if (listComment == null) { + if (result == null || + result.value == pupilEntry.comment) { return; } await _schoolListManager.updatePupilListEntry( entry: pupilEntry, - comment: (value: listComment), + comment: (value: result.value), ); }, onLongPress: () async { diff --git a/school_data_hub_flutter/lib/features/workbooks/presentation/workbook_list_page/widgets/pupil_workbook_card.dart b/school_data_hub_flutter/lib/features/workbooks/presentation/workbook_list_page/widgets/pupil_workbook_card.dart index 8be2c1b6..c32515cb 100644 --- a/school_data_hub_flutter/lib/features/workbooks/presentation/workbook_list_page/widgets/pupil_workbook_card.dart +++ b/school_data_hub_flutter/lib/features/workbooks/presentation/workbook_list_page/widgets/pupil_workbook_card.dart @@ -285,16 +285,19 @@ class PupilWorkbookCard extends WatchingWidget { const Gap(5), InkWell( onTap: () async { - final comment = await longTextFieldDialog( + final result = await longTextFieldDialog( title: 'Kommentar', initialValue: pupilWorkbook.comment ?? '', labelText: 'Kommentar eintragen', parentContext: context, ); - if (comment == null) return; + if (result == null || + result.value == pupilWorkbook.comment) { + return; + } di().updatePupilWorkbook( pupilWorkbook: pupilWorkbook, - comment: (value: comment), + comment: (value: result.value), ); }, child: Text( diff --git a/school_data_hub_server/lib/src/_features/pupil/endpooints/pupil_update_endpoint.dart b/school_data_hub_server/lib/src/_features/pupil/endpooints/pupil_update_endpoint.dart index 6afcebd2..03c9a951 100644 --- a/school_data_hub_server/lib/src/_features/pupil/endpooints/pupil_update_endpoint.dart +++ b/school_data_hub_server/lib/src/_features/pupil/endpooints/pupil_update_endpoint.dart @@ -221,8 +221,8 @@ class PupilUpdateEndpoint extends Endpoint { return updatedPupil; } - Future updateStringProperty( - Session session, int pupilId, String property, String? value) async { + Future updateStringProperty(Session session, int pupilId, + String property, ({String? value})? propertyValue) async { final pupil = await PupilData.db .findById(session, pupilId, include: PupilSchemas.allInclude); if (pupil == null) { @@ -230,13 +230,13 @@ class PupilUpdateEndpoint extends Endpoint { } switch (property) { case 'contact': - pupil.contact = value; + pupil.contact = propertyValue?.value; break; case 'specialInformation': - pupil.specialInformation = value; + pupil.specialInformation = propertyValue?.value; break; case 'swimmer': - pupil.swimmer = value; + pupil.swimmer = propertyValue?.value; break; default: throw Exception('Invalid property name'); diff --git a/school_data_hub_server/lib/src/generated/endpoints.dart b/school_data_hub_server/lib/src/generated/endpoints.dart index bce53137..50c2100b 100644 --- a/school_data_hub_server/lib/src/generated/endpoints.dart +++ b/school_data_hub_server/lib/src/generated/endpoints.dart @@ -3064,9 +3064,9 @@ class Endpoints extends _i1.EndpointDispatch { type: _i1.getType(), nullable: false, ), - 'value': _i1.ParameterDescription( - name: 'value', - type: _i1.getType(), + 'propertyValue': _i1.ParameterDescription( + name: 'propertyValue', + type: _i1.getType<({String? value})?>(), nullable: true, ), }, @@ -3079,7 +3079,7 @@ class Endpoints extends _i1.EndpointDispatch { session, params['pupilId'], params['property'], - params['value'], + params['propertyValue'], ), ), 'updateCredit': _i1.MethodConnector( diff --git a/school_data_hub_server/test/integration/test_tools/serverpod_test_tools.dart b/school_data_hub_server/test/integration/test_tools/serverpod_test_tools.dart index 075183d2..48786df3 100644 --- a/school_data_hub_server/test/integration/test_tools/serverpod_test_tools.dart +++ b/school_data_hub_server/test/integration/test_tools/serverpod_test_tools.dart @@ -4172,7 +4172,7 @@ class _PupilUpdateEndpoint { _i1.TestSessionBuilder sessionBuilder, int pupilId, String property, - String? value, + ({String? value})? propertyValue, ) async { return _i1.callAwaitableFunctionAndHandleExceptions(() async { var _localUniqueSession = @@ -4188,7 +4188,7 @@ class _PupilUpdateEndpoint { parameters: _i1.testObjectToJson({ 'pupilId': pupilId, 'property': property, - 'value': value, + 'propertyValue': _i15.mapRecordToJson(propertyValue), }), serializationManager: _serializationManager, );