feat(programmer): sheet-driven stats, monitor status, drill-down history
- 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>
This commit is contained in:
@@ -1,13 +1,20 @@
|
||||
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.
|
||||
/// specific user in read-only mode, plus their recent day sheets history.
|
||||
///
|
||||
/// Route: /programmer-tasks/programmers/:userId
|
||||
class ProgrammerDrillDownScreen extends ConsumerWidget {
|
||||
@@ -46,7 +53,102 @@ class ProgrammerDrillDownScreen extends ConsumerWidget {
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(name)),
|
||||
body: ProgrammerDashboard(userId: userId, readOnly: true),
|
||||
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),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user