now shows every empty required field in the save as template dialog

This commit is contained in:
Nico
2024-03-23 15:59:27 +01:00
parent b38a1000ba
commit 062b6bbcc4
2 changed files with 14 additions and 12 deletions

View File

@@ -216,7 +216,7 @@ class _AddCamMainState extends State<AddCamMain> {
}
// Function to show the dialog where the user has to choose if he want to safe his values as a template
Future<void> showTemplateDialog(String emptyField) async {
Future<void> showTemplateDialog(List<String> emptyField) async {
return showDialog(
context: context,
barrierDismissible: false,
@@ -224,7 +224,7 @@ class _AddCamMainState extends State<AddCamMain> {
return AlertDialog(
title: Text(AppLocalizations.of(context)!.fieldEmpty),
content: SingleChildScrollView(
child: ListBody(children: <Widget>[Text(emptyField)]),
child: ListBody(children: <Widget>[Text(emptyField.join("; "))]),
),
actions: <Widget>[
TextButton(
@@ -326,7 +326,10 @@ class _AddCamMainState extends State<AddCamMain> {
}
// checks if required fields are not empty. If one is the name will be returned
String validateData() {
List<String> validateData() {
List<String> emptyFields = <String>[];
Map<String, TextEditingController> fields = {
'CID': id,
'Rudel': rudelC,
@@ -347,14 +350,13 @@ class _AddCamMainState extends State<AddCamMain> {
for (var entry in fields.entries) {
if (entry.value.text.isEmpty) {
empty = true;
return entry.key;
} else {
empty = false;
emptyFields.add(entry.key);
}
}
return "";
if (emptyFields.isEmpty) empty = true;
return emptyFields;
}
// If the user decides to safe his values as a template this function is called to save the values in the database
@@ -718,11 +720,11 @@ class _AddCamMainState extends State<AddCamMain> {
currentStep += 1;
});
} else {
String emptyField = validateData();
List<String> emptyFields = validateData();
// ! always fileed out
empty = false;
empty = true;
if (empty == true) {
showTemplateDialog(emptyField);
showTemplateDialog(emptyFields);
();
return;
} else if (empty == false) {