2585cce36d
- Wire daySheetsForUserProvider(userId) into ProgrammerDashboard so computeProgrammerStats/computeBadges receive real sheet data instead of the placeholder const <ProgrammerDaySheet>[]. - Monitor tab: watch allDaySheetsProvider and build sheetStatusByUser map for today; pass it to buildMonitorEntries; add "Sheets pending" chip (pending + disapproved today) to the summary row. - ProgrammerDrillDownScreen: add _RecentDaySheetsPanel below the dashboard showing the last 10 sheets (date + status pill) with tap-to-daySheetDetail. - DaySheetDetailScreen (T17 gaps): replace const [] liveRows with programmerDayDataProvider(sheet.workDate) built rows for non-approved sheets; fix _onApprove timer check to filter only the sheet programmer's own tasks (QN-1). - Add test/programmer_drill_down_test.dart (3 tests, all passing). Co-Authored-By: claude-flow <ruv@ruv.net>
155 lines
5.1 KiB
Dart
155 lines
5.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import '../../models/profile.model.dart';
|
|
import '../../models/programmer_day_sheet.model.dart';
|
|
import '../../providers/profile_provider.dart';
|
|
import '../../providers/programmer_day_sheets_provider.dart';
|
|
import '../../theme/app_status_colors.dart';
|
|
import '../../utils/app_time.dart';
|
|
import '../../widgets/app_section_header.dart';
|
|
import '../../widgets/app_state_view.dart';
|
|
import '../../widgets/status_pill.dart';
|
|
import 'dashboard/programmer_dashboard.dart';
|
|
|
|
/// Admin-only drill-down screen that shows [ProgrammerDashboard] for a
|
|
/// specific user in read-only mode, plus their recent day sheets history.
|
|
///
|
|
/// Route: /programmer-tasks/programmers/:userId
|
|
class ProgrammerDrillDownScreen extends ConsumerWidget {
|
|
const ProgrammerDrillDownScreen({
|
|
super.key,
|
|
required this.userId,
|
|
});
|
|
|
|
final String userId;
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final isStrictAdmin = ref.watch(isStrictAdminProvider);
|
|
final profilesAsync = ref.watch(profilesProvider);
|
|
|
|
if (!isStrictAdmin) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('Programmer')),
|
|
body: const AppEmptyView(
|
|
icon: Icons.lock_outline,
|
|
title: 'Admins only',
|
|
),
|
|
);
|
|
}
|
|
|
|
// Resolve the programmer's name for the AppBar title.
|
|
final profiles = profilesAsync.valueOrNull ?? <Profile>[];
|
|
Profile? profile;
|
|
for (final p in profiles) {
|
|
if (p.id == userId) {
|
|
profile = p;
|
|
break;
|
|
}
|
|
}
|
|
final name = profile?.fullName ?? 'Programmer';
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(title: Text(name)),
|
|
body: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
// Dashboard fills the upper portion of the screen.
|
|
Expanded(
|
|
child: ProgrammerDashboard(userId: userId, readOnly: true),
|
|
),
|
|
const Divider(height: 1),
|
|
// Recent day sheets section — fixed-height scrollable panel.
|
|
_RecentDaySheetsPanel(userId: userId),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Recent sheets panel
|
|
// ---------------------------------------------------------------------------
|
|
|
|
class _RecentDaySheetsPanel extends ConsumerWidget {
|
|
const _RecentDaySheetsPanel({required this.userId});
|
|
|
|
final String userId;
|
|
|
|
StatusKind _kindFor(String status) => switch (status) {
|
|
DaySheetStatus.approved => StatusKind.success,
|
|
DaySheetStatus.pending => StatusKind.info,
|
|
DaySheetStatus.disapproved => StatusKind.warning,
|
|
_ => StatusKind.neutral,
|
|
};
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final sheetsAsync = ref.watch(daySheetsForUserProvider(userId));
|
|
final allSheets = sheetsAsync.valueOrNull ?? const [];
|
|
// Show the most-recent 10 sheets (provider already orders newest-first).
|
|
final recent = allSheets.length > 10 ? allSheets.sublist(0, 10) : allSheets;
|
|
|
|
final cs = Theme.of(context).colorScheme;
|
|
final tt = Theme.of(context).textTheme;
|
|
|
|
return ConstrainedBox(
|
|
constraints: const BoxConstraints(maxHeight: 320),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
|
child: AppSectionHeader('Recent day sheets'),
|
|
),
|
|
if (recent.isEmpty)
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
child: Text(
|
|
'No day sheets yet.',
|
|
style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant),
|
|
),
|
|
)
|
|
else
|
|
Flexible(
|
|
child: ListView.builder(
|
|
padding: const EdgeInsets.only(bottom: 12),
|
|
itemCount: recent.length,
|
|
itemBuilder: (context, i) {
|
|
final sheet = recent[i];
|
|
return InkWell(
|
|
onTap: () => context.pushNamed(
|
|
'daySheetDetail',
|
|
pathParameters: {'id': sheet.id},
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 16, vertical: 8),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
AppTime.formatDate(sheet.workDate),
|
|
style: tt.bodyMedium,
|
|
),
|
|
),
|
|
StatusPill.kind(
|
|
_kindFor(sheet.status),
|
|
label: DaySheetStatus.label(sheet.status),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|