mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
add reference from log to meal
This commit is contained in:
@@ -31,6 +31,9 @@ class Log {
|
||||
@JsonKey(required: true)
|
||||
int? id;
|
||||
|
||||
@JsonKey(required: false, name: 'meal')
|
||||
late int? mealId;
|
||||
|
||||
@JsonKey(required: true, name: 'plan')
|
||||
int planId;
|
||||
|
||||
@@ -56,6 +59,7 @@ class Log {
|
||||
|
||||
Log({
|
||||
this.id,
|
||||
required this.mealId,
|
||||
required this.ingredientId,
|
||||
required this.weightUnitId,
|
||||
required this.amount,
|
||||
@@ -70,6 +74,7 @@ class Log {
|
||||
weightUnitId = mealItem.weightUnitId;
|
||||
datetime = dateTime ?? DateTime.now();
|
||||
amount = mealItem.amount;
|
||||
mealId = mealItem.id;
|
||||
}
|
||||
|
||||
// Boilerplate
|
||||
|
||||
@@ -8,13 +8,14 @@ part of 'log.dart';
|
||||
|
||||
Log _$LogFromJson(Map<String, dynamic> json) {
|
||||
$checkKeys(json,
|
||||
requiredKeys: const ['id', 'plan', 'datetime', 'ingredient', 'weight_unit', 'amount']);
|
||||
requiredKeys: const ['id', 'meal', 'plan', 'datetime', 'ingredient', 'weight_unit', 'amount']);
|
||||
return Log(
|
||||
id: json['id'] as int?,
|
||||
ingredientId: json['ingredient'] as int,
|
||||
weightUnitId: json['weight_unit'] as int?,
|
||||
amount: stringToNum(json['amount'] as String?),
|
||||
planId: json['plan'] as int,
|
||||
mealId: json['meal'] as int,
|
||||
datetime: DateTime.parse(json['datetime'] as String),
|
||||
comment: json['comment'] as String?,
|
||||
);
|
||||
@@ -22,6 +23,7 @@ Log _$LogFromJson(Map<String, dynamic> json) {
|
||||
|
||||
Map<String, dynamic> _$LogToJson(Log instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'meal': instance.mealId,
|
||||
'plan': instance.planId,
|
||||
'datetime': instance.datetime.toIso8601String(),
|
||||
'comment': instance.comment,
|
||||
|
||||
Reference in New Issue
Block a user