2023-01-24 16:05:51 +01:00
|
|
|
<script lang="ts">
|
|
|
|
import inventoryApi from "../stores/api";
|
|
|
|
import { inventory } from "../stores/inventory";
|
2023-01-25 01:30:27 +01:00
|
|
|
import Success from "./Success.svelte";
|
2023-01-24 16:05:51 +01:00
|
|
|
|
|
|
|
export let finishKind = "";
|
|
|
|
let windowIsVisible = "";
|
2023-01-25 01:30:27 +01:00
|
|
|
let name = "";
|
|
|
|
let comment = "";
|
|
|
|
|
|
|
|
let successWindow;
|
2023-01-24 16:05:51 +01:00
|
|
|
|
|
|
|
export const showWindow = () => windowIsVisible = "is-active";
|
|
|
|
|
|
|
|
const closeWindow = () => {
|
|
|
|
windowIsVisible = "";
|
2023-01-25 01:30:27 +01:00
|
|
|
};
|
2023-01-24 16:05:51 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="modal {windowIsVisible}">
|
|
|
|
<div class="modal-background"/>
|
|
|
|
<div class="modal-card">
|
2023-01-25 01:30:27 +01:00
|
|
|
|
2023-01-24 16:05:51 +01:00
|
|
|
{#if finishKind === "reset"}
|
|
|
|
<header class="modal-card-head">
|
|
|
|
<p class="modal-card-title">Inventur neu beginnen ❌</p>
|
|
|
|
<button class="delete" aria-label="close" on:click={closeWindow}></button>
|
|
|
|
</header>
|
|
|
|
<section class="modal-card-body">
|
|
|
|
<p>Bist du dir sicher, dass du die Inventur abbrechen willst? Damit werden alle bereits eingegebenen Werte zurückgesetzt.</p>
|
|
|
|
</section>
|
|
|
|
<footer class="modal-card-foot">
|
|
|
|
<button class="button is-danger" on:click={inventoryApi.reset}>Ja, Reset!</button>
|
|
|
|
<button class="button" on:click={closeWindow}>Abbrechen</button>
|
|
|
|
</footer>
|
2023-01-25 01:30:27 +01:00
|
|
|
|
2023-01-24 16:05:51 +01:00
|
|
|
{:else if finishKind === "finish"}
|
2023-01-25 01:30:27 +01:00
|
|
|
<!--Prevent saving empty inventories-->
|
|
|
|
{#if $inventory.length > 0}
|
|
|
|
<header class="modal-card-head">
|
|
|
|
<p class="modal-card-title">Inventur abschließen ✅</p>
|
|
|
|
<button class="delete" aria-label="close" on:click={closeWindow}></button>
|
|
|
|
</header>
|
|
|
|
<section class="modal-card-body">
|
|
|
|
<p>
|
|
|
|
Vielen Dank, dass du eine Inventur gemacht hast! 🫶
|
|
|
|
<br>
|
|
|
|
Bitte gib noch deinen <strong>Namen</strong> ein. Außerdem hast du hier noch Platz für irgendwelche <strong>Kommentare</strong> zu deiner Inventur.
|
|
|
|
</p>
|
2023-01-24 16:05:51 +01:00
|
|
|
<br>
|
2023-01-25 01:30:27 +01:00
|
|
|
<div class="field">
|
|
|
|
<input class="input is-primary" type="text" placeholder="Name" bind:value={name} />
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<textarea class="textarea is-info" placeholder="Kommentare" bind:value={comment} />
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<footer class="modal-card-foot">
|
|
|
|
{#if name.length > 0}
|
|
|
|
<button class="button is-primary" on:click={() => {
|
|
|
|
// TODO: Hier muss dann der Request an das Backend rausgehen!
|
|
|
|
closeWindow();
|
|
|
|
successWindow.showWindow();
|
|
|
|
setTimeout(() => inventoryApi.reset(), 2000);
|
|
|
|
}}>Abschließen</button>
|
|
|
|
{:else}
|
|
|
|
<button class="button" disabled>Abschließen</button>
|
|
|
|
{/if}
|
|
|
|
<button class="button" on:click={closeWindow}>Abbrechen</button>
|
|
|
|
</footer>
|
|
|
|
{:else}
|
|
|
|
<section class="modal-card-body">
|
|
|
|
<p>Du hast noch gar keine Daten erfasst... 🤓</p>
|
2023-01-24 16:05:51 +01:00
|
|
|
</section>
|
|
|
|
<footer class="modal-card-foot">
|
2023-01-25 01:30:27 +01:00
|
|
|
<button class="button" on:click={closeWindow}>Zurück</button>
|
2023-01-24 16:05:51 +01:00
|
|
|
</footer>
|
2023-01-25 01:30:27 +01:00
|
|
|
{/if}
|
2023-01-24 16:05:51 +01:00
|
|
|
{/if}
|
2023-01-25 01:30:27 +01:00
|
|
|
|
2023-01-24 16:05:51 +01:00
|
|
|
</div>
|
2023-01-25 01:30:27 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<Success bind:this={successWindow} />
|