Skip to content

Commit

Permalink
feat: Division and Organization
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustl22 committed Mar 19, 2024
1 parent c0b1231 commit bf182c2
Show file tree
Hide file tree
Showing 60 changed files with 2,395 additions and 664 deletions.
8 changes: 7 additions & 1 deletion wrestling_scoreboard_client/lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@
"retry": "Erneut versuchen",
"networkTimeout": "Netzwerk-Timeout",

"date": "Datum",
"place": "Ort",
"date": "Datum",
"minutes": "Minuten",
"seconds": "Sekunden",
"startDate": "Beginn",
"endDate": "Ende",

"wrestlingRulesPdf": "https://www.ringen.de/wp-content/uploads/2019/01/Internationales-Regelwerk_Januar-2019_.pdf",
"participantVacant": "unbesetzt",
Expand All @@ -94,6 +96,10 @@
"teams": "Mannschaften",
"participatingTeam": "Teilnehmende Mannschaft",
"participatingTeams": "Teilnehmende Mannschaften",
"organization": "Organisation",
"organizations": "Organisationen",
"division": "Spielklasse",
"divisions": "Spielklassen",
"league": "Liga",
"leagues": "Ligen",
"season": "Saison",
Expand Down
8 changes: 7 additions & 1 deletion wrestling_scoreboard_client/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@
"retry": "Retry",
"networkTimeout": "Network timeout",

"date": "Date",
"place": "Place",
"date": "Date",
"minutes": "Minutes",
"seconds": "Seconds",
"startDate": "Beginning",
"endDate": "End",

"wrestlingRulesPdf": "https://uww.org/sites/default/files/2019-12/wrestling_rules.pdf",
"participantVacant": "vacant",
Expand All @@ -97,6 +99,10 @@
"teams": "Teams",
"participatingTeam": "Participating Team",
"participatingTeams": "Participating Teams",
"organization": "Organization",
"organizations": "Organizations",
"division": "Division",
"divisions": "Divisions",
"league": "League",
"leagues": "Leagues",
"season": "Season",
Expand Down
56 changes: 42 additions & 14 deletions wrestling_scoreboard_client/lib/mocks/services/network/data.dart
Original file line number Diff line number Diff line change
@@ -1,25 +1,47 @@
import 'package:wrestling_scoreboard_common/common.dart';

