refactor: Projektstruktur in app/ und backend/ aufgeteilt
This commit is contained in:
99
app/lib/models/tasks/photo_task.dart
Normal file
99
app/lib/models/tasks/photo_task.dart
Normal file
@@ -0,0 +1,99 @@
|
||||
import '../task.dart';
|
||||
|
||||
// Photo Task
|
||||
class PhotoTask extends Task {
|
||||
final int minPhotoCount;
|
||||
final int maxPhotoCount;
|
||||
|
||||
PhotoTask({
|
||||
required super.id,
|
||||
required super.jobId,
|
||||
required this.minPhotoCount,
|
||||
required this.maxPhotoCount,
|
||||
super.stationOrder,
|
||||
super.completed = false,
|
||||
super.optional = false,
|
||||
super.completedAt,
|
||||
super.completedBy,
|
||||
super.taskOrder,
|
||||
super.title,
|
||||
super.description,
|
||||
super.displayName,
|
||||
});
|
||||
|
||||
factory PhotoTask.fromJson(Map<String, dynamic> json) {
|
||||
final commonProps = Task.parseCommonProperties(json);
|
||||
final taskSpecificData = json['taskSpecificData'] as Map<String, dynamic>;
|
||||
|
||||
return PhotoTask(
|
||||
id: commonProps['id'],
|
||||
jobId: commonProps['jobId'],
|
||||
stationOrder: commonProps['stationOrder'],
|
||||
completed: commonProps['completed'],
|
||||
optional: commonProps['optional'],
|
||||
completedAt: commonProps['completedAt'],
|
||||
completedBy: commonProps['completedBy'],
|
||||
taskOrder: commonProps['taskOrder'],
|
||||
title: commonProps['title'],
|
||||
description: commonProps['description'],
|
||||
displayName: commonProps['displayName'],
|
||||
minPhotoCount: taskSpecificData['minPhotoCount'] ?? 1,
|
||||
maxPhotoCount: taskSpecificData['maxPhotoCount'] ?? 5,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'jobId': jobId,
|
||||
'stationOrder': stationOrder,
|
||||
'completed': completed,
|
||||
'optional': optional,
|
||||
'completedAt': completedAt?.toIso8601String(),
|
||||
'completedBy': completedBy,
|
||||
'taskOrder': taskOrder,
|
||||
'description': description,
|
||||
'displayName': displayName,
|
||||
'taskSpecificData': {
|
||||
'taskType': 'PHOTO',
|
||||
'title': title,
|
||||
'minPhotoCount': minPhotoCount,
|
||||
'maxPhotoCount': maxPhotoCount,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
PhotoTask copyWith({
|
||||
String? id,
|
||||
String? jobId,
|
||||
int? stationOrder,
|
||||
bool? completed,
|
||||
bool? optional,
|
||||
DateTime? completedAt,
|
||||
String? completedBy,
|
||||
int? taskOrder,
|
||||
String? title,
|
||||
String? description,
|
||||
String? displayName,
|
||||
int? minPhotoCount,
|
||||
int? maxPhotoCount,
|
||||
}) {
|
||||
return PhotoTask(
|
||||
id: id ?? this.id,
|
||||
jobId: jobId ?? this.jobId,
|
||||
stationOrder: stationOrder ?? this.stationOrder,
|
||||
completed: completed ?? this.completed,
|
||||
optional: optional ?? this.optional,
|
||||
completedAt: completedAt ?? this.completedAt,
|
||||
completedBy: completedBy ?? this.completedBy,
|
||||
taskOrder: taskOrder ?? this.taskOrder,
|
||||
title: title ?? this.title,
|
||||
description: description ?? this.description,
|
||||
displayName: displayName ?? this.displayName,
|
||||
minPhotoCount: minPhotoCount ?? this.minPhotoCount,
|
||||
maxPhotoCount: maxPhotoCount ?? this.maxPhotoCount,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user