Merge pull request 'fix: Improve validation for completed work and display pending work in report task bottom sheet' (#37) from Vaibhav_Bug-#435 into main
Reviewed-on: #37
This commit is contained in:
commit
a7f8ea16b0
@ -124,10 +124,8 @@ class _ReportTaskBottomSheetState extends State<ReportTaskBottomSheet>
|
||||
.trim()),
|
||||
buildRow(
|
||||
"Assigned",
|
||||
controller.basicValidator
|
||||
.getController('assigned')
|
||||
?.text
|
||||
.trim()),
|
||||
"${controller.basicValidator.getController('assigned')?.text.trim()} "
|
||||
"of ${widget.taskData['pendingWork'] ?? '-'} Pending"),
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.work_outline,
|
||||
@ -141,8 +139,23 @@ class _ReportTaskBottomSheetState extends State<ReportTaskBottomSheet>
|
||||
),
|
||||
MySpacing.height(8),
|
||||
TextFormField(
|
||||
validator: controller.basicValidator
|
||||
.getValidation('completed_work'),
|
||||
validator: (value) {
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return 'Please enter completed work';
|
||||
}
|
||||
final completed = int.tryParse(value.trim());
|
||||
final pending = widget.taskData['pendingWork'] ?? 0;
|
||||
|
||||
if (completed == null) {
|
||||
return 'Enter a valid number';
|
||||
}
|
||||
|
||||
if (completed > pending) {
|
||||
return 'Completed work cannot exceed pending work $pending';
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
controller: controller.basicValidator
|
||||
.getController('completed_work'),
|
||||
keyboardType: TextInputType.number,
|
||||
|
@ -440,6 +440,11 @@ class _DailyProgressReportScreenState extends State<DailyProgressReportScreen>
|
||||
final teamMembers = task.teamMembers
|
||||
.map((e) => e.firstName)
|
||||
.toList();
|
||||
final pendingWork = (task.workItem
|
||||
?.plannedWork ??
|
||||
0) -
|
||||
(task.workItem?.completedWork ??
|
||||
0);
|
||||
|
||||
final taskData = {
|
||||
'activity': activityName,
|
||||
@ -452,6 +457,7 @@ class _DailyProgressReportScreenState extends State<DailyProgressReportScreen>
|
||||
'teamSize':
|
||||
task.teamMembers.length,
|
||||
'teamMembers': teamMembers,
|
||||
'pendingWork': pendingWork,
|
||||
};
|
||||
|
||||
showModalBottomSheet(
|
||||
|
Loading…
x
Reference in New Issue
Block a user