add deleted attribute
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 45s
Pull Request Pipeline / lint (pull_request) Successful in 46s

This commit is contained in:
gelbeinhalb
2026-04-30 11:56:15 +02:00
parent 1ec1df3514
commit 66e657235a
6 changed files with 30 additions and 7 deletions

View File

@@ -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,
};
}

View File

@@ -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,
};
}

View File

@@ -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 {

View File

@@ -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,
};
}

View File

@@ -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,
};
}

View File

@@ -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,
};
}