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