Prevent task starting and completion without assigned it staff
This commit is contained in:
@@ -3503,12 +3503,8 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
|
||||
return chip;
|
||||
}
|
||||
|
||||
final statusOptions = _statusOptions.where((status) {
|
||||
if (status == 'in_progress' && !hasAssignedItStaff) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}).toList();
|
||||
// Show all status options - validation happens on selection
|
||||
final statusOptions = _statusOptions;
|
||||
|
||||
return PopupMenuButton<String>(
|
||||
onSelected: (value) async {
|
||||
@@ -3606,6 +3602,16 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate IT staff assignment before starting or completing
|
||||
if ((value == 'in_progress' || value == 'completed') &&
|
||||
!hasAssignedItStaff) {
|
||||
showWarningSnackBar(
|
||||
context,
|
||||
'Please assign at least one IT Staff member before ${value == 'in_progress' ? 'starting' : 'completing'} this task.',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Update DB only — Supabase realtime stream will emit the
|
||||
// updated task list, so explicit invalidation here causes a
|
||||
// visible loading/refresh and is unnecessary.
|
||||
|
||||
Reference in New Issue
Block a user