Add Enable Dynamic Audio option to schedule blocks
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
initialStartMinutes = 9 * 60,
|
||||
initialEndMinutes = 10 * 60,
|
||||
initialProclamationIds = [],
|
||||
initialDynamicAudio = false,
|
||||
categories = [],
|
||||
groups = [],
|
||||
proclamations = [],
|
||||
@@ -42,6 +43,7 @@
|
||||
initialStartMinutes?: number;
|
||||
initialEndMinutes?: number;
|
||||
initialProclamationIds?: string[];
|
||||
initialDynamicAudio?: boolean;
|
||||
categories?: BrowserCategory[];
|
||||
groups?: BrowserGroup[];
|
||||
proclamations?: BrowserProclamation[];
|
||||
@@ -61,6 +63,7 @@
|
||||
let endMinute = $state('0');
|
||||
let endPeriod = $state<'AM' | 'PM'>('AM');
|
||||
let selectedIds = $state<string[]>([]);
|
||||
let dynamicAudio = $state(false);
|
||||
let error = $state('');
|
||||
|
||||
const hourOptions = Array.from({ length: 12 }, (_, i) => String(i + 1));
|
||||
@@ -98,6 +101,7 @@
|
||||
endMinute = String(end.minute);
|
||||
endPeriod = end.period;
|
||||
selectedIds = [...initialProclamationIds];
|
||||
dynamicAudio = initialDynamicAudio;
|
||||
error = '';
|
||||
step = 'details';
|
||||
});
|
||||
@@ -209,6 +213,7 @@
|
||||
<input type="hidden" name="startMinutes" value={startMinutes} />
|
||||
<input type="hidden" name="endMinutes" value={endMinutes} />
|
||||
<input type="hidden" name="proclamationIds" value={JSON.stringify(selectedIds)} />
|
||||
<input type="hidden" name="dynamicAudio" value={dynamicAudio ? 'true' : 'false'} />
|
||||
|
||||
<div class="min-h-0 flex-1 overflow-y-auto px-6 py-5">
|
||||
{#if error}
|
||||
@@ -313,6 +318,39 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<label
|
||||
class="flex items-center gap-2 text-sm font-medium text-slate-700 dark:text-slate-300"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={dynamicAudio}
|
||||
onchange={(e) => (dynamicAudio = e.currentTarget.checked)}
|
||||
class="h-4 w-4 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500 dark:border-slate-600"
|
||||
/>
|
||||
Enable Dynamic Audio
|
||||
</label>
|
||||
<span class="group relative inline-flex">
|
||||
<button
|
||||
type="button"
|
||||
aria-label="What is Dynamic Audio?"
|
||||
aria-describedby="dynamic-audio-help"
|
||||
class="flex h-5 w-5 items-center justify-center rounded-full border border-slate-300 text-xs font-semibold text-slate-500 transition hover:border-indigo-400 hover:text-indigo-600 focus:border-indigo-500 focus:outline-none dark:border-slate-600 dark:text-slate-400"
|
||||
>
|
||||
?
|
||||
</button>
|
||||
<span
|
||||
id="dynamic-audio-help"
|
||||
role="tooltip"
|
||||
class="pointer-events-none absolute bottom-full left-1/2 z-20 mb-2 w-64 -translate-x-1/2 rounded-md bg-slate-900 px-3 py-2 text-xs font-normal text-white opacity-0 shadow-lg transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 dark:bg-slate-700"
|
||||
>
|
||||
Dynamic audio will be enabled for this block, while this block is playing.
|
||||
This will override any audio selections you have made on your device while
|
||||
this block is active.
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
|
||||
@@ -159,4 +159,35 @@ describe('BlockModal', () => {
|
||||
await expect.element(page.getByRole('button', { name: 'Create Block' })).toBeInTheDocument();
|
||||
await expect.element(page.getByRole('button', { name: 'Accept' })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('offers an Enable Dynamic Audio checkbox with a help tooltip', async () => {
|
||||
mount();
|
||||
|
||||
const checkbox = page.getByRole('checkbox', { name: /Enable Dynamic Audio/ });
|
||||
await expect.element(checkbox).toBeInTheDocument();
|
||||
expect((checkbox.element() as HTMLInputElement).checked).toBe(false);
|
||||
|
||||
await expect
|
||||
.element(page.getByText(/Dynamic audio will be enabled for this block/))
|
||||
.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('pre-checks dynamic audio when editing a block that has it enabled', async () => {
|
||||
mount({ initialDynamicAudio: true });
|
||||
|
||||
const checkbox = page.getByRole('checkbox', { name: /Enable Dynamic Audio/ });
|
||||
await expect.element(checkbox).toBeInTheDocument();
|
||||
expect((checkbox.element() as HTMLInputElement).checked).toBe(true);
|
||||
});
|
||||
|
||||
it('toggles the dynamic audio flag in the submitted payload', async () => {
|
||||
mount();
|
||||
|
||||
const checkbox = page.getByRole('checkbox', { name: /Enable Dynamic Audio/ });
|
||||
await expect.element(checkbox).toBeInTheDocument();
|
||||
(checkbox.element() as HTMLInputElement).click();
|
||||
|
||||
const hidden = document.querySelector('input[name="dynamicAudio"]') as HTMLInputElement;
|
||||
await expect.poll(() => hidden.value).toBe('true');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
id: string;
|
||||
startMinutes: number;
|
||||
endMinutes: number;
|
||||
dynamicAudio: boolean;
|
||||
proclamations: { id: string; name: string }[];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user