League _leagueMenRPW = League(
const _organization = Organization(name: 'Deutscher Ringer Bund (DRB)');

final _adultDivision = Division(
id: 1,
name: 'Real Pro Wrestling',
name: 'Adult',
startDate: DateTime(2021),
endDate: DateTime(2022),
boutConfig: const BoutConfig(id: 1),
seasonPartitions: 2,
organization: _organization,
);
League _leagueJnRPW = League(

final _juniorDivision = Division(
id: 2,
name: 'Real Pro Wrestling Jn',
name: 'Junior',
startDate: DateTime(2021),
boutConfig: const BoutConfig(id: 2),
endDate: DateTime(2022),
boutConfig: const BoutConfig(id: 1),
seasonPartitions: 2,
organization: _organization,
);
League _leagueNational = League(

final _leagueMenRPW = League(
id: 1,
name: 'Real Pro Wrestling',
startDate: DateTime(2021),
endDate: DateTime(2022),
division: _adultDivision,
);
final _leagueJnRPW = League(
id: 2,
name: 'Real Pro Wrestling Jn',
startDate: DateTime(2021),
endDate: DateTime(2022),
division: _juniorDivision,
);
final _leagueNational = League(
id: 3,
name: 'National League',
startDate: DateTime(2021),
boutConfig: const BoutConfig(id: 3),
seasonPartitions: 2,
endDate: DateTime(2022),
division: _adultDivision,
);

Club _homeClub = const Club(id: 1, name: 'Springfield Wrestlers');
Expand Down Expand Up @@ -85,8 +107,10 @@ Membership b4 = Membership(id: 8, person: p8, club: _guestClub);
final List<Club> _clubs = [_homeClub, _guestClub];
final List<Bout> _bouts = [];
final List<BoutAction> _boutActions = []; // TODO fill
final List<Organization> _organizations = [_organization];
final List<Division> _divisions = [_juniorDivision, _adultDivision];
final List<League> _leagues = [_leagueMenRPW, _leagueJnRPW, _leagueNational];
final List<LeagueWeightClass> _leagueWeightClasses = []; // TODO fill
final List<DivisionWeightClass> _divisionWeightClasses = []; // TODO fill
final List<LeagueTeamParticipation> _leagueTeamParticipations = [_htMenRPW, _gtMenRPW, _htjJnRPW, _htNat, _gtNat];
final List<Lineup> _lineups = [];
final List<Membership> _memberships = [r1, r2, r3, r4, b1, b2, b3, b4];
Expand Down Expand Up @@ -162,12 +186,16 @@ List<BoutAction> getBoutActions() => _boutActions;

List<BoutAction> getBoutActionsOfBout(Bout bout) => getBoutActions().where((element) => element.bout == bout).toList();

List<Organization> getOrganizations() => _organizations;

List<Division> getDivisions() => _divisions;

List<League> getLeagues() => _leagues;

List<LeagueWeightClass> getLeagueWeightClasses() => _leagueWeightClasses;
List<DivisionWeightClass> getDivisionWeightClasses() => _divisionWeightClasses;

List<LeagueWeightClass> getLeagueWeightClassesOfLeague(League league) {
return getLeagueWeightClasses().where((element) => element.league == league).toList();
List<DivisionWeightClass> getDivisionWeightClassesOfDivision(Division division) {
return getDivisionWeightClasses().where((element) => element.division == division).toList();
}

List<LeagueTeamParticipation> getLeagueTeamParticipations() => _leagueTeamParticipations;
Expand Down Expand Up @@ -224,8 +252,8 @@ List<CompetitionBout> getCompetitionBouts() => _competitionBouts;

List<WeightClass> getWeightClasses() => _weightClasses;

List<WeightClass> getWeightClassesOfLeague(League league) {
return (getLeagueWeightClassesOfLeague(league).toList()..sort((a, b) => a.pos - b.pos))
List<WeightClass> getWeightClassesOfDivision(Division league) {
return (getDivisionWeightClassesOfDivision(league).toList()..sort((a, b) => a.pos - b.pos))
.map((e) => e.weightClass)
.toList();
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ class MockDataManager extends DataManager {
if (filterObject is Team) return getTeamMatchesOfTeam(filterObject).cast<T>();
throw DataUnimplementedError(CRUD.read, T, filterObject);
case const (WeightClass):
// TODO may remove in favor of getLeagueWeightClassesOfLeague
if (filterObject is League) return getWeightClassesOfLeague(filterObject).cast<T>();
// TODO may remove in favor of getDivisionWeightClassesOfLeague
if (filterObject is Division) return getWeightClassesOfDivision(filterObject).cast<T>();
throw DataUnimplementedError(CRUD.read, T, filterObject);
case const (LeagueWeightClass):
if (filterObject is League) return getLeagueWeightClassesOfLeague(filterObject).cast<T>();
case const (DivisionWeightClass):
if (filterObject is Division) return getDivisionWeightClassesOfDivision(filterObject).cast<T>();
throw DataUnimplementedError(CRUD.read, T, filterObject);
case const (LeagueTeamParticipation):
if (filterObject is League) return getLeagueTeamParticipationsOfLeague(filterObject).cast<T>();
Expand Down Expand Up @@ -238,11 +238,11 @@ class MockDataManager extends DataManager {
));
} else if (single is League) {
getManyStreamController<League>()?.add(ManyDataObject(data: getLeagues()));
} else if (single is LeagueWeightClass) {
getManyStreamController<LeagueWeightClass>(filterType: League)?.add(ManyDataObject(
data: getLeagueWeightClassesOfLeague(single.league),
} else if (single is DivisionWeightClass) {
getManyStreamController<DivisionWeightClass>(filterType: League)?.add(ManyDataObject(
data: getDivisionWeightClassesOfDivision(single.division),
filterType: League,
filterId: single.league.id,
filterId: single.division.id,
));
} else if (single is Lineup) {
// No filtered list needs to be handled.
Expand Down Expand Up @@ -296,10 +296,14 @@ class MockDataManager extends DataManager {
return getBouts().cast<T>();
} else if (obj is BoutAction) {
return getBoutActions().cast<T>();
} else if (obj is Organization) {
return getOrganizations().cast<T>();
} else if (obj is Division) {
return getDivisions().cast<T>();
} else if (obj is League) {
return getLeagues().cast<T>();
} else if (obj is LeagueWeightClass) {
return getLeagueWeightClasses().cast<T>();
} else if (obj is DivisionWeightClass) {
return getDivisionWeightClasses().cast<T>();
} else if (obj is Lineup) {
return getLineups().cast<T>();
} else if (obj is Membership) {
Expand Down Expand Up @@ -331,10 +335,14 @@ class MockDataManager extends DataManager {
return getBouts().cast<T>();
case const (BoutAction):
return getBoutActions().cast<T>();
case const (Organization):
return getOrganizations().cast<T>();
case const (Division):
return getDivisions().cast<T>();
case const (League):
return getLeagues().cast<T>();
case const (LeagueWeightClass):
return getLeagueWeightClasses().cast<T>();
case const (DivisionWeightClass):
return getDivisionWeightClasses().cast<T>();
case const (Lineup):
return getLineups().cast<T>();
case const (Membership):
Expand Down Expand Up @@ -365,10 +373,14 @@ class MockDataManager extends DataManager {
return getSingleStreamController<Bout>() as StreamController<T>;
} else if (obj is BoutAction) {
return getSingleStreamController<BoutAction>() as StreamController<T>;
} else if (obj is Organization) {
return getSingleStreamController<Organization>() as StreamController<T>;
} else if (obj is Division) {
return getSingleStreamController<Division>() as StreamController<T>;
} else if (obj is League) {
return getSingleStreamController<League>() as StreamController<T>;
} else if (obj is LeagueWeightClass) {
return getSingleStreamController<LeagueWeightClass>() as StreamController<T>;
} else if (obj is DivisionWeightClass) {
return getSingleStreamController<DivisionWeightClass>() as StreamController<T>;
} else if (obj is Lineup) {
return getSingleStreamController<Lineup>() as StreamController<T>;
} else if (obj is Membership) {
Expand Down
16 changes: 13 additions & 3 deletions wrestling_scoreboard_client/lib/routes/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import 'package:wrestling_scoreboard_client/view/screens/display/bout/bout_displ
import 'package:wrestling_scoreboard_client/view/screens/display/match/match_display.dart';
import 'package:wrestling_scoreboard_client/view/screens/overview/club_overview.dart';
import 'package:wrestling_scoreboard_client/view/screens/overview/membership_overview.dart';
import 'package:wrestling_scoreboard_client/view/screens/overview/organization_overview.dart';
import 'package:wrestling_scoreboard_client/view/screens/overview/team_match/division_overview.dart';
import 'package:wrestling_scoreboard_client/view/screens/overview/team_match/league_overview.dart';
import 'package:wrestling_scoreboard_client/view/screens/overview/team_match/league_team_participation_overview.dart';
import 'package:wrestling_scoreboard_client/view/screens/overview/team_match/league_weight_class_overview.dart';
import 'package:wrestling_scoreboard_client/view/screens/overview/team_match/division_weight_class_overview.dart';
import 'package:wrestling_scoreboard_client/view/screens/overview/team_match/team_match_bout_overview.dart';
import 'package:wrestling_scoreboard_client/view/screens/overview/team_match/team_match_overview.dart';
import 'package:wrestling_scoreboard_client/view/screens/overview/team_overview.dart';
Expand All @@ -22,6 +24,14 @@ final router = GoRouter(
path: '${ClubOverview.route}/:club_id',
builder: (context, state) => ClubOverview(id: int.parse(state.pathParameters['club_id']!)),
),
GoRoute(
path: '${OrganizationOverview.route}/:organization_id',
builder: (context, state) => OrganizationOverview(id: int.parse(state.pathParameters['organization_id']!)),
),
GoRoute(
path: '${DivisionOverview.route}/:division_id',
builder: (context, state) => DivisionOverview(id: int.parse(state.pathParameters['division_id']!)),
),
GoRoute(
path: '${LeagueOverview.route}/:league_id',
builder: (context, state) => LeagueOverview(id: int.parse(state.pathParameters['league_id']!)),
Expand Down Expand Up @@ -50,9 +60,9 @@ final router = GoRouter(
LeagueTeamParticipationOverview(id: int.parse(state.pathParameters['participation_id']!)),
),
GoRoute(
path: '${LeagueWeightClassOverview.route}/:league_weight_class_id',
path: '${DivisionWeightClassOverview.route}/:division_weight_class_id',
builder: (context, state) =>
LeagueWeightClassOverview(id: int.parse(state.pathParameters['league_weight_class_id']!)),
DivisionWeightClassOverview(id: int.parse(state.pathParameters['division_weight_class_id']!)),
),
GoRoute(
path: '${TeamMatchBoutOverview.route}/:team_match_bout_id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class TeamMatchBoutDisplay extends StatelessWidget {
builder: (context, bout) {
return BoutScreen(
wrestlingEvent: match,
boutConfig: match.league?.boutConfig ?? const BoutConfig(),
boutConfig: match.league?.division.boutConfig ?? const BoutConfig(),
bouts: teamMatchBouts.map((e) => e.bout).toList(),
boutIndex: teamMatchBoutIndex,
bout: bout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MatchDisplay extends StatelessWidget {
filterObject: match,
builder: (context, teamMatchBouts) {
final matchInfos = [
match.league?.name,
match.league?.fullname,
'${AppLocalizations.of(context)!.boutNo}: ${match.id ?? ''}',
if (match.referee != null)
'${AppLocalizations.of(context)!.refereeAbbr}: ${match.referee?.fullName}',
Expand Down
47 changes: 29 additions & 18 deletions wrestling_scoreboard_client/lib/view/screens/edit/lineup_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class LineupEdit extends ConsumerStatefulWidget {
class LineupEditState extends ConsumerState<LineupEdit> {
final _formKey = GlobalKey<FormState>();

Iterable<Membership>? memberships;
Iterable<Membership>? _memberships;

Membership? _leader;
Membership? _coach;
Expand Down Expand Up @@ -120,7 +120,10 @@ class LineupEditState extends ConsumerState<LineupEdit> {
_leader = value;
}),
itemAsString: (u) => u.person.fullName,
onFind: (String? filter) => ParticipationEditTile.filterMemberships(ref, filter, widget.lineup),
onFind: (String? filter) async {
_memberships ??= await _getMemberships(ref, club: widget.lineup.team.club);
return _filterMemberships(ref, filter, widget.lineup, _memberships!);
},
),
),
ListTile(
Expand All @@ -132,7 +135,10 @@ class LineupEditState extends ConsumerState<LineupEdit> {
_coach = value;
}),
itemAsString: (u) => u.person.fullName,
onFind: (String? filter) => ParticipationEditTile.filterMemberships(ref, filter, widget.lineup),
onFind: (String? filter) async {
_memberships ??= await _getMemberships(ref, club: widget.lineup.team.club);
return _filterMemberships(ref, filter, widget.lineup, _memberships!);
},
),
),
..._participations.entries.map((mapEntry) {
Expand Down Expand Up @@ -166,25 +172,13 @@ class ParticipationEditTile extends ConsumerStatefulWidget {
required this.createOrUpdateParticipation,
});

static Future<List<Membership>> filterMemberships(
WidgetRef ref,
String? filter,
Lineup lineup,
) async {
final memberships = await _getMemberships(ref, club: lineup.team.club);
return (filter == null ? memberships : memberships.where((element) => element.person.fullName.contains(filter)))
.toList();
}

static Future<List<Membership>> _getMemberships(WidgetRef ref, {required Club club}) async {
return ref.watch(manyDataStreamProvider<Membership, Club>(ManyProviderData(filterObject: club)).future);
}

@override
ConsumerState<ParticipationEditTile> createState() => _ParticipationEditTileState();
}

class _ParticipationEditTileState extends ConsumerState<ParticipationEditTile> {
Iterable<Membership>? _memberships;

Membership? _curMembership;
double? _curWeight;

Expand Down Expand Up @@ -245,7 +239,10 @@ class _ParticipationEditTileState extends ConsumerState<ParticipationEditTile> {
},
onSaved: (Membership? newMembership) => onSave(),
itemAsString: (u) => u.person.fullName,
onFind: (String? filter) => ParticipationEditTile.filterMemberships(ref, filter, widget.lineup),
onFind: (String? filter) async {
_memberships ??= await _getMemberships(ref, club: widget.lineup.team.club);
return _filterMemberships(ref, filter, widget.lineup, _memberships!);
},
),
),
),
Expand Down Expand Up @@ -273,3 +270,17 @@ class _ParticipationEditTileState extends ConsumerState<ParticipationEditTile> {
);
}
}

Future<List<Membership>> _filterMemberships(
WidgetRef ref,
String? filter,
Lineup lineup,
Iterable<Membership> memberships,
) async {
return (filter == null ? memberships : memberships.where((element) => element.person.fullName.contains(filter)))
.toList();
}

Future<List<Membership>> _getMemberships(WidgetRef ref, {required Club club}) async {
return ref.watch(manyDataStreamProvider<Membership, Club>(ManyProviderData(filterObject: club)).future);
}
Loading

0 comments on commit bf182c2

Please sign in to comment.