Added missing dao functions
This commit is contained in:
@@ -241,6 +241,14 @@ class TeamDao extends DatabaseAccessor<AppDatabase> with _$TeamDaoMixin {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> removeAllTeamScores({required String matchId}) async {
|
||||||
|
await (update(
|
||||||
|
teamTable,
|
||||||
|
)).write(const TeamTableCompanion(score: Value(null)));
|
||||||
|
await db.scoreEntryDao.deleteAllScoresForMatch(matchId: matchId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Delete */
|
/* Delete */
|
||||||
|
|
||||||
/// Deletes all teams from the database.
|
/// Deletes all teams from the database.
|
||||||
@@ -261,6 +269,8 @@ class TeamDao extends DatabaseAccessor<AppDatabase> with _$TeamDaoMixin {
|
|||||||
|
|
||||||
/* Score handling */
|
/* Score handling */
|
||||||
|
|
||||||
|
/// Sets the team with the given [teamId] as the winner of the match with the given [matchId] by assigning a score of 1.
|
||||||
|
/// Returns `true` if the score was updated successfully, `false` otherwise.
|
||||||
Future<bool> setWinnerTeam({
|
Future<bool> setWinnerTeam({
|
||||||
required String teamId,
|
required String teamId,
|
||||||
required String matchId,
|
required String matchId,
|
||||||
@@ -268,6 +278,8 @@ class TeamDao extends DatabaseAccessor<AppDatabase> with _$TeamDaoMixin {
|
|||||||
return await updateTeamScore(teamId: teamId, matchId: matchId, score: 1);
|
return await updateTeamScore(teamId: teamId, matchId: matchId, score: 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets multiple teams as winners of the match with the given [matchId] by assigning a score of 1 to each team.
|
||||||
|
/// Returns `true` if all scores were updated successfully, `false` otherwise.
|
||||||
Future<bool> setWinnerTeams({
|
Future<bool> setWinnerTeams({
|
||||||
required List<Team> winners,
|
required List<Team> winners,
|
||||||
required String matchId,
|
required String matchId,
|
||||||
@@ -283,13 +295,14 @@ class TeamDao extends DatabaseAccessor<AppDatabase> with _$TeamDaoMixin {
|
|||||||
return success.every((result) => result == true);
|
return success.every((result) => result == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> removeWinnerTeam({
|
/// Removes the winner status from all Teams with the given [matchId] by setting its score to null.
|
||||||
required String teamId,
|
/// Returns `true` if the score was updated successfully, `false` otherwise.
|
||||||
required String matchId,
|
Future<bool> removeWinnerTeam({required String matchId}) async {
|
||||||
}) async {
|
return await removeAllTeamScores(matchId: matchId);
|
||||||
return await removeScoreForTeam(teamId: teamId, matchId: matchId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the team with the given [teamId] as the loser of the match with the given [matchId] by assigning a score of 0.
|
||||||
|
/// Returns `true` if the score was updated successfully, `false` otherwise.
|
||||||
Future<bool> setLoserTeam({
|
Future<bool> setLoserTeam({
|
||||||
required String teamId,
|
required String teamId,
|
||||||
required String matchId,
|
required String matchId,
|
||||||
@@ -297,13 +310,17 @@ class TeamDao extends DatabaseAccessor<AppDatabase> with _$TeamDaoMixin {
|
|||||||
return await updateTeamScore(teamId: teamId, matchId: matchId, score: 0);
|
return await updateTeamScore(teamId: teamId, matchId: matchId, score: 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Removes the loser status from the team with the given [teamId] in the match with the given [matchId] by setting its score to null.
|
||||||
|
/// Returns `true` if the score was updated successfully, `false` otherwise.
|
||||||
Future<bool> removeLoserTeam({
|
Future<bool> removeLoserTeam({
|
||||||
required String teamId,
|
required String teamId,
|
||||||
required String matchId,
|
required String matchId,
|
||||||
}) async {
|
}) async {
|
||||||
return await removeScoreForTeam(teamId: teamId, matchId: matchId);
|
return await removeAllTeamScores(matchId: matchId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the placements for the teams in the match with the given [matchId] by assigning scores based on their order in the [teams] list.
|
||||||
|
/// Returns `true` if all scores were updated successfully, `false` otherwise.
|
||||||
Future<bool> setTeamPlacements({
|
Future<bool> setTeamPlacements({
|
||||||
required String matchId,
|
required String matchId,
|
||||||
required List<Team> teams,
|
required List<Team> teams,
|
||||||
|
|||||||
@@ -306,10 +306,7 @@ class _MatchResultViewState extends State<MatchResultView> {
|
|||||||
Future<bool> _handleWinner() async {
|
Future<bool> _handleWinner() async {
|
||||||
if (isTeamMatch) {
|
if (isTeamMatch) {
|
||||||
if (_selectedTeam == null) {
|
if (_selectedTeam == null) {
|
||||||
return await db.teamDao.removeWinnerTeam(
|
return await db.teamDao.removeWinnerTeam(matchId: widget.match.id);
|
||||||
matchId: widget.match.id,
|
|
||||||
teamId: _selectedTeam!.id,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
return await db.teamDao.setWinnerTeam(
|
return await db.teamDao.setWinnerTeam(
|
||||||
matchId: widget.match.id,
|
matchId: widget.match.id,
|
||||||
@@ -332,7 +329,7 @@ class _MatchResultViewState extends State<MatchResultView> {
|
|||||||
Future<bool> _handleWinners() async {
|
Future<bool> _handleWinners() async {
|
||||||
if (isTeamMatch) {
|
if (isTeamMatch) {
|
||||||
if (_selectedTeams.isEmpty) {
|
if (_selectedTeams.isEmpty) {
|
||||||
return await db.scoreEntryDao.removeWinner(matchId: widget.match.id);
|
return await db.teamDao.removeWinnerTeam(matchId: widget.match.id);
|
||||||
} else {
|
} else {
|
||||||
return await db.teamDao.setWinnerTeams(
|
return await db.teamDao.setWinnerTeams(
|
||||||
matchId: widget.match.id,
|
matchId: widget.match.id,
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ class _MatchTileState extends State<MatchTile> {
|
|||||||
LayoutBuilder(
|
LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
final useSingleColumn = match.teams!.any(
|
final useSingleColumn = match.teams!.any(
|
||||||
(team) => team.name.length > 14,
|
(team) => team.name.length > 10,
|
||||||
);
|
);
|
||||||
|
|
||||||
const spacing = 8.0;
|
const spacing = 8.0;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: tallee
|
name: tallee
|
||||||
description: "Tracking App for Card Games"
|
description: "Tracking App for Card Games"
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
version: 0.0.30+325
|
version: 0.0.30+327
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.8.1
|
sdk: ^3.8.1
|
||||||
|
|||||||
Reference in New Issue
Block a user