migration to Svelte 5
This commit is contained in:
parent
a032d3a166
commit
1378636a98
28 changed files with 164 additions and 206 deletions
|
|
@ -1,4 +1,6 @@
|
|||
<script>
|
||||
import { run } from 'svelte/legacy';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Col,
|
||||
|
|
@ -34,27 +36,20 @@
|
|||
}
|
||||
}
|
||||
|
||||
let objP;
|
||||
let obj;
|
||||
|
||||
$: {
|
||||
switch ($page.params["kind"]) {
|
||||
function callRightFunction(kind) {
|
||||
switch(kind) {
|
||||
case "single":
|
||||
objP = getAlarmSingle($page.params["aid"]);
|
||||
break;
|
||||
return getAlarmSingle;
|
||||
case "repeated":
|
||||
objP = getAlarmRepeated($page.params["aid"]);
|
||||
break;
|
||||
return getAlarmRepeated;
|
||||
case "exceptions":
|
||||
objP = getAlarmException($page.params["aid"]);
|
||||
break;
|
||||
return getAlarmException;
|
||||
}
|
||||
objP.then((o) => obj = o);
|
||||
}
|
||||
|
||||
let edit = false;
|
||||
let edit = $state(false);
|
||||
|
||||
function deleteThis() {
|
||||
function deleteThis(obj) {
|
||||
obj.delete().then(() => {
|
||||
switch($page.params["kind"]) {
|
||||
case "single":
|
||||
|
|
@ -74,12 +69,12 @@
|
|||
</script>
|
||||
|
||||
<Container fluid class="flex-fill">
|
||||
{#if $page.params["kind"] == "single"}
|
||||
{#await objP}
|
||||
<div class="d-flex justify-content-center align-items-center gap-2">
|
||||
<Spinner color="primary" /> Chargement en cours…
|
||||
</div>
|
||||
{:then alarm}
|
||||
{#await callRightFunction($page.params["kind"])($page.params["aid"])}
|
||||
<div class="d-flex justify-content-center align-items-center gap-2">
|
||||
<Spinner color="primary" /> Chargement en cours…
|
||||
</div>
|
||||
{:then alarm}
|
||||
{#if $page.params["kind"] == "single"}
|
||||
<h2 class="mb-0">
|
||||
{slugToTitle($page.params["kind"])} du <DateFormat date={alarm.time} dateStyle="long" />
|
||||
</h2>
|
||||
|
|
@ -97,16 +92,10 @@
|
|||
</ListGroupItem>
|
||||
<ListGroupItem class="d-flex">
|
||||
<strong>Fédération activée ?</strong>
|
||||
<Input type="switch" class="ms-2" on:change={() => {obj.enable_federation = !obj.enable_federation; obj.save();}} checked={obj.enable_federation} /> {obj.enable_federation?"oui":"non"}
|
||||
<Input type="switch" class="ms-2" on:change={() => {alarm.enable_federation = !alarm.enable_federation; alarm.save();}} checked={alarm.enable_federation} /> {alarm.enable_federation?"oui":"non"}
|
||||
</ListGroupItem>
|
||||
</ListGroup>
|
||||
{/await}
|
||||
{:else if $page.params["kind"] == "repeated"}
|
||||
{#await objP}
|
||||
<div class="d-flex justify-content-center align-items-center gap-2">
|
||||
<Spinner color="primary" /> Chargement en cours…
|
||||
</div>
|
||||
{:then alarm}
|
||||
{:else if $page.params["kind"] == "repeated"}
|
||||
<h2 class="mb-0">
|
||||
{slugToTitle($page.params["kind"])} des {weekdayStr(alarm.weekday)}s à {alarm.time}
|
||||
</h2>
|
||||
|
|
@ -124,19 +113,19 @@
|
|||
</ListGroupItem>
|
||||
<ListGroupItem class="d-flex">
|
||||
<strong>Alarme active ?</strong>
|
||||
<Input type="switch" class="ms-2" on:change={() => {obj.disabled = !obj.disabled; obj.save().then(() => {obj.next_time = null; alarmsRepeated.refresh()});}} checked={!obj.disabled} /> {!obj.disabled?"oui":"non"}
|
||||
<Input type="switch" class="ms-2" on:change={() => {alarm.disabled = !alarm.disabled; alarm.save().then(() => {alarm.next_time = null; alarmsRepeated.refresh()});}} checked={!alarm.disabled} /> {!alarm.disabled?"oui":"non"}
|
||||
</ListGroupItem>
|
||||
<ListGroupItem class="d-flex">
|
||||
<strong>Ignorer les exceptions ?</strong>
|
||||
<Input type="switch" class="ms-2" on:change={() => {obj.ignore_exceptions = !obj.ignore_exceptions; obj.save();}} checked={obj.ignore_exceptions} /> {obj.ignore_exceptions?"oui":"non"}
|
||||
<Input type="switch" class="ms-2" on:change={() => {alarm.ignore_exceptions = !alarm.ignore_exceptions; alarm.save();}} checked={alarm.ignore_exceptions} /> {alarm.ignore_exceptions?"oui":"non"}
|
||||
</ListGroupItem>
|
||||
<ListGroupItem class="d-flex">
|
||||
<strong>Fédération activée ?</strong>
|
||||
<Input type="switch" class="ms-2" on:change={() => {obj.enable_federation = !obj.enable_federation; obj.save();}} checked={obj.enable_federation} /> {obj.enable_federation?"oui":"non"}
|
||||
<Input type="switch" class="ms-2" on:change={() => {alarm.enable_federation = !alarm.enable_federation; alarm.save();}} checked={alarm.enable_federation} /> {alarm.enable_federation?"oui":"non"}
|
||||
</ListGroupItem>
|
||||
{#if alarm.next_time}
|
||||
<ListGroupItem>
|
||||
<strong>Prochaine occurrence</strong> <DateFormat date={new Date(obj.next_time)} dateStyle="long" />
|
||||
<strong>Prochaine occurrence</strong> <DateFormat date={new Date(alarm.next_time)} dateStyle="long" />
|
||||
</ListGroupItem>
|
||||
{/if}
|
||||
</ListGroup>
|
||||
|
|
@ -150,13 +139,7 @@
|
|||
{/each}
|
||||
</ListGroup>
|
||||
{/if}
|
||||
{/await}
|
||||
{:else if $page.params["kind"] == "exceptions"}
|
||||
{#await objP}
|
||||
<div class="d-flex justify-content-center align-items-center gap-2">
|
||||
<Spinner color="primary" /> Chargement en cours…
|
||||
</div>
|
||||
{:then exception}
|
||||
{:else if $page.params["kind"] == "exceptions"}
|
||||
<h2 class="mb-0">
|
||||
{slugToTitle($page.params["kind"])} du <DateRangeFormat startDate={exception._start()} endDate={exception._end()} dateStyle="long" />
|
||||
</h2>
|
||||
|
|
@ -166,11 +149,8 @@
|
|||
</p>
|
||||
{/if}
|
||||
Entre le <DateRangeFormat startDate={exception._start()} endDate={exception._end()} dateStyle="long" />
|
||||
{/await}
|
||||
{/if}
|
||||
|
||||
{#if !edit}
|
||||
{#await objP then alarm}
|
||||
{/if}
|
||||
{#if !edit}
|
||||
<ListGroup class="my-2 text-center">
|
||||
<ListGroupItem
|
||||
action
|
||||
|
|
@ -185,12 +165,12 @@
|
|||
action
|
||||
tag="button"
|
||||
class="text-danger fw-bold"
|
||||
on:click={deleteThis}
|
||||
on:click={() => deleteThis(alarm)}
|
||||
>
|
||||
<Icon name="trash" />
|
||||
Supprimer ce {slugToTitle($page.params["kind"]).toLowerCase()}
|
||||
</ListGroupItem>
|
||||
</ListGroup>
|
||||
{/await}
|
||||
{/if}
|
||||
{/if}
|
||||
{/await}
|
||||
</Container>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue