1
0
mirror of https://github.com/go-vikunja/app synced 2024-06-02 18:49:47 +00:00

make models' created, updated, & lists non late

This commit is contained in:
Paul Nettleton 2022-09-04 14:06:35 -05:00
parent 8191c83c36
commit 0633839f82
7 changed files with 25 additions and 39 deletions

View File

@ -8,10 +8,10 @@ class Bucket {
int id, listId, limit;
String title;
double? position;
late final DateTime created, updated;
final DateTime created, updated;
User createdBy;
bool isDoneBucket;
late final List<Task> tasks;
final List<Task> tasks;
Bucket({
this.id = -1,
@ -24,11 +24,9 @@ class Bucket {
DateTime? updated,
required this.createdBy,
List<Task>? tasks,
}) {
this.created = created ?? DateTime.now();
this.updated = created ?? DateTime.now();
this.tasks = tasks ?? [];
}
}) : this.created = created ?? DateTime.now(),
this.updated = created ?? DateTime.now(),
this.tasks = tasks ?? [];
Bucket.fromJSON(Map<String, dynamic> json)
: id = json['id'],

View File

@ -6,7 +6,7 @@ import 'package:vikunja_app/theme/constants.dart';
class Label {
final int id;
final String title, description;
late final DateTime created, updated;
final DateTime created, updated;
final User createdBy;
final Color? color;
@ -20,10 +20,8 @@ class Label {
DateTime? created,
DateTime? updated,
required this.createdBy,
}) {
this.created = created ?? DateTime.now();
this.updated = updated ?? DateTime.now();
}
}) : this.created = created ?? DateTime.now(),
this.updated = updated ?? DateTime.now();
Label.fromJson(Map<String, dynamic> json)
: id = json['id'],

View File

@ -6,8 +6,8 @@ class TaskList {
int namespaceId;
String title, description;
final User owner;
late final DateTime created, updated;
late final List<Task> tasks;
final DateTime created, updated;
final List<Task> tasks;
final bool isFavorite;
TaskList({
@ -20,11 +20,9 @@ class TaskList {
DateTime? updated,
List<Task>? tasks,
this.isFavorite = false,
}) {
this.created = created ?? DateTime.now();
this.updated = updated ?? DateTime.now();
this.tasks = tasks ?? [];
}
}) : this.created = created ?? DateTime.now(),
this.updated = updated ?? DateTime.now(),
this.tasks = tasks ?? [];
TaskList.fromJson(Map<String, dynamic> json)
: id = json['id'],

View File

@ -2,7 +2,7 @@ import 'package:vikunja_app/models/user.dart';
class Namespace {
final int id;
late final DateTime created, updated;
final DateTime created, updated;
final String title, description;
final User owner;
@ -13,10 +13,8 @@ class Namespace {
required this.title,
this.description = '',
required this.owner,
}) {
this.created = created ?? DateTime.now();
this.updated = updated ?? DateTime.now();
}
}) : this.created = created ?? DateTime.now(),
this.updated = updated ?? DateTime.now();
Namespace.fromJson(Map<String, dynamic> json)
: title = json['title'],

View File

@ -11,7 +11,7 @@ class Task {
final int id;
final int? parentTaskId, priority, bucketId;
final int listId;
late final DateTime created, updated;
final DateTime created, updated;
final DateTime? dueDate, startDate, endDate;
final List<DateTime> reminderDates;
final String identifier;
@ -26,7 +26,7 @@ class Task {
final List<TaskAttachment> attachments;
// TODO: add position(?)
late final CheckboxStatistics checkboxStatistics = getCheckboxStatistics(description);
late final checkboxStatistics = getCheckboxStatistics(description);
late final hasCheckboxes = checkboxStatistics.total != 0;
late final textColor = (color != null && color!.computeLuminance() > 0.5) ? Colors.black : Colors.white;
late final hasDueDate = dueDate?.year != 1;
@ -54,10 +54,8 @@ class Task {
required this.createdBy,
required this.listId,
this.bucketId,
}) {
this.created = DateTime.now();
this.updated = DateTime.now();
}
}) : this.created = created ?? DateTime.now(),
this.updated = updated ?? DateTime.now();
bool loading = false;

View File

@ -5,7 +5,7 @@ import 'package:vikunja_app/models/user.dart';
@JsonSerializable()
class TaskAttachment {
final int id, taskId;
late final DateTime created;
final DateTime created;
final User createdBy;
// TODO: add file
@ -14,9 +14,7 @@ class TaskAttachment {
required this.taskId,
DateTime? created,
required this.createdBy,
}) {
this.created = created ?? DateTime.now();
}
}) : this.created = created ?? DateTime.now();
TaskAttachment.fromJSON(Map<String, dynamic> json)
: id = json['id'],

View File

@ -4,7 +4,7 @@ import 'package:vikunja_app/global.dart';
class User {
final int id;
final String name, username;
late final DateTime created, updated;
final DateTime created, updated;
User({
this.id = -1,
@ -12,10 +12,8 @@ class User {
required this.username,
DateTime? created,
DateTime? updated,
}) {
this.created = created ?? DateTime.now();
this.updated = updated ?? DateTime.now();
}
}) : this.created = created ?? DateTime.now(),
this.updated = updated ?? DateTime.now();
User.fromJson(Map<String, dynamic> json)
: id = json['id'],