Fixed In Progress ISR not reflecting on IT Staff Pulse Dashboard Status Pill
Made the Location Tracking more persistent
This commit is contained in:
@@ -15,6 +15,8 @@ import '../../models/task.dart';
|
||||
import '../../models/task_assignment.dart';
|
||||
import '../../models/ticket.dart';
|
||||
import '../../models/ticket_message.dart';
|
||||
import '../../models/it_service_request.dart';
|
||||
import '../../models/it_service_request_assignment.dart';
|
||||
import '../../providers/attendance_provider.dart';
|
||||
import '../../providers/leave_provider.dart';
|
||||
import '../../providers/pass_slip_provider.dart';
|
||||
@@ -302,6 +304,23 @@ final dashboardMetricsProvider = Provider<AsyncValue<DashboardMetrics>>((ref) {
|
||||
.add(task.id);
|
||||
}
|
||||
|
||||
// Determine which staff members are currently handling an IT service
|
||||
// request. The dashboard should treat these assignments like being "on
|
||||
// task" so that the status pill reflects the fact that they are busy.
|
||||
final isrList = isrAsync.valueOrNull ?? const <ItServiceRequest>[];
|
||||
final isrById = {for (final r in isrList) r.id: r};
|
||||
final staffOnService = <String>{};
|
||||
for (final assign
|
||||
in isrAssignmentsAsync.valueOrNull ??
|
||||
const <ItServiceRequestAssignment>[]) {
|
||||
final isr = isrById[assign.requestId];
|
||||
if (isr == null) continue;
|
||||
if (isr.status == ItServiceRequestStatus.inProgress ||
|
||||
isr.status == ItServiceRequestStatus.inProgressDryRun) {
|
||||
staffOnService.add(assign.userId);
|
||||
}
|
||||
}
|
||||
|
||||
const triageWindow = Duration(minutes: 1);
|
||||
final triageCutoff = now.subtract(triageWindow);
|
||||
|
||||
@@ -367,12 +386,14 @@ final dashboardMetricsProvider = Provider<AsyncValue<DashboardMetrics>>((ref) {
|
||||
final lastMessage = lastStaffMessageByUser[staff.id];
|
||||
final ticketsResponded = respondedTicketsByUser[staff.id]?.length ?? 0;
|
||||
final tasksClosed = tasksClosedByUser[staff.id]?.length ?? 0;
|
||||
// users are considered "on task" if they have either a regular task
|
||||
// assignment or an active service request in progress/dry run.
|
||||
// determine whether staff have regular tasks or service requests
|
||||
final onTask = staffOnTask.contains(staff.id);
|
||||
final inTriage = lastMessage != null && lastMessage.isAfter(triageCutoff);
|
||||
|
||||
// Attendance-based status.
|
||||
final onService = staffOnService.contains(staff.id);
|
||||
final userSchedules = todaySchedulesByUser[staff.id] ?? const [];
|
||||
final userLogs = todayLogsByUser[staff.id] ?? const [];
|
||||
final inTriage = lastMessage != null && lastMessage.isAfter(triageCutoff);
|
||||
|
||||
// Whereabouts from live position, with tracking-off inference.
|
||||
final livePos = positionByUser[staff.id];
|
||||
@@ -410,8 +431,10 @@ final dashboardMetricsProvider = Provider<AsyncValue<DashboardMetrics>>((ref) {
|
||||
// Active pass slip — user is temporarily away from duty.
|
||||
status = 'PASS SLIP';
|
||||
} else if (userSchedules.isEmpty) {
|
||||
// No schedule today — off duty unless actively on task/triage.
|
||||
status = onTask
|
||||
// No schedule today — off duty unless actively on task/service/triage.
|
||||
status = onService
|
||||
? 'On event'
|
||||
: onTask
|
||||
? 'On task'
|
||||
: inTriage
|
||||
? 'In triage'
|
||||
@@ -445,7 +468,9 @@ final dashboardMetricsProvider = Provider<AsyncValue<DashboardMetrics>>((ref) {
|
||||
|
||||
if (activeLog != null) {
|
||||
// Currently checked in — on-duty, can be overridden.
|
||||
status = onTask
|
||||
status = onService
|
||||
? 'On event'
|
||||
: onTask
|
||||
? 'On task'
|
||||
: inTriage
|
||||
? 'In triage'
|
||||
@@ -1166,6 +1191,7 @@ class _PulseStatusPill extends StatelessWidget {
|
||||
'noon break' => (Colors.blue.shade100, Colors.blue.shade900),
|
||||
'vacant' => (Colors.green.shade100, Colors.green.shade900),
|
||||
'on task' => (Colors.purple.shade100, Colors.purple.shade900),
|
||||
'on event' => (Colors.purple.shade100, Colors.purple.shade900),
|
||||
'in triage' => (Colors.orange.shade100, Colors.orange.shade900),
|
||||
'early out' => (Colors.deepOrange.shade100, Colors.deepOrange.shade900),
|
||||
'on leave' => (Colors.teal.shade100, Colors.teal.shade900),
|
||||
|
||||
Reference in New Issue
Block a user