Skip to content

Commit 0a69cdd

Browse files
Merge pull request #24 from dabblingwithcode/staging
client, server: add delete option to long textfield dialog
2 parents e74a7b7 + 9b18fe6 commit 0a69cdd

26 files changed

Lines changed: 211 additions & 168 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
@@ -1459,15 +1459,15 @@ class EndpointPupilUpdate extends _i1.EndpointRef {
14591459
_i2.Future<_i5.PupilData> updateStringProperty(
14601460
int pupilId,
14611461
String property,
1462-
String? value,
1462+
({String? value})? propertyValue,
14631463
) =>
14641464
caller.callServerEndpoint<_i5.PupilData>(
14651465
'pupilUpdate',
14661466
'updateStringProperty',
14671467
{
14681468
'pupilId': pupilId,
14691469
'property': property,
1470-
'value': value,
1470+
'propertyValue': _i16.mapRecordToJson(propertyValue),
14711471
},
14721472
);
14731473

school_data_hub_flutter/lib/common/widgets/dialogs/long_textfield_dialog.dart

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:school_data_hub_flutter/common/theme/styles.dart';
33

4-
Future<String?> longTextFieldDialog({
4+
Future<({String? value})?> longTextFieldDialog({
55
required String title,
66
required String? initialValue,
77
required String labelText,
@@ -61,36 +61,32 @@ Future<String?> longTextFieldDialog({
6161
),
6262
),
6363
),
64-
// initialValue != null
65-
// ? Padding(
66-
// padding: const EdgeInsets.all(5.0),
67-
// child: ElevatedButton(
68-
// style: AppStyles.actionButtonStyle,
69-
// onPressed: () {
70-
// textEditingController.dispose();
71-
// Navigator.of(parentContext).pop(null);
72-
// return;
73-
// }, // Add onPressed
74-
// child: const Text(
75-
// "LÖSCHEN",
76-
// style: AppStyles.buttonTextStyle,
77-
// ),
78-
// ),
79-
// )
80-
// : const SizedBox.shrink(),
64+
initialValue != null
65+
? Padding(
66+
padding: const EdgeInsets.all(5.0),
67+
child: ElevatedButton(
68+
style: AppStyles.actionButtonStyle,
69+
onPressed: () {
70+
textEditingController.dispose();
71+
Navigator.of(parentContext).pop((value: null));
72+
return;
73+
}, // Add onPressed
74+
child: const Text(
75+
"LÖSCHEN",
76+
style: AppStyles.buttonTextStyle,
77+
),
78+
),
79+
)
80+
: const SizedBox.shrink(),
8181
Padding(
8282
padding: const EdgeInsets.all(5.0),
8383
child: ElevatedButton(
8484
style: AppStyles.successButtonStyle,
8585
onPressed: () {
86-
String? newSpecialInformation = textEditingController.text;
87-
88-
if (newSpecialInformation.isEmpty) {
89-
return;
90-
}
86+
String? newPropertyValue = textEditingController.text;
9187

9288
textEditingController.dispose();
93-
Navigator.of(parentContext).pop(newSpecialInformation);
89+
Navigator.of(parentContext).pop((value: newPropertyValue));
9490
}, // Add onPressed
9591
child: const Text("OK", style: AppStyles.buttonTextStyle),
9692
),

school_data_hub_flutter/lib/features/_attendance/presentation/attendance_page/widgets/atendance_list_card.dart

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -374,21 +374,19 @@ class AttendanceCard extends WatchingWidget {
374374
Expanded(
375375
child: InkWell(
376376
onTap: () async {
377-
final String? commentValue =
378-
await longTextFieldDialog(
379-
title: 'Kommentar eintragen',
380-
labelText: 'Kommentar',
381-
initialValue: null,
382-
parentContext: context,
383-
);
384-
if (commentValue == null ||
385-
commentValue.isEmpty ||
386-
commentValue == attendanceInfo.commentValue) {
377+
final result = await longTextFieldDialog(
378+
title: 'Kommentar eintragen',
379+
labelText: 'Kommentar',
380+
initialValue: null,
381+
parentContext: context,
382+
);
383+
if (result == null ||
384+
result.value == attendanceInfo.commentValue) {
387385
return;
388386
}
389387
_attendanceManager.updateCommentValue(
390388
pupil.pupilId,
391-
commentValue,
389+
result.value,
392390
thisDate,
393391
);
394392
},
@@ -777,19 +775,20 @@ class AttendanceCard extends WatchingWidget {
777775
Expanded(
778776
child: InkWell(
779777
onTap: () async {
780-
final String? commentValue = await longTextFieldDialog(
778+
final result = await longTextFieldDialog(
781779
title: 'Kommentar',
782780
labelText: 'Kommentar',
783781
initialValue: attendanceInfo.commentValue,
784782
parentContext: context,
785783
);
786-
if (commentValue == attendanceInfo.commentValue) {
784+
if (result == null ||
785+
result.value == attendanceInfo.commentValue) {
787786
return;
788787
}
789788

790789
_attendanceManager.updateCommentValue(
791790
pupil.pupilId,
792-
commentValue ?? '',
791+
result.value,
793792
thisDate,
794793
);
795794
},

school_data_hub_flutter/lib/features/authorizations/presentation/authorization_pupils_page/widgets/authorization_pupil_card.dart

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,22 +224,23 @@ class AuthorizationPupilCard extends WatchingWidget {
224224
Expanded(
225225
child: InkWell(
226226
onTap: () async {
227-
final String? authorizationComment =
228-
await longTextFieldDialog(
229-
title: 'Kommentar ändern',
230-
labelText: 'Kommentar',
231-
initialValue: pupilAuthorization.comment,
232-
parentContext: context,
233-
);
234-
if (authorizationComment == null) return;
235-
if (authorizationComment == '') return;
227+
final result = await longTextFieldDialog(
228+
title: 'Kommentar ändern',
229+
labelText: 'Kommentar',
230+
initialValue: pupilAuthorization.comment,
231+
parentContext: context,
232+
);
233+
if (result == null ||
234+
result.value == pupilAuthorization.comment ||
235+
result.value == '') {
236+
return;
237+
}
238+
236239
await di<AuthorizationManager>().updatePupilAuthorization(
237240
pupilId: pupil.pupilId,
238241
authorizationId: authorization.id!,
239242
status: null,
240-
comment: authorizationComment == ''
241-
? null
242-
: authorizationComment,
243+
comment: result.value,
243244
);
244245
},
245246
child: Text(

school_data_hub_flutter/lib/features/books/presentation/book_infos_page/book_infos_page.dart

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,22 +176,24 @@ class _BookInfosPageState extends State<BookInfosPage> {
176176
const Gap(8),
177177
InkWell(
178178
onTap: () async {
179-
final String? description = await longTextFieldDialog(
179+
final result = await longTextFieldDialog(
180180
title: 'Beschreibung',
181181
labelText: 'Beschreibung',
182182
initialValue: bookProxy.description,
183183
parentContext: context,
184184
);
185-
if (description != null &&
186-
description != bookProxy.description) {
187-
await di<BookManager>().updateLibraryBookAndBookProperties(
188-
isbn: bookProxy.isbn,
189-
libraryId: bookProxy.libraryId,
190-
description: description,
191-
);
192-
_loadBook(); // Reload to reflect changes
185+
if (result == null || result.value == bookProxy.description) {
186+
return;
193187
}
188+
189+
await di<BookManager>().updateLibraryBookAndBookProperties(
190+
isbn: bookProxy.isbn,
191+
libraryId: bookProxy.libraryId,
192+
description: result.value,
193+
);
194+
_loadBook(); // Reload to reflect changes
194195
},
196+
195197
child: Text(
196198
bookProxy.description.isNotEmpty
197199
? bookProxy.description

school_data_hub_flutter/lib/features/books/presentation/book_list_page/widgets/book_card.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import 'dart:io';
33
import 'package:flutter/material.dart';
44
import 'package:gap/gap.dart';
55
import 'package:school_data_hub_client/school_data_hub_client.dart';
6+
import 'package:school_data_hub_flutter/app_utils/create_and_crop_image_file.dart';
67
import 'package:school_data_hub_flutter/app_utils/extensions/isbn_extensions.dart';
78
import 'package:school_data_hub_flutter/common/theme/app_colors.dart';
89
import 'package:school_data_hub_flutter/common/theme/styles.dart';
910
import 'package:school_data_hub_flutter/common/widgets/dialogs/confirmation_dialog.dart';
1011
import 'package:school_data_hub_flutter/common/widgets/dialogs/information_dialog.dart';
1112
import 'package:school_data_hub_flutter/common/widgets/dialogs/long_textfield_dialog.dart';
1213
import 'package:school_data_hub_flutter/common/widgets/unencrypted_image_in_card.dart';
13-
import 'package:school_data_hub_flutter/app_utils/create_and_crop_image_file.dart';
1414
import 'package:school_data_hub_flutter/core/session/hub_session_manager.dart';
1515
import 'package:school_data_hub_flutter/features/books/domain/book_helper.dart';
1616
import 'package:school_data_hub_flutter/features/books/domain/book_manager.dart';
@@ -233,16 +233,20 @@ class BookCard extends WatchingWidget {
233233
children: [
234234
InkWell(
235235
onTap: () async {
236-
final String? description = await longTextFieldDialog(
236+
final result = await longTextFieldDialog(
237237
title: 'Beschreibung',
238238
labelText: 'Beschreibung',
239239
initialValue: bookProxy.description,
240240
parentContext: context,
241241
);
242+
if (result == null ||
243+
result.value == bookProxy.description) {
244+
return;
245+
}
242246
di<BookManager>().updateLibraryBookAndBookProperties(
243247
isbn: bookProxy.isbn,
244248
libraryId: bookProxy.libraryId,
245-
description: description,
249+
description: result.value,
246250
);
247251
},
248252
child: Text(

school_data_hub_flutter/lib/features/books/presentation/book_search_page/book_search_result_card.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,20 @@ class SearchResultBookCard extends WatchingWidget {
183183
children: [
184184
InkWell(
185185
onTap: () async {
186-
final String? description = await longTextFieldDialog(
186+
final result = await longTextFieldDialog(
187187
title: 'Beschreibung',
188188
labelText: 'Beschreibung',
189189
initialValue: bookProxy.description,
190190
parentContext: context,
191191
);
192+
if (result == null ||
193+
result.value == bookProxy.description) {
194+
return;
195+
}
192196
di<BookManager>().updateLibraryBookAndBookProperties(
193197
isbn: bookProxy.isbn,
194198
libraryId: bookProxy.libraryId,
195-
description: description,
199+
description: result.value,
196200
);
197201
},
198202
child: Text(

school_data_hub_flutter/lib/features/books/presentation/widgets/pupil_book_card.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,19 @@ class PupilBookLendingCard extends StatelessWidget {
187187
),
188188
InkWell(
189189
onTap: () async {
190-
final status = await longTextFieldDialog(
190+
final result = await longTextFieldDialog(
191191
title: 'Status',
192192
labelText: 'Status',
193193
initialValue: pupilBookLending.status ?? '',
194194
parentContext: context,
195195
);
196-
if (status == null) return;
196+
if (result == null ||
197+
result.value == pupilBookLending.status) {
198+
return;
199+
}
197200
await di<PupilProxyManager>().updatePupilBookLending(
198201
pupilBookLending: pupilBookLending,
199-
status: (value: status),
202+
status: (value: result.value),
200203
);
201204
},
202205
borderRadius: BorderRadius.circular(8),

school_data_hub_flutter/lib/features/learning/presentation/multi_pupil_competence_check_page/widgets/multi_pupil_competence_check_card.dart

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import 'dart:io';
33
import 'package:flutter/material.dart';
44
import 'package:gap/gap.dart';
55
import 'package:school_data_hub_client/school_data_hub_client.dart';
6+
import 'package:school_data_hub_flutter/app_utils/create_and_crop_image_file.dart';
67
import 'package:school_data_hub_flutter/common/theme/app_colors.dart';
78
import 'package:school_data_hub_flutter/common/widgets/dialogs/confirmation_dialog.dart';
89
import 'package:school_data_hub_flutter/common/widgets/dialogs/long_textfield_dialog.dart';
910
import 'package:school_data_hub_flutter/common/widgets/encrypted_document_image.dart';
1011
import 'package:school_data_hub_flutter/common/widgets/growth_dropdown.dart';
11-
import 'package:school_data_hub_flutter/app_utils/create_and_crop_image_file.dart';
1212
import 'package:school_data_hub_flutter/core/session/hub_session_helper.dart';
1313
import 'package:school_data_hub_flutter/features/app_main_navigation/domain/main_menu_bottom_nav_manager.dart';
1414
import 'package:school_data_hub_flutter/features/learning/domain/competence_helper.dart';
@@ -288,18 +288,20 @@ class MultiPupilCompetenceCheckCard extends WatchingWidget {
288288
InkWell(
289289
onTap: () async {
290290
if (SessionHelper.isAuthorized(competenceCheck.createdBy)) {
291-
final String? comment = await longTextFieldDialog(
291+
final result = await longTextFieldDialog(
292292
parentContext: context,
293293
title: 'Kommentar',
294294
labelText: 'Kommentar eingeben',
295295
initialValue: competenceCheck.comment,
296296
);
297-
if (comment != null) {
298-
await di<CompetenceManager>().updateCompetenceCheck(
299-
competenceCheckId: competenceCheck.checkId,
300-
competenceComment: (value: comment),
301-
);
297+
if (result == null ||
298+
result.value == competenceCheck.comment) {
299+
return;
302300
}
301+
await di<CompetenceManager>().updateCompetenceCheck(
302+
competenceCheckId: competenceCheck.checkId,
303+
competenceComment: (value: result.value),
304+
);
303305
}
304306
},
305307
child: Text(
@@ -318,18 +320,20 @@ class MultiPupilCompetenceCheckCard extends WatchingWidget {
318320
if (SessionHelper.isAuthorized(
319321
competenceCheck.createdBy,
320322
)) {
321-
final String? comment = await longTextFieldDialog(
323+
final result = await longTextFieldDialog(
322324
parentContext: context,
323325
title: 'Kommentar',
324326
labelText: 'Kommentar eingeben',
325327
initialValue: competenceCheck.comment,
326328
);
327-
if (comment != null) {
328-
await di<CompetenceManager>().updateCompetenceCheck(
329-
competenceCheckId: competenceCheck.checkId,
330-
competenceComment: (value: comment),
331-
);
329+
if (result == null ||
330+
result.value == competenceCheck.comment) {
331+
return;
332332
}
333+
await di<CompetenceManager>().updateCompetenceCheck(
334+
competenceCheckId: competenceCheck.checkId,
335+
competenceComment: (value: result.value),
336+
);
333337
}
334338
},
335339
child: Text(

0 commit comments

Comments
 (0)