Erweiterung der Teamformatierungsfunktionen um Altersgruppen für bessere Anzeige in Spielplänen
This commit is contained in:
@@ -58,9 +58,9 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-sm text-gray-800">
|
<p class="text-sm text-gray-800">
|
||||||
{{ formatMatchTeamName(game.HeimMannschaft, game.HeimMannschaftAltersklasse) }}
|
{{ formatMatchTeamName(game.HeimMannschaft, game.HeimMannschaftAltersklasse, game.Altersklasse) }}
|
||||||
vs
|
vs
|
||||||
{{ formatMatchTeamName(game.GastMannschaft, game.GastMannschaftAltersklasse) }}
|
{{ formatMatchTeamName(game.GastMannschaft, game.GastMannschaftAltersklasse, game.Altersklasse) }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -97,8 +97,8 @@ const widgetTitle = computed(() => {
|
|||||||
return formatTeamDisplayName(props.teamName, props.teamAgeGroup)
|
return formatTeamDisplayName(props.teamName, props.teamAgeGroup)
|
||||||
})
|
})
|
||||||
|
|
||||||
function formatMatchTeamName(teamName, teamAgeGroup) {
|
function formatMatchTeamName(teamName, teamAgeGroup, competitionAgeGroup) {
|
||||||
return formatTeamDisplayName(teamName, teamAgeGroup) || '-'
|
return formatTeamDisplayName(teamName, teamAgeGroup, competitionAgeGroup) || '-'
|
||||||
}
|
}
|
||||||
|
|
||||||
const seasonLabel = computed(() => {
|
const seasonLabel = computed(() => {
|
||||||
|
|||||||
@@ -216,7 +216,7 @@
|
|||||||
<div class="h-3 w-px shrink-0 bg-primary-700" />
|
<div class="h-3 w-px shrink-0 bg-primary-700" />
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
to="/mannschaften/spielplaene"
|
to="/mannschaften/spielplaene"
|
||||||
class="shrink-0 px-2.5 py-1 text-xs text-gray-300 hover:text-white hover:bg-primary-700/50 rounded transition-all"
|
class="shrink-0 whitespace-nowrap px-2.5 py-1 text-xs text-gray-300 hover:text-white hover:bg-primary-700/50 rounded transition-all"
|
||||||
active-class="text-white bg-primary-600"
|
active-class="text-white bg-primary-600"
|
||||||
>
|
>
|
||||||
Spielpläne
|
Spielpläne
|
||||||
|
|||||||
@@ -146,7 +146,7 @@
|
|||||||
Heim
|
Heim
|
||||||
</p>
|
</p>
|
||||||
<p class="font-semibold text-gray-900">
|
<p class="font-semibold text-gray-900">
|
||||||
{{ formatTeamName(game.HeimMannschaft, game.HeimMannschaftAltersklasse) }}
|
{{ formatTeamName(game.HeimMannschaft, game.HeimMannschaftAltersklasse, game.Altersklasse) }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center mx-4">
|
<div class="text-center mx-4">
|
||||||
@@ -159,7 +159,7 @@
|
|||||||
Gast
|
Gast
|
||||||
</p>
|
</p>
|
||||||
<p class="font-semibold text-gray-900">
|
<p class="font-semibold text-gray-900">
|
||||||
{{ formatTeamName(game.GastMannschaft, game.GastMannschaftAltersklasse) }}
|
{{ formatTeamName(game.GastMannschaft, game.GastMannschaftAltersklasse, game.Altersklasse) }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -356,10 +356,10 @@ const formatTime = (terminString) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatTeamName = (teamName, ageGroup) => {
|
const formatTeamName = (teamName, ageGroup, competitionAgeGroup) => {
|
||||||
if (!teamName) return 'Nicht angegeben'
|
if (!teamName) return 'Nicht angegeben'
|
||||||
|
|
||||||
return formatTeamDisplayName(teamName, ageGroup)
|
return formatTeamDisplayName(teamName, ageGroup, competitionAgeGroup)
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatRunde = (runde) => {
|
const formatRunde = (runde) => {
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
import { listSpielplanSeasons, readSpielplanData, validateSeasonSlug } from '../../utils/spielplan-data.js'
|
import { listSpielplanSeasons, readSpielplanData, validateSeasonSlug } from '../../utils/spielplan-data.js'
|
||||||
import { formatTeamDisplayName } from '../../../utils/team-display.js'
|
import { formatTeamDisplayName } from '../../../utils/team-display.js'
|
||||||
|
|
||||||
function teamLabel(teamName, teamAgeGroup) {
|
function teamLabel(teamName, teamAgeGroup, competitionAgeGroup) {
|
||||||
return formatTeamDisplayName(teamName, teamAgeGroup)
|
return formatTeamDisplayName(teamName, teamAgeGroup, competitionAgeGroup)
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractHarheimerTeams(rows) {
|
function extractHarheimerTeams(rows) {
|
||||||
const seen = new Set()
|
const seen = new Set()
|
||||||
const teams = []
|
const teams = []
|
||||||
|
|
||||||
const addTeam = (teamName, teamAgeGroup) => {
|
const addTeam = (teamName, teamAgeGroup, competitionAgeGroup) => {
|
||||||
const name = String(teamName || '').trim()
|
const name = String(teamName || '').trim()
|
||||||
if (!name) return
|
if (!name) return
|
||||||
const age = String(teamAgeGroup || '').trim()
|
const age = String(teamAgeGroup || '').trim()
|
||||||
@@ -18,7 +18,7 @@ function extractHarheimerTeams(rows) {
|
|||||||
seen.add(key)
|
seen.add(key)
|
||||||
teams.push({
|
teams.push({
|
||||||
key,
|
key,
|
||||||
label: teamLabel(name, age),
|
label: teamLabel(name, age, competitionAgeGroup),
|
||||||
teamName: name,
|
teamName: name,
|
||||||
teamAgeGroup: age
|
teamAgeGroup: age
|
||||||
})
|
})
|
||||||
@@ -26,10 +26,10 @@ function extractHarheimerTeams(rows) {
|
|||||||
|
|
||||||
for (const row of rows || []) {
|
for (const row of rows || []) {
|
||||||
if (String(row.HeimVereinName || '').trim() === 'Harheimer TC') {
|
if (String(row.HeimVereinName || '').trim() === 'Harheimer TC') {
|
||||||
addTeam(row.HeimMannschaft, row.HeimMannschaftAltersklasse)
|
addTeam(row.HeimMannschaft, row.HeimMannschaftAltersklasse, row.Altersklasse)
|
||||||
}
|
}
|
||||||
if (String(row.GastVereinName || '').trim() === 'Harheimer TC') {
|
if (String(row.GastVereinName || '').trim() === 'Harheimer TC') {
|
||||||
addTeam(row.GastMannschaft, row.GastMannschaftAltersklasse)
|
addTeam(row.GastMannschaft, row.GastMannschaftAltersklasse, row.Altersklasse)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,30 @@
|
|||||||
/**
|
/**
|
||||||
* Makes youth teams identifiable while retaining the team name supplied by
|
* Makes youth teams identifiable while retaining the team name supplied by
|
||||||
* click-TT. Age groups occur in a few forms, for example "Jugend 13",
|
* click-TT. Age groups occur in a few forms, for example "Jugend 13",
|
||||||
* "Jugend 13 1. Kreisklasse", and "J13".
|
* "Jugend 13 1. Kreisklasse", and "J13". Some imports provide the age
|
||||||
|
* only for the whole fixture, therefore `competitionAgeGroup` is considered
|
||||||
|
* as a fallback.
|
||||||
*/
|
*/
|
||||||
export function youthTeamCode(teamAgeGroup, teamName = '') {
|
export function youthTeamCode(teamAgeGroup, teamName = '', competitionAgeGroup = '') {
|
||||||
const ageGroup = String(teamAgeGroup || '').trim()
|
const ageGroup = [teamAgeGroup, competitionAgeGroup]
|
||||||
|
.map(value => String(value || '').trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' ')
|
||||||
const name = String(teamName || '').trim()
|
const name = String(teamName || '').trim()
|
||||||
const codeMatch = ageGroup.match(/\b(?:jugend\s*|j\s*)(\d{1,2})\b/i)
|
const codeMatch = `${ageGroup} ${name}`.match(/\b(?:jugend\s*|j\s*\(?)(\d{1,2})\b/i)
|
||||||
|
|
||||||
if (codeMatch) return `J${codeMatch[1]}`
|
if (codeMatch) return `J${codeMatch[1]}`
|
||||||
if (/\bjugend\b/i.test(ageGroup) || /\bjugend\b/i.test(name)) return 'J'
|
if (/\bjugend\b/i.test(ageGroup) || /\bjugend\b/i.test(name)) return 'J'
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatTeamDisplayName(teamName, teamAgeGroup) {
|
export function formatTeamDisplayName(teamName, teamAgeGroup, competitionAgeGroup = '') {
|
||||||
const name = String(teamName || '').trim()
|
const rawName = String(teamName || '').trim()
|
||||||
if (!name) return ''
|
if (!rawName) return ''
|
||||||
|
|
||||||
const youthCode = youthTeamCode(teamAgeGroup, name)
|
const youthCode = youthTeamCode(teamAgeGroup, rawName, competitionAgeGroup)
|
||||||
|
const name = youthCode
|
||||||
|
? rawName.replace(/\s*\(J\d{1,2}\)\s*$/i, '').trim()
|
||||||
|
: rawName
|
||||||
return youthCode ? `(${youthCode}) ${name}` : name
|
return youthCode ? `(${youthCode}) ${name}` : name
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user