+surfers & athletes
This commit is contained in:
parent
5cef5cf409
commit
086be8ccc2
5 changed files with 67 additions and 16 deletions
|
@ -10,7 +10,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Surfer struct {
|
type Surfer struct {
|
||||||
Name string `json:"name"`
|
Athlete Athlete `json:"surfer"`
|
||||||
Color string `json:"color"`
|
Color string `json:"color"`
|
||||||
Priority string `json:"priority"`
|
Priority string `json:"priority"`
|
||||||
Score string `json:"score"`
|
Score string `json:"score"`
|
||||||
|
@ -27,7 +27,7 @@ type Heat struct {
|
||||||
|
|
||||||
func heatName(heat Heat) string {
|
func heatName(heat Heat) string {
|
||||||
str := fmt.Sprintf("%s.%d.%s", heat.Round, heat.Number, heat.Category)
|
str := fmt.Sprintf("%s.%d.%s", heat.Round, heat.Number, heat.Category)
|
||||||
strings.ReplaceAll(str, " ", "_")
|
str = strings.ReplaceAll(str, " ", "_")
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
7
backend/surfers.go
Normal file
7
backend/surfers.go
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
type Athlete struct {
|
||||||
|
Firstname string `json:"firstname"`
|
||||||
|
Lastname string `json:"lastname"`
|
||||||
|
Category string `json:"category"`
|
||||||
|
}
|
|
@ -3,14 +3,13 @@
|
||||||
export let id;
|
export let id;
|
||||||
export let options = [];
|
export let options = [];
|
||||||
export let value;
|
export let value;
|
||||||
export let optionStyle = '';
|
export let handleSelect;
|
||||||
export let selectStyle;
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<label class="label" for={id}>{label}</label>
|
<label class="label" for={id}>{label}</label>
|
||||||
<select name={id} {id} bind:value style={selectStyle}>
|
<select name={id} {id} bind:value on:select={handleSelect}>
|
||||||
{#each options as option}
|
{#each options as option}
|
||||||
<option value={option} style={optionStyle}>{option}</option>
|
<option value={option}>{option}</option>
|
||||||
{/each}
|
{/each}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
import Button from '../../lib/button.svelte';
|
import Button from '../../lib/button.svelte';
|
||||||
|
|
||||||
$: surfers = 2;
|
$: surfers = 2;
|
||||||
|
$: athletes = [];
|
||||||
|
|
||||||
$: heats = [];
|
$: heats = [];
|
||||||
let surfer_list = [];
|
let surfer_list = [];
|
||||||
|
@ -68,6 +69,15 @@
|
||||||
loadHeats();
|
loadHeats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadSurfers() {
|
||||||
|
const res = await fetch(`/api/loadsurfers`);
|
||||||
|
const data = await res.json();
|
||||||
|
for (let i in data) {
|
||||||
|
athletes[i] = data[i];
|
||||||
|
console.log(`${i} retval: ${JSON.stringify(data[i])}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setHeat(id) {
|
function setHeat(id) {
|
||||||
resetHeat();
|
resetHeat();
|
||||||
console.log(`setHeat: ${id}`);
|
console.log(`setHeat: ${id}`);
|
||||||
|
@ -188,7 +198,13 @@
|
||||||
<Number label="Number" min="1" max="20" id="number" bind:value={heat.number} />
|
<Number label="Number" min="1" max="20" id="number" bind:value={heat.number} />
|
||||||
</div>
|
</div>
|
||||||
<div class="category">
|
<div class="category">
|
||||||
<Select label="Category" id="category" options={$categories} bind:value={heat.category} />
|
<Select
|
||||||
|
label="Category"
|
||||||
|
id="category"
|
||||||
|
options={$categories}
|
||||||
|
bind:value={heat.category}
|
||||||
|
handleSelect={loadSurfers}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="duration">
|
<div class="duration">
|
||||||
<Number label="Duration" id="duration" min="5" max="60" step="5" bind:value={heat.timer} />
|
<Number label="Duration" id="duration" min="5" max="60" step="5" bind:value={heat.timer} />
|
||||||
|
@ -204,7 +220,13 @@
|
||||||
<div class="surfer">
|
<div class="surfer">
|
||||||
{#each Array(surfers) as _, surfer}
|
{#each Array(surfers) as _, surfer}
|
||||||
<div class="name">
|
<div class="name">
|
||||||
<Input label="Name" id="name{surfer}" bind:value={surfer_list[surfer].name} />
|
<Select
|
||||||
|
label="Name"
|
||||||
|
id="name{surfer}"
|
||||||
|
bind:value={surfer_list[surfer].name}
|
||||||
|
options={athletes}
|
||||||
|
/>
|
||||||
|
<!-- <Input label="Name" id="name{surfer}" bind:value={surfer_list[surfer].name} /> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="color">
|
<div class="color">
|
||||||
<Color id="color{surfer}" label="Color" bind:value={surfer_list[surfer].color} />
|
<Color id="color{surfer}" label="Color" bind:value={surfer_list[surfer].color} />
|
||||||
|
|
|
@ -3,21 +3,38 @@
|
||||||
import Button from '$lib/button.svelte';
|
import Button from '$lib/button.svelte';
|
||||||
import Select from '$lib/select.svelte';
|
import Select from '$lib/select.svelte';
|
||||||
import Input from '$lib/input.svelte';
|
import Input from '$lib/input.svelte';
|
||||||
import Number from '$lib/number.svelte';
|
|
||||||
import { categories } from '$lib/stores/categories.js';
|
import { categories } from '$lib/stores/categories.js';
|
||||||
|
|
||||||
|
$: surfers = [];
|
||||||
|
|
||||||
let surfer = {
|
let surfer = {
|
||||||
firstname: '',
|
firstname: '',
|
||||||
lastname: '',
|
lastname: '',
|
||||||
category: '',
|
category: ''
|
||||||
num: '1'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$: value = '';
|
$: value = '';
|
||||||
|
|
||||||
|
async function loadSurfers() {
|
||||||
|
const res = await fetch(`/api/loadsurfers`);
|
||||||
|
const data = await res.json();
|
||||||
|
for (let i in data) {
|
||||||
|
surfers[i] = data[i];
|
||||||
|
console.log(`${i} retval: ${JSON.stringify(data[i])}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onclick() {
|
function onclick() {
|
||||||
alert('clicked');
|
alert('clicked');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reset() {
|
||||||
|
surfer = {
|
||||||
|
firstname: '',
|
||||||
|
lastname: '',
|
||||||
|
category: ''
|
||||||
|
};
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Header title="Surfer Edit" />
|
<Header title="Surfer Edit" />
|
||||||
|
@ -28,9 +45,15 @@
|
||||||
<Select label="category" id="category" options={$categories} bind:value={surfer.category} />
|
<Select label="category" id="category" options={$categories} bind:value={surfer.category} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button handleClick={onclick} title="SAVE"></Button>
|
<Button handleClick={onclick} label="SAVE"></Button>
|
||||||
<Button handleClick={onclick} title="Reset"></Button>
|
<Button handleClick={reset} label="Reset"></Button>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<label for="surfer">{JSON.stringify(surfer)}</label>
|
<label for="surfer">{JSON.stringify(surfer)}</label>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
{#each surfers as s}
|
||||||
|
<label for={s}>{JSON.stringify(s)}</label>
|
||||||
|
{/each}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue