Skip to content

Commit

Permalink
feat: create shortcut for class creation
Browse files Browse the repository at this point in the history
- hide the more complex class features, as most people will not use them
- let people create the simplest classes like original munro
  • Loading branch information
brownben committed Jan 30, 2024
1 parent 6ede36a commit b381985
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 119 deletions.
29 changes: 12 additions & 17 deletions frontend/pages/leagues/[name]/classes/[cls]/edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ const setAgeClassRestriction = (value: string) => {
return { age_class, age_class_type }
}
const getNumberOfCountingEvents = () => {
if (form.specify_number_of_counting_events)
return form.number_of_counting_events
if (form.number_of_counting_events) return form.number_of_counting_events
else return null
}
Expand All @@ -57,8 +56,7 @@ const form = reactive({
course: data.value?.standard_course ?? '',
...setAgeClassRestriction(data.value?.age_class_filter ?? ''),
...setClubRestriction(data.value?.club_filter ?? ''),
specify_number_of_counting_events: !!data.value?.number_of_counting_events,
number_of_counting_events: Number(data.value?.number_of_counting_events),
number_of_counting_events: data.value?.number_of_counting_events || 0,
})
const action = async () => {
Expand Down Expand Up @@ -111,19 +109,6 @@ useTitle({
:validator="IsValidURLParameter('a name')"
/>

<InputSwitch
v-model="form.specify_number_of_counting_events"
label="Override number of counting events?"
description="Specify a different number of events to score than the league default?"
class="col-span-2"
/>
<InputNumber
v-if="form.specify_number_of_counting_events"
v-model="form.number_of_counting_events"
label="Number of Counting Events:"
class="col-span-2"
/>

<FormHeading
title="Course"
description="Set the default course to use for results for this class."
Expand Down Expand Up @@ -218,6 +203,16 @@ useTitle({
label="Club:"
class="col-span-2"
/>

<FormHeading
title="Counting Events"
description="The number of events to score for the class. Leave as 0 for the league default."
/>
<InputNumber
v-model="form.number_of_counting_events"
label="Number of Counting Events:"
class="col-span-2"
/>
</Form>
</div>
<LazyError v-else />
Expand Down
234 changes: 132 additions & 102 deletions frontend/pages/leagues/[name]/classes/create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,28 @@ const form = reactive({
age_class_type: '',
club: '',
club_type: '',
specify_number_of_counting_events: false,
number_of_counting_events: 0,
})
const settingsShortcut = ref('course')
const getClubRestriction = () => {
if (form.club_type == 'specific') return form.club
else if (form.club_type == 'scottish') return '{scottish_clubs}'
else return ''
}
const getDefaultCourse = () => {
if (settingsShortcut.value == 'overall') return '*'
else if (settingsShortcut.value == 'course') return form.name
return form.course || form.name
}
const getAgeClassRestriction = () => {
if (form.age_class_type == '') return ''
else if (form.age_class_type == 'standard') return form.age_class
else return `${form.age_class_type}-${form.age_class}`
}
const getClubRestriction = () => {
if (form.club_type == 'specific') return form.club
else if (form.club_type == 'scottish') return '{scottish_clubs}'
else return ''
}
const getNumberOfCountingEvents = () => {
if (form.specify_number_of_counting_events)
return form.number_of_counting_events
if (form.number_of_counting_events) return form.number_of_counting_events
else return null
}
Expand All @@ -50,7 +53,7 @@ const action = async () => {
await usePost(`leagues/${form.league}/classes`, {
name: form.name,
league: form.league,
standard_course: form.course || form.name,
standard_course: getDefaultCourse(),
age_class_filter: getAgeClassRestriction(),
club_filter: getClubRestriction(),
number_of_counting_events: getNumberOfCountingEvents(),
Expand Down Expand Up @@ -95,113 +98,140 @@ useTitle({
:validator="IsValidURLParameter('a name')"
/>

<InputSwitch
v-model="form.specify_number_of_counting_events"
label="Override number of counting events?"
description="Specify a different number of events to score than the league default?"
class="col-span-2"
/>
<InputNumber
v-if="form.specify_number_of_counting_events"
v-model="form.number_of_counting_events"
label="Number of Counting Events:"
class="col-span-2"
/>

<FormHeading
title="Course"
description="Set the default course to use for results for this class."
/>
<Input
v-model.trim="form.course"
label="Default Course:"
class="col-span-2"
:validator="IsValidOptionalURLParameter('a default course')"
/>

<FormHeading
title="Age Class Filtering"
description="Only include people with a specific age class in the results."
title="Scoring"
description="How the league results are calculated."
/>
<InputRadio
v-model="form.age_class_type"
label="Age Class Matching:"
v-model="settingsShortcut"
label="Scoring:"
:options="[
{
title: 'No Restrictions',
description: 'Allow any age class',
value: '',
},
{
title: 'Standard',
description: 'Standard Orienteering age class eligibility',
value: 'standard',
},
{
title: 'Exact',
description: 'Only include people who are in the age class',
value: 'exact',
title: 'Course',
description: 'Basic league results for a given course.',
value: 'course',
},
{
title: 'Exact with B',
description:
'Only include people who are in the age class, or juniors who\'s B class is the specified class',
value: 'exactWithB',
title: 'Overall',
description: 'Combine scores from all the courses into one class.',
value: 'overall',
},
{
title: 'Exact Gender',
title: 'Custom',
description:
'Gender must match the age class (Women can\'t run up as men)',
value: 'exactGender',
},
{
title: 'Seniors',
description: 'Only include seniors (over 18s)',
value: 'older18',
'Configure what courses are included and who can count in the class.',
value: 'custom',
},
]"
class="col-span-2"
/>
<Input
v-if="form.age_class_type != ''"
v-model.trim="form.age_class"
label="Age Class:"
class="col-span-2"
:validator="IsValidAgeClass"
/>

<FormHeading
title="Club Filtering"
description="Only include people with a specific club in the results."
/>
<InputRadio
v-model="form.club_type"
label="Club Matching:"
:options="[
{
title: 'No Restrictions',
description: 'Allow any club',
value: '',
},
{
title: 'Scottish',
description: 'Only allow Scottish clubs',
value: 'scottish',
},
{
title: 'Specific Club',
description: 'Only include people who are in the age class',
value: 'specific',
},
]"
class="col-span-2"
/>
<Input
v-if="form.club_type == 'specific'"
v-model.trim="form.club"
label="Club:"
class="col-span-2"
/>
<template v-if="settingsShortcut == 'custom'">
<FormHeading
title="Course"
description="Set the default course to use for results for this class."
/>
<Input
v-model.trim="form.course"
label="Default Course:"
class="col-span-2"
:validator="IsValidOptionalURLParameter('a default course')"
/>

<FormHeading
title="Age Class Filtering"
description="Only include people with a specific age class in the results."
/>
<InputRadio
v-model="form.age_class_type"
label="Age Class Matching:"
:options="[
{
title: 'No Restrictions',
description: 'Allow any age class',
value: '',
},
{
title: 'Standard',
description: 'Standard Orienteering age class eligibility',
value: 'standard',
},
{
title: 'Exact',
description: 'Only include people who are in the age class',
value: 'exact',
},
{
title: 'Exact with B',
description:
'Only include people who are in the age class, or juniors who\'s B class is the specified class',
value: 'exactWithB',
},
{
title: 'Exact Gender',
description:
'Gender must match the age class (Women can\'t run up as men)',
value: 'exactGender',
},
{
title: 'Seniors',
description: 'Only include seniors (over 18s)',
value: 'older18',
},
]"
class="col-span-2"
/>
<Input
v-if="form.age_class_type != ''"
v-model.trim="form.age_class"
label="Age Class:"
class="col-span-2"
:validator="IsValidAgeClass"
/>

<FormHeading
title="Club Filtering"
description="Only include people with a specific club in the results."
/>
<InputRadio
v-model="form.club_type"
label="Club Matching:"
:options="[
{
title: 'No Restrictions',
description: 'Allow any club',
value: '',
},
{
title: 'Scottish',
description: 'Only allow Scottish clubs',
value: 'scottish',
},
{
title: 'Specific Club',
description: 'Only include people who are in the age class',
value: 'specific',
},
]"
class="col-span-2"
/>
<Input
v-if="form.club_type == 'specific'"
v-model.trim="form.club"
label="Club:"
class="col-span-2"
/>

<FormHeading
title="Counting Events"
description="The number of events to score for the class. Leave blank for the league default."
/>
<InputNumber
v-model="form.number_of_counting_events"
label="Number of Counting Events:"
class="col-span-2"
/>
</template>
</Form>
</div>
</template>

0 comments on commit b381985

Please sign in to comment.