fix: Stationsabschluss absichern und Kundenformulare anpassen
Sperrt nachträgliche Aufgabenabschlüsse in App und Backend und zeigt erledigte Aufträge trotz offener optionaler Aufgaben grün an. Ergänzt Regressionstests, die Anredeauswahl und optionale Steuerangaben für Kunden. Enthält App-Version 0.9.25, Backend-Version 0.9.26 und das aktualisierte Frontend-Bundle.
This commit is contained in:
1 parent
8758c53e5b
commit
5e6044e4b1
16 files changed
+638
-69
No files matched your search
@@ -6,6 +6,7 @@ import 'l10n/app_localizations.dart';
|
||||
import 'l10n/localization_helpers.dart';
|
||||
import 'models/delivery_station.dart';
|
||||
import 'models/job.dart';
|
||||
import 'models/job_progress.dart';
|
||||
import 'services/database_service.dart';
|
||||
import 'task_view.dart';
|
||||
import 'widgets/offline_banner.dart';
|
||||
@@ -13,8 +14,10 @@ import 'widgets/offline_banner.dart';
|
||||
@visibleForTesting
|
||||
Color? deliveryStationCardBackgroundColor(
|
||||
DeliveryStation station,
|
||||
Map<String, bool> taskStatuses,
|
||||
) {
|
||||
Map<String, bool> taskStatuses, {
|
||||
bool isClosed = false,
|
||||
}) {
|
||||
if (isClosed) return AppColors.successSoft;
|
||||
if (station.tasks.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
@@ -37,6 +40,7 @@ class CargoItemsView extends StatefulWidget {
|
||||
class _CargoItemsViewState extends State<CargoItemsView> {
|
||||
final DatabaseService _databaseService = DatabaseService();
|
||||
Map<String, bool> _taskStatuses = const {};
|
||||
Set<int> _completedStations = const {};
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -46,9 +50,13 @@ class _CargoItemsViewState extends State<CargoItemsView> {
|
||||
|
||||
Future<void> _loadLocalTaskStatuses() async {
|
||||
final map = await _databaseService.loadAllTaskStatuses();
|
||||
final completedStations = await _databaseService.loadCompletedStationOrders(
|
||||
widget.job,
|
||||
);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_taskStatuses = map;
|
||||
_completedStations = completedStations;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -311,6 +319,11 @@ class _CargoItemsViewState extends State<CargoItemsView> {
|
||||
final backgroundColor = deliveryStationCardBackgroundColor(
|
||||
station,
|
||||
_taskStatuses,
|
||||
isClosed: JobProgress(
|
||||
widget.job,
|
||||
taskStatuses: _taskStatuses,
|
||||
localCompletedStations: _completedStations,
|
||||
).isStationClosed(station.stationOrder),
|
||||
);
|
||||
final title =
|
||||
station.displayName.isNotEmpty ? station.displayName : station.company;
|
||||
|
||||
+54
-21
@@ -8,6 +8,7 @@ import 'services/dart_mq.dart';
|
||||
import 'services/chat_service.dart';
|
||||
import 'models/delivery_station.dart';
|
||||
import 'models/job.dart';
|
||||
import 'models/job_progress.dart';
|
||||
import 'models/task.dart';
|
||||
import 'models/tasks/confirmation_task.dart';
|
||||
import 'models/tasks/photo_task.dart';
|
||||
@@ -23,6 +24,13 @@ import 'services/database_service.dart';
|
||||
import 'navigation_observer.dart';
|
||||
import 'routing_view.dart';
|
||||
|
||||
@visibleForTesting
|
||||
Color? jobCardBackgroundColor(JobProgress progress) {
|
||||
if (progress.isCompleted) return AppColors.successSoft;
|
||||
if (progress.hasProgress) return AppColors.warningSoft;
|
||||
return null;
|
||||
}
|
||||
|
||||
class JobsView extends StatefulWidget {
|
||||
const JobsView({super.key});
|
||||
|
||||
@@ -63,6 +71,7 @@ class _JobsViewState extends State<JobsView> with RouteAware {
|
||||
bool _isLoggingOut = false;
|
||||
final DatabaseService _databaseService = DatabaseService();
|
||||
Map<String, bool> _taskStatuses = const {};
|
||||
Map<String, Set<int>> _completedStations = const {};
|
||||
Map<String, bool> _jobSeen = const {};
|
||||
Map<String, double> _jobSwipeOffsets = const {};
|
||||
String? _openJobId;
|
||||
@@ -479,9 +488,15 @@ class _JobsViewState extends State<JobsView> with RouteAware {
|
||||
|
||||
Future<void> _loadLocalTaskStatuses() async {
|
||||
final map = await _databaseService.loadAllTaskStatuses();
|
||||
final completedStations = <String, Set<int>>{};
|
||||
for (final job in _appState.assignedJobs) {
|
||||
completedStations[job.id] = await _databaseService
|
||||
.loadCompletedStationOrders(job);
|
||||
}
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_taskStatuses = map;
|
||||
_completedStations = completedStations;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -950,25 +965,15 @@ class _JobsViewState extends State<JobsView> with RouteAware {
|
||||
statusColor = AppColors.textMuted;
|
||||
}
|
||||
|
||||
// Determine card background color based on task completion
|
||||
final progress = JobProgress(
|
||||
job,
|
||||
taskStatuses: _taskStatuses,
|
||||
localCompletedStations: _completedStations[job.id] ?? const {},
|
||||
);
|
||||
final totalTasks = job.tasks.length;
|
||||
int completedTasks = 0;
|
||||
for (final t in job.tasks) {
|
||||
final isCompleted = _taskStatuses[t.id] ?? t.completed;
|
||||
if (isCompleted) completedTasks++;
|
||||
}
|
||||
|
||||
// Check if all tasks are completed (job is done)
|
||||
final bool isJobCompleted = totalTasks > 0 && completedTasks == totalTasks;
|
||||
|
||||
Color? cardBg;
|
||||
if (totalTasks == 0 || completedTasks == 0) {
|
||||
cardBg = null; // unchanged (default)
|
||||
} else if (completedTasks > 0 && completedTasks < totalTasks) {
|
||||
cardBg = AppColors.warningSoft;
|
||||
} else if (completedTasks == totalTasks) {
|
||||
cardBg = AppColors.successSoft;
|
||||
}
|
||||
final completedTasks = progress.completedTaskCount;
|
||||
final isJobCompleted = progress.isCompleted;
|
||||
final cardBg = jobCardBackgroundColor(progress);
|
||||
// Build robust display strings with fallbacks
|
||||
final pickupName = _joinNonEmpty([job.pickupFirstName, job.pickupLastName]);
|
||||
final pickupDisplayName =
|
||||
@@ -1211,7 +1216,17 @@ class _JobsViewState extends State<JobsView> with RouteAware {
|
||||
),
|
||||
],
|
||||
),
|
||||
// Progress bar for tasks
|
||||
if (isJobCompleted) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
AppLocalizations.of(context).jobCompleted,
|
||||
style: const TextStyle(
|
||||
color: AppColors.success,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
// Progress bar for tasks (optional tasks retain their actual state).
|
||||
if (totalTasks > 0) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
@@ -1235,7 +1250,8 @@ class _JobsViewState extends State<JobsView> with RouteAware {
|
||||
minHeight: 8,
|
||||
backgroundColor: AppColors.border,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
completedTasks >= totalTasks
|
||||
isJobCompleted ||
|
||||
completedTasks >= totalTasks
|
||||
? AppColors.success
|
||||
: (completedTasks > 0
|
||||
? AppColors.warning
|
||||
@@ -1447,6 +1463,14 @@ class _JobsViewState extends State<JobsView> with RouteAware {
|
||||
}
|
||||
|
||||
void _toggleTaskCompletion(Job job, int taskIndex) {
|
||||
final progress = JobProgress(
|
||||
job,
|
||||
taskStatuses: _taskStatuses,
|
||||
localCompletedStations: _completedStations[job.id] ?? const {},
|
||||
);
|
||||
if (progress.isStationClosed(job.tasks[taskIndex].stationOrder ?? 0)) {
|
||||
return;
|
||||
}
|
||||
// Create a new task with toggled completion status
|
||||
final updatedTask = job.tasks[taskIndex].copyWith(
|
||||
completed: !job.tasks[taskIndex].completed,
|
||||
@@ -1488,6 +1512,7 @@ class _JobsViewState extends State<JobsView> with RouteAware {
|
||||
id: job.id,
|
||||
jobNumber: job.jobNumber,
|
||||
status: job.status,
|
||||
completedStationOrders: job.completedStationOrders,
|
||||
createdAt: job.createdAt,
|
||||
updatedAt: job.updatedAt,
|
||||
createdBy: job.createdBy,
|
||||
@@ -1690,7 +1715,15 @@ class _JobsViewState extends State<JobsView> with RouteAware {
|
||||
const SizedBox(height: 8),
|
||||
...job.tasks.asMap().entries.map(
|
||||
(entry) => GestureDetector(
|
||||
onTap: () => _toggleTaskCompletion(job, entry.key),
|
||||
onTap:
|
||||
JobProgress(
|
||||
job,
|
||||
taskStatuses: _taskStatuses,
|
||||
localCompletedStations:
|
||||
_completedStations[job.id] ?? const {},
|
||||
).isStationClosed(entry.value.stationOrder ?? 0)
|
||||
? null
|
||||
: () => _toggleTaskCompletion(job, entry.key),
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 4),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
|
||||
@@ -52,7 +52,7 @@ class DeliveryStation {
|
||||
final tasks =
|
||||
(json['tasks'] as List? ?? const []).map((rawTask) {
|
||||
final taskJson = Map<String, dynamic>.from(rawTask as Map);
|
||||
taskJson['stationOrder'] ??= stationOrder;
|
||||
taskJson['stationOrder'] = stationOrder;
|
||||
return Task.fromJson(taskJson);
|
||||
}).toList()
|
||||
..sort((a, b) => (a.taskOrder ?? 0).compareTo(b.taskOrder ?? 0));
|
||||
|
||||
@@ -6,6 +6,7 @@ class Job {
|
||||
final String id; // Will store the timestamp as string
|
||||
final String jobNumber;
|
||||
final String status;
|
||||
final List<int> completedStationOrders;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final String createdBy;
|
||||
@@ -61,6 +62,7 @@ class Job {
|
||||
required this.id,
|
||||
required this.jobNumber,
|
||||
required this.status,
|
||||
this.completedStationOrders = const [],
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.createdBy,
|
||||
@@ -332,6 +334,12 @@ class Job {
|
||||
id: idValue,
|
||||
jobNumber: jobJson['jobNumber']?.toString() ?? '',
|
||||
status: jobJson['status']?.toString() ?? 'UNKNOWN',
|
||||
completedStationOrders:
|
||||
(jobJson['completedStationOrders'] as List? ?? const [])
|
||||
.map((value) => int.tryParse(value.toString()))
|
||||
.whereType<int>()
|
||||
.toSet()
|
||||
.toList(),
|
||||
createdAt: _parseDateTime(jobJson['createdAt']) ?? DateTime.now(),
|
||||
updatedAt: _parseDateTime(jobJson['updatedAt']) ?? DateTime.now(),
|
||||
createdBy: jobJson['createdBy']?.toString() ?? '',
|
||||
@@ -391,6 +399,7 @@ class Job {
|
||||
id: id,
|
||||
jobNumber: t(jobNumber),
|
||||
status: t(status),
|
||||
completedStationOrders: List.of(completedStationOrders),
|
||||
createdAt: createdAt,
|
||||
updatedAt: updatedAt,
|
||||
createdBy: t(createdBy),
|
||||
@@ -446,6 +455,7 @@ class Job {
|
||||
'id': id,
|
||||
'jobNumber': jobNumber,
|
||||
'status': status,
|
||||
'completedStationOrders': completedStationOrders,
|
||||
'createdAt': createdAt.toIso8601String(),
|
||||
'updatedAt': updatedAt.toIso8601String(),
|
||||
'createdBy': createdBy,
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import 'job.dart';
|
||||
import 'task.dart';
|
||||
|
||||
/// Combines server state with work confirmed locally while offline.
|
||||
class JobProgress {
|
||||
final Job job;
|
||||
final Map<String, bool> taskStatuses;
|
||||
final Set<int> completedStationOrders;
|
||||
|
||||
JobProgress(
|
||||
this.job, {
|
||||
this.taskStatuses = const {},
|
||||
Set<int> localCompletedStations = const {},
|
||||
}) : completedStationOrders = {
|
||||
...job.completedStationOrders,
|
||||
...localCompletedStations,
|
||||
};
|
||||
|
||||
bool isTaskCompleted(Task task) =>
|
||||
task.completed || taskStatuses[task.id] == true;
|
||||
|
||||
bool get isCancelled => job.status.toUpperCase() == 'CANCELLED';
|
||||
|
||||
bool get isCompleted {
|
||||
if (isCancelled) return false;
|
||||
if (const {'COMPLETED', 'DONE'}.contains(job.status.toUpperCase())) {
|
||||
return true;
|
||||
}
|
||||
// Same rule as the backend: explicit final-station confirmation and all
|
||||
// mandatory tasks completed. Open optional tasks do not prevent completion.
|
||||
final lastStationOrder =
|
||||
job.deliveryStations.isEmpty
|
||||
? 0
|
||||
: job.deliveryStations
|
||||
.map((station) => station.stationOrder)
|
||||
.reduce((a, b) => a > b ? a : b);
|
||||
return completedStationOrders.contains(lastStationOrder) &&
|
||||
job.tasks.where((task) => !task.optional).every(isTaskCompleted);
|
||||
}
|
||||
|
||||
bool isStationClosed(int stationOrder) =>
|
||||
isCancelled ||
|
||||
isCompleted ||
|
||||
completedStationOrders.contains(stationOrder);
|
||||
|
||||
bool canCompleteTask(Task task) =>
|
||||
!isStationClosed(task.stationOrder ?? 0) && !isTaskCompleted(task);
|
||||
|
||||
int get completedTaskCount => job.tasks.where(isTaskCompleted).length;
|
||||
bool get hasProgress =>
|
||||
completedTaskCount > 0 || completedStationOrders.isNotEmpty;
|
||||
}
|
||||
@@ -368,6 +368,23 @@ class DatabaseService {
|
||||
}
|
||||
}
|
||||
|
||||
/// Merge server confirmations and locally persisted offline confirmations.
|
||||
Future<Set<int>> loadCompletedStationOrders(Job job) async {
|
||||
final orders =
|
||||
job.deliveryStations.isEmpty
|
||||
? {0}
|
||||
: job.deliveryStations
|
||||
.map((station) => station.stationOrder)
|
||||
.toSet();
|
||||
final completed = <int>{...job.completedStationOrders};
|
||||
for (final order in orders) {
|
||||
if (await loadKeyValue('station_completed:${job.id}:$order') == '1') {
|
||||
completed.add(order);
|
||||
}
|
||||
}
|
||||
return completed;
|
||||
}
|
||||
|
||||
/// Load all task completion statuses
|
||||
Future<Map<String, bool>> loadAllTaskStatuses() async {
|
||||
try {
|
||||
|
||||
+74
-15
@@ -6,9 +6,11 @@ import 'package:image/image.dart' as img;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'app_theme.dart';
|
||||
import 'app_state.dart';
|
||||
import 'l10n/app_localizations.dart';
|
||||
import 'l10n/localization_helpers.dart';
|
||||
import 'models/job.dart';
|
||||
import 'models/job_progress.dart';
|
||||
import 'models/task.dart';
|
||||
import 'models/tasks/confirmation_task.dart';
|
||||
import 'models/tasks/photo_task.dart';
|
||||
@@ -42,6 +44,9 @@ class TaskView extends StatefulWidget {
|
||||
class _TaskViewState extends State<TaskView> {
|
||||
final Set<String> _completedTasks = {};
|
||||
final DatabaseService _databaseService = DatabaseService();
|
||||
late Job _job;
|
||||
Set<int> _localCompletedStations = {};
|
||||
StreamSubscription<void>? _jobsUpdatedSubscription;
|
||||
bool _statusesLoaded = false;
|
||||
bool _stationCompleted = false;
|
||||
bool _isCompletingStation = false;
|
||||
@@ -51,31 +56,73 @@ class _TaskViewState extends State<TaskView> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_job = widget.job;
|
||||
_jobsUpdatedSubscription = AppState().jobsUpdated.listen(
|
||||
(_) => _loadTaskStatuses(),
|
||||
);
|
||||
_loadTaskStatuses();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant TaskView oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (!identical(oldWidget.job, widget.job) ||
|
||||
oldWidget.stationOrder != widget.stationOrder) {
|
||||
_job = widget.job;
|
||||
_statusesLoaded = false;
|
||||
_loadTaskStatuses();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_jobsUpdatedSubscription?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
JobProgress get _progress => JobProgress(
|
||||
_job,
|
||||
taskStatuses: {for (final id in _completedTasks) id: true},
|
||||
localCompletedStations: _localCompletedStations,
|
||||
);
|
||||
|
||||
bool _canCompleteTask(Task task) =>
|
||||
mounted &&
|
||||
_statusesLoaded &&
|
||||
!_isCompletingStation &&
|
||||
!_stationCompleted &&
|
||||
_progress.canCompleteTask(task);
|
||||
|
||||
List<Task> get _visibleTasks {
|
||||
final stationOrder = widget.stationOrder;
|
||||
if (stationOrder == null) {
|
||||
return widget.job.tasks;
|
||||
return _job.tasks;
|
||||
}
|
||||
return widget.job.tasks
|
||||
return _job.tasks
|
||||
.where((task) => task.stationOrder == stationOrder)
|
||||
.toList();
|
||||
}
|
||||
|
||||
String get _stationCompletionKey =>
|
||||
'station_completed:${widget.job.id}:${widget.stationOrder ?? 0}';
|
||||
'station_completed:${_job.id}:${widget.stationOrder ?? 0}';
|
||||
|
||||
/// Load task completion and skipped statuses from database and merge with JSON task states
|
||||
Future<void> _loadTaskStatuses() async {
|
||||
var latestJob = _job;
|
||||
for (final savedJob in await _databaseService.loadJobs()) {
|
||||
if (savedJob.id == _job.id &&
|
||||
!savedJob.updatedAt.isBefore(latestJob.updatedAt)) {
|
||||
latestJob = savedJob;
|
||||
}
|
||||
}
|
||||
final statuses = await _databaseService.loadAllTaskStatuses();
|
||||
final stationCompleted =
|
||||
await _databaseService.loadKeyValue(_stationCompletionKey) == '1';
|
||||
final completedStations = await _databaseService.loadCompletedStationOrders(
|
||||
latestJob,
|
||||
);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_stationCompleted =
|
||||
stationCompleted || widget.job.status.toUpperCase() == 'COMPLETED';
|
||||
_job = latestJob;
|
||||
_localCompletedStations = completedStations;
|
||||
_statusesLoaded = true;
|
||||
_completedTasks.clear();
|
||||
// 1) Add all completed from DB
|
||||
@@ -85,11 +132,12 @@ class _TaskViewState extends State<TaskView> {
|
||||
}
|
||||
}
|
||||
// 2) Merge: also mark tasks completed if the job JSON already had them completed
|
||||
for (final t in widget.job.tasks) {
|
||||
for (final t in _job.tasks) {
|
||||
if (t.completed) {
|
||||
_completedTasks.add(t.id);
|
||||
}
|
||||
}
|
||||
_stationCompleted = _progress.isStationClosed(widget.stationOrder ?? 0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -100,7 +148,7 @@ class _TaskViewState extends State<TaskView> {
|
||||
title: Text(
|
||||
widget.stationTitle?.isNotEmpty == true
|
||||
? '${AppLocalizations.of(context).tasks} - ${widget.stationTitle}'
|
||||
: '${AppLocalizations.of(context).tasks} - ${widget.job.jobNumber}',
|
||||
: '${AppLocalizations.of(context).tasks} - ${_job.jobNumber}',
|
||||
),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
@@ -189,7 +237,9 @@ class _TaskViewState extends State<TaskView> {
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: enabled ? _onCompleteStationPressed : null,
|
||||
icon: const Icon(Icons.flag),
|
||||
label: const Text('Station abschließen'),
|
||||
label: Text(
|
||||
_stationCompleted ? 'Station abgeschlossen' : 'Station abschließen',
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
),
|
||||
@@ -235,12 +285,13 @@ class _TaskViewState extends State<TaskView> {
|
||||
final stationOrder = widget.stationOrder ?? 0;
|
||||
try {
|
||||
await StompService().sendStationCompleted(
|
||||
jobId: widget.job.id,
|
||||
jobNumber: widget.job.jobNumber,
|
||||
jobId: _job.id,
|
||||
jobNumber: _job.jobNumber,
|
||||
stationOrder: stationOrder,
|
||||
hasIncompleteOptionalTasks: _hasIncompleteOptionalTasks,
|
||||
);
|
||||
_stationCompleted = true;
|
||||
_localCompletedStations.add(stationOrder);
|
||||
await _databaseService.saveKeyValue(_stationCompletionKey, '1');
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(
|
||||
@@ -289,7 +340,7 @@ class _TaskViewState extends State<TaskView> {
|
||||
final task = _visibleTasks[index];
|
||||
final isCompleted = _completedTasks.contains(task.id);
|
||||
final canBeCompletedNow =
|
||||
!isCompleted && _arePreviousTasksCompleted(index);
|
||||
_canCompleteTask(task) && _arePreviousTasksCompleted(index);
|
||||
|
||||
// Hintergrundfarbe je nach Status:
|
||||
// abgeschlossen → hellgrün, bearbeitbar → weiß, gesperrt → hellgrau
|
||||
@@ -429,6 +480,7 @@ class _TaskViewState extends State<TaskView> {
|
||||
}
|
||||
|
||||
void _showTaskCompletionDialog(Task task, int taskIndex) {
|
||||
if (!_canCompleteTask(task)) return;
|
||||
switch (task) {
|
||||
case ConfirmationTask():
|
||||
_showConfirmationDialog(task, taskIndex);
|
||||
@@ -542,10 +594,12 @@ class _TaskViewState extends State<TaskView> {
|
||||
(context) => PhotoCaptureScreen(
|
||||
task: task,
|
||||
onPhotosCompleted: (List<Uint8List> photoData) async {
|
||||
if (!_canCompleteTask(task)) return;
|
||||
// Compress + encode photos for network send (limit payload)
|
||||
final List<String> base64List = await _compressAndEncodePhotos(
|
||||
photoData,
|
||||
);
|
||||
if (!_canCompleteTask(task)) return;
|
||||
final bool truncated = base64List.length < photoData.length;
|
||||
|
||||
// Try to persist full-quality (encoded) photos to DB for offline/backup
|
||||
@@ -647,6 +701,7 @@ class _TaskViewState extends State<TaskView> {
|
||||
(context) => SignatureCaptureScreen(
|
||||
task: task,
|
||||
onSignatureCompleted: (String svg, String note) async {
|
||||
if (!_canCompleteTask(task)) return;
|
||||
try {
|
||||
// Persist SVG only (no PNG)
|
||||
await _databaseService.saveTaskSignature(task.id, svg);
|
||||
@@ -658,6 +713,7 @@ class _TaskViewState extends State<TaskView> {
|
||||
);
|
||||
developer.log('Stack trace: $stackTrace', name: 'TaskView');
|
||||
}
|
||||
if (!_canCompleteTask(task)) return;
|
||||
// Store SVG for later use in this TaskView session
|
||||
setState(() {
|
||||
_signatureSvgByTask[task.id] = svg;
|
||||
@@ -690,6 +746,7 @@ class _TaskViewState extends State<TaskView> {
|
||||
(context) => BarcodeCaptureScreen(
|
||||
task: task,
|
||||
onBarcodesCompleted: (List<String> barcodes) async {
|
||||
if (!_canCompleteTask(task)) return;
|
||||
try {
|
||||
// Save barcodes to database for later use
|
||||
await _databaseService.saveTaskBarcodes(task.id, barcodes);
|
||||
@@ -758,6 +815,8 @@ class _TaskViewState extends State<TaskView> {
|
||||
String? taskType,
|
||||
Map<String, dynamic>? extraData,
|
||||
}) {
|
||||
final tasks = _visibleTasks.where((task) => task.id == taskId);
|
||||
if (tasks.isEmpty || !_canCompleteTask(tasks.first)) return;
|
||||
final bool hadOpenMandatoryBefore = _hasOpenMandatoryTasks;
|
||||
setState(() {
|
||||
_completedTasks.add(taskId);
|
||||
@@ -1000,7 +1059,7 @@ class _TaskViewState extends State<TaskView> {
|
||||
}
|
||||
}
|
||||
|
||||
String _getRemark() => widget.job.remark;
|
||||
String _getRemark() => _job.remark;
|
||||
|
||||
String? _getTaskStationLabel(Task task) {
|
||||
if (widget.stationOrder != null) {
|
||||
@@ -1011,7 +1070,7 @@ class _TaskViewState extends State<TaskView> {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (final station in widget.job.deliveryStations) {
|
||||
for (final station in _job.deliveryStations) {
|
||||
if (station.stationOrder == stationOrder) {
|
||||
final suffix =
|
||||
station.displayName.isNotEmpty ? station.displayName : station.city;
|
||||
|
||||
Reference in new issue
Block a user