From f0314d47c73810e1a3fa35b91309bac21735c705 Mon Sep 17 00:00:00 2001 From: devendra <devendra@devendras-MacBook-Pro.local> Date: Thu, 8 Dec 2022 13:59:46 +0530 Subject: [PATCH] Fix: assessor form validation changes --- lib/l10n/app_en.arb | 3 ++- lib/pages/application_details_page.dart | 19 ++++++++++++++++++- .../lead_inspector_application_field.dart | 8 ++++---- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index be80fc6..dd27d61 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -67,5 +67,6 @@ "preview": "Preview", "remove": "Remove", "attachment": "Attachment", - "version": "Version" + "version": "Version", + "canNotSubmitEmptyForm": "Empty assessment can't be submitted" } \ No newline at end of file diff --git a/lib/pages/application_details_page.dart b/lib/pages/application_details_page.dart index 3798fcb..0dca045 100644 --- a/lib/pages/application_details_page.dart +++ b/lib/pages/application_details_page.dart @@ -164,7 +164,7 @@ class _ApplicationDetailsPageState extends State<ApplicationDetailsPage> updatedFields = {}, value.forEach((childKey, childValue) => { updatedFields[childKey] = { - childValue: {'value': 'Correct', 'comments': ''} + childValue: {'value': '', 'comments': ''} } }), _data[key] = updatedFields @@ -266,6 +266,7 @@ class _ApplicationDetailsPageState extends State<ApplicationDetailsPage> if (isInternetConnected) { _validateUser(); } + if (_isleadInspector) { Map data = { 'applicationId': widget.application.applicationId, @@ -273,6 +274,22 @@ class _ApplicationDetailsPageState extends State<ApplicationDetailsPage> 'dataObject': _data }; + //Validate assessment form to make sure some inputs are given by the assessor + int fieldsLength = _data.keys.length; + bool isValidForm = false; + for (int i = 0; i < fieldsLength; i++) { + _data[_data.keys.elementAt(i)].forEach((key, value) { + if (value[value.keys.elementAt(0)]["value"].isNotEmpty) { + isValidForm = true; + } + }); + } + + if (!isValidForm) { + Helper.toastMessage("Empty assessment can't be submitted"); + return; + } + Navigator.of(context).pushReplacement(MaterialPageRoute( builder: (context) => InspectionSummaryPage( // formId: widget.formId, diff --git a/lib/widgets/lead_inspector_application_field.dart b/lib/widgets/lead_inspector_application_field.dart index b8c5654..6865939 100644 --- a/lib/widgets/lead_inspector_application_field.dart +++ b/lib/widgets/lead_inspector_application_field.dart @@ -543,14 +543,14 @@ class _LeadInspectorApplicationFieldState if (widget.applicationStatus != InspectionStatus .inspectionCompleted && - _radioValue.toLowerCase() != - FieldValue.correct + _radioValue.toLowerCase() == + FieldValue.inCorrect .toLowerCase()) { _displayCommentDialog(); } }, - icon: _radioValue.toLowerCase() != - FieldValue.correct + icon: _radioValue.toLowerCase() == + FieldValue.inCorrect .toLowerCase() && widget.applicationStatus != InspectionStatus -- GitLab