096d6e2868
CI / update (push) Successful in 3m31s
Replace season: number[] (months 1-12) on Recipe with seasonRanges, a list of date ranges where each endpoint is either a fixed MM-DD or a movable liturgical anchor (Easter, Ash Wednesday, Palm Sunday, Pentecost, Advent I) plus a day offset. The old month list couldn't express liturgical seasons whose boundaries shift each year (Advent, Lent, Easter Octave, Christmas Octave) nor sub-month windows. The shared evaluator resolves anchors against [Y-1, Y, Y+1] so spans that wrap the calendar year boundary (e.g. christmas + 0 to christmas + 7) match correctly on both sides. SeasonSelect was rewritten as a controlled bind:ranges editor with a fixed/liturgical kind toggle, anchor + offset inputs, per-row resolved-this-year preview, and preset chips. Run the one-time migration before deploying: pnpm exec vite-node scripts/migrate-season-to-ranges.ts It coalesces contiguous month runs into single fixed ranges and merges Dec/Jan wrap into one wrapping range; the new code does not read the legacy season field, so order matters.
82 lines
2.3 KiB
Svelte
82 lines
2.3 KiB
Svelte
<script lang="ts">
|
|
import CardAdd from '$lib/components/recipes/CardAdd.svelte';
|
|
import MediaScroller from '$lib/components/recipes/MediaScroller.svelte';
|
|
import Search from '$lib/components/recipes/Search.svelte';
|
|
import SeasonSelect from '$lib/components/recipes/SeasonSelect.svelte';
|
|
import CreateIngredientList from '$lib/components/recipes/CreateIngredientList.svelte';
|
|
import CreateStepList from '$lib/components/recipes/CreateStepList.svelte';
|
|
|
|
let {
|
|
card_data = $bindable({}),
|
|
seasonRanges = $bindable([]),
|
|
ingredients = $bindable([]),
|
|
instructions = $bindable([])
|
|
}: {
|
|
card_data?: any,
|
|
seasonRanges?: any[],
|
|
ingredients?: any[],
|
|
instructions?: any[]
|
|
} = $props();
|
|
|
|
let short_name = $state('');
|
|
let password = $state('');
|
|
let datecreated = $state(new Date());
|
|
let datemodified = $state(datecreated);
|
|
let result = $state('');
|
|
let image_preview_url = $state('');
|
|
let selected_image_file = $state<File | null>(null);
|
|
|
|
async function doPost () {
|
|
const res = await fetch('/api/add', {
|
|
method: 'POST',
|
|
body: JSON.stringify({
|
|
recipe: {
|
|
seasonRanges: seasonRanges,
|
|
...card_data,
|
|
images: [{
|
|
mediapath: short_name + '.webp',
|
|
alt: "",
|
|
caption: ""
|
|
}],
|
|
short_name,
|
|
datecreated,
|
|
datemodified,
|
|
instructions,
|
|
ingredients,
|
|
},
|
|
headers: {
|
|
'content-type': 'application/json',
|
|
bearer: password,
|
|
}
|
|
})
|
|
})
|
|
|
|
const json = await res.json()
|
|
result = JSON.stringify(json)
|
|
}
|
|
</script>
|
|
<style>
|
|
input.temp{
|
|
all: unset;
|
|
display: block;
|
|
margin: 1rem auto;
|
|
padding: 0.2em 1em;
|
|
border-radius: var(--radius-pill);
|
|
background-color: var(--nord4);
|
|
|
|
}
|
|
</style>
|
|
|
|
<CardAdd bind:card_data={card_data} bind:image_preview_url={image_preview_url} bind:selected_image_file={selected_image_file} {short_name}></CardAdd>
|
|
|
|
<input class=temp bind:value={short_name} placeholder="Kurzname"/>
|
|
|
|
<SeasonSelect bind:ranges={seasonRanges} />
|
|
<button onclick={() => console.log(seasonRanges)}>PRINTOUT season</button>
|
|
|
|
<h2>Zutaten</h2>
|
|
<CreateIngredientList bind:ingredients={ingredients}></CreateIngredientList>
|
|
<h2>Zubereitung</h2>
|
|
<CreateStepList bind:instructions={instructions} add_info={{}}></CreateStepList>
|
|
<input class=temp type="password" placeholder=Passwort bind:value={password}>
|