Skip to content

Commit 67965d6

Browse files
SachinPremkumarSachin S P
andauthored
validation added in document upload screen (#217)
* fixed validation issue in document upload page Signed-off-by: Sachin S P <sachin.sp@cyberpwn.com> * added validation message Signed-off-by: Sachin S P <sachin.sp@cyberpwn.com> --------- Signed-off-by: Sachin S P <sachin.sp@cyberpwn.com> Co-authored-by: Sachin S P <sachin.sp@cyberpwn.com>
1 parent 07757ba commit 67965d6

File tree

9 files changed

+43
-17
lines changed

9 files changed

+43
-17
lines changed

lib/l10n/app_ar.arb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,6 @@
9797
"type": "String"
9898
}
9999
}
100-
}
100+
},
101+
"upload_document": "يرجى تحميل الوثيقة"
101102
}

lib/l10n/app_en.arb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,6 @@
9797
"type": "String"
9898
}
9999
}
100-
}
100+
},
101+
"upload_document": "Please Upload The Document"
101102
}

lib/l10n/app_fr.arb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,6 @@
9797
"type": "String"
9898
}
9999
}
100-
}
100+
},
101+
"upload_document": "Veuillez télécharger le document"
101102
}

lib/l10n/app_hi.arb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,6 @@
9797
"type": "String"
9898
}
9999
}
100-
}
100+
},
101+
"upload_document": "कृपया दस्तावेज़ अपलोड करें"
101102
}

lib/l10n/app_kn.arb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,6 @@
9797
"type": "String"
9898
}
9999
}
100-
}
100+
},
101+
"upload_document": "ದಯವಿಟ್ಟು ಡಾಕ್ಯುಮೆಂಟ್ ಅನ್ನು ಅಪ್‌ಲೋಡ್ ಮಾಡಿ"
101102
}

lib/l10n/app_ta.arb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,6 @@
9797
"type": "String"
9898
}
9999
}
100-
}
100+
},
101+
"upload_document": "ஆவணத்தைப் பதிவேற்றவும்"
101102
}

lib/provider/global_provider.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,15 @@ class GlobalProvider with ChangeNotifier {
320320
notifyListeners();
321321
}
322322

323+
removeValidFromMap(String key,Uint8List? item, Map<String, dynamic> commonMap) {
324+
if(commonMap[key].listofImages!=null && commonMap[key].listofImages.length>=1) {
325+
commonMap[key].listofImages.remove(item);
326+
}else{
327+
commonMap.remove(key);
328+
}
329+
notifyListeners();
330+
}
331+
323332
clearMapValue(Map<String, dynamic> commonMap) {
324333
commonMap = {};
325334
notifyListeners();

lib/ui/process_ui/new_process.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ class _NewProcessState extends State<NewProcess> {
324324
!(context.read<GlobalProvider>().fieldInputValue.containsKey(
325325
"${screen.fields!.elementAt(i)!.group}${screen.fields!.elementAt(i)!.subType}"))) {
326326
log("field: ${screen.fields!.elementAt(i)!.group}${screen.fields!.elementAt(i)!.subType}");
327+
328+
if(screen.fields!.elementAt(i)!.controlType == "fileupload"){
329+
_showInSnackBar(AppLocalizations.of(context)!.upload_document);
330+
}
327331
isValid = false;
328332

329333
break;

lib/ui/process_ui/widgets/document_upload_control.dart

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,8 @@ class _DocumentUploadControlState extends State<DocumentUploadControl> {
3030
@override
3131
void initState() {
3232
//load from the map
33-
final scannedPagesMap =
34-
context.read<GlobalProvider>().scannedPages[widget.field.id];
35-
36-
if (scannedPagesMap != null) {
37-
imageBytesList.clear();
38-
setState(() {
39-
imageBytesList.addAll(scannedPagesMap);
40-
});
33+
if(mounted) {
34+
getScannedDocuments(widget.field);
4135
}
4236

4337
if (context
@@ -48,11 +42,16 @@ class _DocumentUploadControlState extends State<DocumentUploadControl> {
4842
.read<GlobalProvider>()
4943
.fieldInputValue[widget.field.id]
5044
.title!;
45+
doc.title = context
46+
.read<GlobalProvider>()
47+
.fieldInputValue[widget.field.id]
48+
.title;
5149
}
5250

5351
super.initState();
5452
}
5553

54+
5655
void focusNextField(FocusNode currentFocus, FocusNode nextFocus) {
5756
currentFocus.unfocus();
5857
FocusScope.of(context).requestFocus(nextFocus);
@@ -90,6 +89,11 @@ class _DocumentUploadControlState extends State<DocumentUploadControl> {
9089
context.read<GlobalProvider>().removeScannedPages(e.id!,item,listOfScannedDoc);
9190
}
9291

92+
_removeFieldValue(Field e, Uint8List? item) async{
93+
context.read<GlobalProvider>().removeValidFromMap(
94+
e.id!,item,context.read<GlobalProvider>().fieldInputValue);
95+
}
96+
9397
_setValueInMap() {
9498
context.read<GlobalProvider>().fieldInputValue[widget.field.id!] = doc;
9599
}
@@ -151,13 +155,12 @@ class _DocumentUploadControlState extends State<DocumentUploadControl> {
151155
}
152156

153157
void _deleteImage(Field e, Uint8List? item) async {
154-
for(int i =0;i<=imageBytesList.length;i++){
158+
for(int i =0;i<imageBytesList.length;i++){
155159
if(imageBytesList[i] == item){
156160
setState(() {
157-
imageBytesList.remove(item);
161+
imageBytesList.removeAt(i);
158162
});
159163
await _getRemoveDocumentProvider(e, i);
160-
_setRemoveScannedPages(e, item, imageBytesList);
161164
}
162165
}
163166
}
@@ -309,6 +312,8 @@ class _DocumentUploadControlState extends State<DocumentUploadControl> {
309312
GestureDetector(
310313
onTap: (){
311314
_deleteImage(widget.field,item);
315+
_removeFieldValue(widget.field,item);
316+
_setRemoveScannedPages(widget.field, item,imageBytesList);
312317
},
313318
child: Row(
314319
mainAxisAlignment: MainAxisAlignment.center,
@@ -484,6 +489,8 @@ class _DocumentUploadControlState extends State<DocumentUploadControl> {
484489
GestureDetector(
485490
onTap: (){
486491
_deleteImage(widget.field,item);
492+
_removeFieldValue(widget.field,item);
493+
_setRemoveScannedPages(widget.field, item,imageBytesList);
487494
},
488495
child: Row(
489496
mainAxisAlignment: MainAxisAlignment.center,

0 commit comments

Comments
 (0)