forked from vikunja/app
Added label model
This commit is contained in:
parent
9606fe4ad6
commit
fcfca5dfff
37
lib/models/label.dart
Normal file
37
lib/models/label.dart
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
import 'package:vikunja_app/models/user.dart';
|
||||||
|
|
||||||
|
class Label {
|
||||||
|
final int id;
|
||||||
|
final String title, description, hexColor;
|
||||||
|
final DateTime created, updated;
|
||||||
|
final User createdBy;
|
||||||
|
|
||||||
|
Label(
|
||||||
|
{@required this.id,
|
||||||
|
this.title,
|
||||||
|
this.description,
|
||||||
|
this.hexColor,
|
||||||
|
this.created,
|
||||||
|
this.updated,
|
||||||
|
this.createdBy});
|
||||||
|
|
||||||
|
Label.fromJson(Map<String, dynamic> json)
|
||||||
|
: id = json['id'],
|
||||||
|
title = json['title'],
|
||||||
|
description = json['description'],
|
||||||
|
hexColor = json['hex_color'],
|
||||||
|
updated = DateTime.fromMillisecondsSinceEpoch(json['updated']),
|
||||||
|
created = DateTime.fromMillisecondsSinceEpoch(json['created']),
|
||||||
|
createdBy = User.fromJson(json['created_by']);
|
||||||
|
|
||||||
|
toJSON() => {
|
||||||
|
'id': id,
|
||||||
|
'title': title,
|
||||||
|
'description': description,
|
||||||
|
'hex_color': description,
|
||||||
|
'created_by': createdBy?.toJSON(),
|
||||||
|
'updated': updated?.millisecondsSinceEpoch,
|
||||||
|
'created': created?.millisecondsSinceEpoch,
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
import 'package:vikunja_app/models/user.dart';
|
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
import 'package:vikunja_app/models/label.dart';
|
||||||
|
import 'package:vikunja_app/models/user.dart';
|
||||||
|
|
||||||
class Task {
|
class Task {
|
||||||
final int id, parentTaskID, priority;
|
final int id, parentTaskID, priority;
|
||||||
final DateTime created, updated, dueDate, startDate, endDate;
|
final DateTime created, updated, dueDate, startDate, endDate;
|
||||||
|
@ -10,8 +12,7 @@ class Task {
|
||||||
final User createdBy;
|
final User createdBy;
|
||||||
final Duration repeatAfter;
|
final Duration repeatAfter;
|
||||||
final List<Task> subtasks;
|
final List<Task> subtasks;
|
||||||
|
final List<Label> labels;
|
||||||
//labels
|
|
||||||
|
|
||||||
Task(
|
Task(
|
||||||
{@required this.id,
|
{@required this.id,
|
||||||
|
@ -26,6 +27,7 @@ class Task {
|
||||||
this.priority,
|
this.priority,
|
||||||
this.repeatAfter,
|
this.repeatAfter,
|
||||||
this.subtasks,
|
this.subtasks,
|
||||||
|
this.labels,
|
||||||
this.created,
|
this.created,
|
||||||
this.updated,
|
this.updated,
|
||||||
this.createdBy});
|
this.createdBy});
|
||||||
|
@ -44,6 +46,9 @@ class Task {
|
||||||
parentTaskID = json['parentTaskID'],
|
parentTaskID = json['parentTaskID'],
|
||||||
priority = json['priority'],
|
priority = json['priority'],
|
||||||
repeatAfter = Duration(seconds: json['repeatAfter']),
|
repeatAfter = Duration(seconds: json['repeatAfter']),
|
||||||
|
labels = (json['labels'] as List<dynamic>)
|
||||||
|
?.map((label) => Label.fromJson(label))
|
||||||
|
?.toList(),
|
||||||
subtasks = (json['subtasks'] as List<dynamic>)
|
subtasks = (json['subtasks'] as List<dynamic>)
|
||||||
?.map((subtask) => Task.fromJson(subtask))
|
?.map((subtask) => Task.fromJson(subtask))
|
||||||
?.toList(),
|
?.toList(),
|
||||||
|
@ -63,6 +68,7 @@ class Task {
|
||||||
'endDate': endDate?.millisecondsSinceEpoch,
|
'endDate': endDate?.millisecondsSinceEpoch,
|
||||||
'priority': priority,
|
'priority': priority,
|
||||||
'repeatAfter': repeatAfter.inSeconds,
|
'repeatAfter': repeatAfter.inSeconds,
|
||||||
|
'labels': labels?.map((label) => label.toJSON())?.toList(),
|
||||||
'subtasks': subtasks?.map((subtask) => subtask.toJSON())?.toList(),
|
'subtasks': subtasks?.map((subtask) => subtask.toJSON())?.toList(),
|
||||||
'createdBy': createdBy?.toJSON(),
|
'createdBy': createdBy?.toJSON(),
|
||||||
'updated': updated?.millisecondsSinceEpoch,
|
'updated': updated?.millisecondsSinceEpoch,
|
||||||
|
|
|
@ -39,7 +39,7 @@ var _tasks = {
|
||||||
1: Task(
|
1: Task(
|
||||||
id: 1,
|
id: 1,
|
||||||
text: 'Task 1',
|
text: 'Task 1',
|
||||||
owner: _users[1],
|
createdBy: _users[1],
|
||||||
updated: DateTime.now(),
|
updated: DateTime.now(),
|
||||||
created: DateTime.now(),
|
created: DateTime.now(),
|
||||||
description: 'A descriptive task',
|
description: 'A descriptive task',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user