add deleted attribute
This commit is contained in:
@@ -10,6 +10,7 @@ class Game {
|
||||
final String description;
|
||||
final GameColor color;
|
||||
final String icon;
|
||||
final bool deleted;
|
||||
|
||||
Game({
|
||||
String? id,
|
||||
@@ -19,6 +20,7 @@ class Game {
|
||||
String? description,
|
||||
required this.color,
|
||||
required this.icon,
|
||||
this.deleted = false,
|
||||
}) : id = id ?? const Uuid().v4(),
|
||||
createdAt = createdAt ?? clock.now(),
|
||||
description = description ?? '';
|
||||
@@ -39,7 +41,8 @@ class Game {
|
||||
),
|
||||
description = json['description'],
|
||||
color = GameColor.values.firstWhere((e) => e.name == json['color']),
|
||||
icon = json['icon'];
|
||||
icon = json['icon'],
|
||||
deleted = json['deleted'] ?? false;
|
||||
|
||||
/// Converts the Game instance to a JSON object.
|
||||
Map<String, dynamic> toJson() => {
|
||||
@@ -50,5 +53,6 @@ class Game {
|
||||
'description': description,
|
||||
'color': color.name,
|
||||
'icon': icon,
|
||||
'deleted': deleted,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ class Group {
|
||||
final String description;
|
||||
final DateTime createdAt;
|
||||
final List<Player> members;
|
||||
final bool deleted;
|
||||
|
||||
Group({
|
||||
String? id,
|
||||
@@ -15,6 +16,7 @@ class Group {
|
||||
required this.name,
|
||||
String? description,
|
||||
required this.members,
|
||||
this.deleted = false,
|
||||
}) : id = id ?? const Uuid().v4(),
|
||||
createdAt = createdAt ?? clock.now(),
|
||||
description = description ?? '';
|
||||
@@ -31,7 +33,8 @@ class Group {
|
||||
createdAt = DateTime.parse(json['createdAt']),
|
||||
name = json['name'],
|
||||
description = json['description'],
|
||||
members = [];
|
||||
members = [],
|
||||
deleted = json['deleted'] ?? false;
|
||||
|
||||
/// Converts the Group instance to a JSON object. Related [Player] objects are
|
||||
/// represented by their IDs.
|
||||
@@ -41,5 +44,6 @@ class Group {
|
||||
'name': name,
|
||||
'description': description,
|
||||
'memberIds': members.map((member) => member.id).toList(),
|
||||
'deleted': deleted,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ class Match {
|
||||
final List<Player> players;
|
||||
final String notes;
|
||||
Map<String, ScoreEntry?> scores;
|
||||
final bool deleted;
|
||||
|
||||
Match({
|
||||
required this.name,
|
||||
@@ -27,6 +28,7 @@ class Match {
|
||||
String? id,
|
||||
DateTime? createdAt,
|
||||
Map<String, ScoreEntry?>? scores,
|
||||
this.deleted = false,
|
||||
}) : id = id ?? const Uuid().v4(),
|
||||
createdAt = createdAt ?? clock.now(),
|
||||
scores = scores ?? {for (Player p in players) p.id: null};
|
||||
@@ -65,7 +67,8 @@ class Match {
|
||||
),
|
||||
)
|
||||
: {},
|
||||
notes = json['notes'] ?? '';
|
||||
notes = json['notes'] ?? '',
|
||||
deleted = json['deleted'] ?? false;
|
||||
|
||||
/// Converts the Match instance to a JSON object. Related objects are
|
||||
/// represented by their IDs, so the game, group, and players are not fully
|
||||
@@ -80,6 +83,7 @@ class Match {
|
||||
'playerIds': players.map((player) => player.id).toList(),
|
||||
'scores': scores.map((key, value) => MapEntry(key, value?.toJson())),
|
||||
'notes': notes,
|
||||
'deleted': deleted,
|
||||
};
|
||||
|
||||
List<Player> get mvp {
|
||||
|
||||
@@ -7,6 +7,7 @@ class Player {
|
||||
final String name;
|
||||
int nameCount;
|
||||
final String description;
|
||||
final bool deleted;
|
||||
|
||||
Player({
|
||||
String? id,
|
||||
@@ -14,6 +15,7 @@ class Player {
|
||||
required this.name,
|
||||
this.nameCount = 0,
|
||||
String? description,
|
||||
this.deleted = false,
|
||||
}) : id = id ?? const Uuid().v4(),
|
||||
createdAt = createdAt ?? clock.now(),
|
||||
description = description ?? '';
|
||||
@@ -29,7 +31,8 @@ class Player {
|
||||
createdAt = DateTime.parse(json['createdAt']),
|
||||
name = json['name'],
|
||||
nameCount = 0,
|
||||
description = json['description'];
|
||||
description = json['description'],
|
||||
deleted = json['deleted'] ?? false;
|
||||
|
||||
/// Converts the Player instance to a JSON object.
|
||||
Map<String, dynamic> toJson() => {
|
||||
@@ -37,5 +40,6 @@ class Player {
|
||||
'createdAt': createdAt.toIso8601String(),
|
||||
'name': name,
|
||||
'description': description,
|
||||
'deleted': deleted,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@ class ScoreEntry {
|
||||
final int roundNumber;
|
||||
final int score;
|
||||
final int change;
|
||||
final bool deleted;
|
||||
|
||||
ScoreEntry({required this.score, this.roundNumber = 0, this.change = 0});
|
||||
ScoreEntry({required this.score, this.roundNumber = 0, this.change = 0, this.deleted = false});
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@@ -13,11 +14,13 @@ class ScoreEntry {
|
||||
ScoreEntry.fromJson(Map<String, dynamic> json)
|
||||
: roundNumber = json['roundNumber'],
|
||||
score = json['score'],
|
||||
change = json['change'];
|
||||
change = json['change'],
|
||||
deleted = json['deleted'] ?? false;
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'roundNumber': roundNumber,
|
||||
'score': score,
|
||||
'change': change,
|
||||
'deleted': deleted,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,12 +7,14 @@ class Team {
|
||||
final String name;
|
||||
final DateTime createdAt;
|
||||
final List<Player> members;
|
||||
final bool deleted;
|
||||
|
||||
Team({
|
||||
String? id,
|
||||
required this.name,
|
||||
DateTime? createdAt,
|
||||
required this.members,
|
||||
this.deleted = false,
|
||||
}) : id = id ?? const Uuid().v4(),
|
||||
createdAt = createdAt ?? clock.now();
|
||||
|
||||
@@ -27,7 +29,8 @@ class Team {
|
||||
: id = json['id'],
|
||||
name = json['name'],
|
||||
createdAt = DateTime.parse(json['createdAt']),
|
||||
members = []; // Populated during import via DataTransferService
|
||||
members = [],
|
||||
deleted = json['deleted'] ?? false;
|
||||
|
||||
/// Converts the Team instance to a JSON object. Related objects are
|
||||
/// represented by their IDs.
|
||||
@@ -36,5 +39,6 @@ class Team {
|
||||
'name': name,
|
||||
'createdAt': createdAt.toIso8601String(),
|
||||
'memberIds': members.map((member) => member.id).toList(),
|
||||
'deleted': deleted,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user