Slots: bulk generate, copy week and clear, with a preview step
Generate fills a date range (weekdays x opening hours) spaced by the service's duration + get-ready time (overridable). Copy repeats a week into the next 1-12 weeks; Clear deletes free slots in a range. Each previews first, skips past slots and overlaps with the same service, and never touches booked or in-basket slots. Planning is pure and DST-safe in $shared/slots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VaXE9U7AmW3dfD2w6cbLfk
This commit is contained in:
parent
1a71c9db73
commit
2052ad5a59
9 changed files with 862 additions and 11 deletions
54
app-admin/src/lib/admin/slots/BulkActions.svelte
Normal file
54
app-admin/src/lib/admin/slots/BulkActions.svelte
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<script lang="ts">
|
||||
// Footer of a bulk slot form: the server's preview, then Preview / confirm
|
||||
// buttons. See bulkForm.svelte.ts for the two-step submit.
|
||||
import { formatDateTime } from '$lib/calendar';
|
||||
import { confirmSubmit } from '$lib/admin/confirm';
|
||||
import type { BulkForm } from './bulkForm.svelte';
|
||||
|
||||
let { bulk, timezone, onCancel }: { bulk: BulkForm; timezone: string; onCancel: () => void } = $props();
|
||||
|
||||
let preview = $derived(bulk.preview);
|
||||
let deleting = $derived(preview?.action === 'clear');
|
||||
let plural = (n: number, word: string) => `${n} ${word}${n === 1 ? '' : 's'}`;
|
||||
</script>
|
||||
|
||||
{#if bulk.error}<div class="alert alert-error mt-3 text-sm" role="alert">{bulk.error}</div>{/if}
|
||||
|
||||
{#if preview}
|
||||
<div class="mt-3 rounded-box bg-base-200 p-4 text-sm">
|
||||
{#if preview.count}
|
||||
<p class="font-semibold">
|
||||
{plural(preview.count, 'slot')} will be {deleting ? 'deleted' : 'created'}{preview.count > 1
|
||||
? `, from ${formatDateTime(preview.firstStart, timezone)} to ${formatDateTime(preview.lastStart, timezone)}`
|
||||
: `, at ${formatDateTime(preview.firstStart, timezone)}`}.
|
||||
</p>
|
||||
{:else}
|
||||
<p class="font-semibold">Nothing to {deleting ? 'delete' : 'create'}.</p>
|
||||
{/if}
|
||||
<ul class="mt-1 list-inside list-disc text-base-content/70 empty:hidden">
|
||||
{#if preview.skippedOverlap}<li>{plural(preview.skippedOverlap, 'slot')} skipped — it would overlap a slot of the same service.</li>{/if}
|
||||
{#if preview.skippedPast}<li>{plural(preview.skippedPast, 'slot')} skipped — in the past.</li>{/if}
|
||||
{#if preview.kept}<li>{plural(preview.kept, 'slot')} kept — booked, or in a customer’s basket right now.</li>{/if}
|
||||
</ul>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="modal-action">
|
||||
<button class="btn" type="button" onclick={onCancel}>Cancel</button>
|
||||
<button class={['btn', !preview?.count && 'btn-primary']} type="submit" name="intent" value="preview" disabled={bulk.busy}>
|
||||
{#if bulk.busy}<span class="loading loading-spinner loading-xs"></span>{/if}
|
||||
{preview ? 'Preview again' : 'Preview'}
|
||||
</button>
|
||||
{#if preview?.count}
|
||||
<button
|
||||
class={['btn', deleting ? 'btn-error' : 'btn-primary']}
|
||||
type="submit"
|
||||
name="intent"
|
||||
value="create"
|
||||
disabled={bulk.busy}
|
||||
onclick={deleting ? confirmSubmit(`Delete ${plural(preview.count, 'slot')}?`) : undefined}
|
||||
>
|
||||
{deleting ? 'Delete' : 'Create'} {plural(preview.count, 'slot')}
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue