This commit is contained in:
parent
75f6608863
commit
9606fe4ad6
|
@ -2,47 +2,70 @@ import 'package:vikunja_app/models/user.dart';
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
class Task {
|
class Task {
|
||||||
final int id;
|
final int id, parentTaskID, priority;
|
||||||
final DateTime created, updated, due;
|
final DateTime created, updated, dueDate, startDate, endDate;
|
||||||
final List<DateTime> reminders;
|
final List<DateTime> reminderDates;
|
||||||
final String text, description;
|
final String text, description;
|
||||||
final bool done;
|
final bool done;
|
||||||
final User owner;
|
final User createdBy;
|
||||||
|
final Duration repeatAfter;
|
||||||
|
final List<Task> subtasks;
|
||||||
|
|
||||||
|
//labels
|
||||||
|
|
||||||
Task(
|
Task(
|
||||||
{@required this.id,
|
{@required this.id,
|
||||||
|
this.text,
|
||||||
|
this.description,
|
||||||
|
this.done,
|
||||||
|
this.reminderDates,
|
||||||
|
this.dueDate,
|
||||||
|
this.startDate,
|
||||||
|
this.endDate,
|
||||||
|
this.parentTaskID,
|
||||||
|
this.priority,
|
||||||
|
this.repeatAfter,
|
||||||
|
this.subtasks,
|
||||||
this.created,
|
this.created,
|
||||||
this.updated,
|
this.updated,
|
||||||
this.reminders,
|
this.createdBy});
|
||||||
this.due,
|
|
||||||
@required this.text,
|
|
||||||
this.description,
|
|
||||||
@required this.done,
|
|
||||||
@required this.owner});
|
|
||||||
|
|
||||||
Task.fromJson(Map<String, dynamic> json)
|
Task.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
updated = DateTime.fromMillisecondsSinceEpoch(json['updated']),
|
text = json['text'],
|
||||||
created = DateTime.fromMillisecondsSinceEpoch(json['created']),
|
description = json['description'],
|
||||||
reminders = (json['reminderDates'] as List<dynamic>)
|
done = json['done'],
|
||||||
|
reminderDates = (json['reminderDates'] as List<dynamic>)
|
||||||
?.map((milli) => DateTime.fromMillisecondsSinceEpoch(milli))
|
?.map((milli) => DateTime.fromMillisecondsSinceEpoch(milli))
|
||||||
?.toList(),
|
?.toList(),
|
||||||
due = DateTime.fromMillisecondsSinceEpoch(json['dueDate']),
|
dueDate = DateTime.fromMillisecondsSinceEpoch(json['dueDate']),
|
||||||
description = json['description'],
|
startDate = DateTime.fromMillisecondsSinceEpoch(json['startDate']),
|
||||||
text = json['text'],
|
endDate = DateTime.fromMillisecondsSinceEpoch(json['endDate']),
|
||||||
done = json['done'],
|
parentTaskID = json['parentTaskID'],
|
||||||
owner = User.fromJson(json['createdBy']);
|
priority = json['priority'],
|
||||||
|
repeatAfter = Duration(seconds: json['repeatAfter']),
|
||||||
|
subtasks = (json['subtasks'] as List<dynamic>)
|
||||||
|
?.map((subtask) => Task.fromJson(subtask))
|
||||||
|
?.toList(),
|
||||||
|
updated = DateTime.fromMillisecondsSinceEpoch(json['updated']),
|
||||||
|
created = DateTime.fromMillisecondsSinceEpoch(json['created']),
|
||||||
|
createdBy = User.fromJson(json['createdBy']);
|
||||||
|
|
||||||
toJSON() => {
|
toJSON() => {
|
||||||
'id': id,
|
'id': id,
|
||||||
|
'text': text,
|
||||||
|
'description': description,
|
||||||
|
'done': done ?? false,
|
||||||
|
'reminderDates':
|
||||||
|
reminderDates?.map((date) => date.millisecondsSinceEpoch)?.toList(),
|
||||||
|
'dueDate': dueDate?.millisecondsSinceEpoch,
|
||||||
|
'startDate': startDate?.millisecondsSinceEpoch,
|
||||||
|
'endDate': endDate?.millisecondsSinceEpoch,
|
||||||
|
'priority': priority,
|
||||||
|
'repeatAfter': repeatAfter.inSeconds,
|
||||||
|
'subtasks': subtasks?.map((subtask) => subtask.toJSON())?.toList(),
|
||||||
|
'createdBy': createdBy?.toJSON(),
|
||||||
'updated': updated?.millisecondsSinceEpoch,
|
'updated': updated?.millisecondsSinceEpoch,
|
||||||
'created': created?.millisecondsSinceEpoch,
|
'created': created?.millisecondsSinceEpoch,
|
||||||
'reminderDates':
|
|
||||||
reminders?.map((date) => date.millisecondsSinceEpoch)?.toList(),
|
|
||||||
'dueDate': due?.millisecondsSinceEpoch,
|
|
||||||
'description': description,
|
|
||||||
'text': text,
|
|
||||||
'done': done ?? false,
|
|
||||||
'createdBy': owner?.toJSON()
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue
Block a user