You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.4 KiB
50 lines
1.4 KiB
<script lang="ts">
|
|
import stuffLogClient from "../clients/stufflog";
|
|
import Modal from "../components/Modal.svelte";
|
|
import modalStore from "../stores/modal";
|
|
import groupStore from "../stores/group";
|
|
|
|
const md = $modalStore;
|
|
if (md.name !== "item.delete") {
|
|
throw new Error("Wrong form");
|
|
}
|
|
|
|
let item = md.item;
|
|
let group = md.group;
|
|
let name = item.name;
|
|
let description = item.description;
|
|
let groupWeight = item.groupWeight;
|
|
let error = null;
|
|
|
|
function onSubmit() {
|
|
stuffLogClient.deleteItem(item.id).then(() => {
|
|
groupStore.markStale();
|
|
modalStore.close();
|
|
}).catch(err => {
|
|
error = err.message ? err.message : err.toString();
|
|
})
|
|
|
|
error = null;
|
|
}
|
|
|
|
function onClose() {
|
|
modalStore.close();
|
|
}
|
|
</script>
|
|
|
|
<Modal show title="Edit Item" error={error} closable on:close={onClose}>
|
|
<form on:submit|preventDefault={onSubmit}>
|
|
<label for="groupName">Group</label>
|
|
<input disabled name="groupName" type="text" value={group.name} />
|
|
<label for="name">Name</label>
|
|
<input disabled name="name" type="text" value={name} />
|
|
<label for="description">Description</label>
|
|
<textarea disabled name="description" value={description} />
|
|
<label for="groupWeight">Group Weight</label>
|
|
<input disabled name="groupWeight" type="number" value={groupWeight} />
|
|
|
|
<hr />
|
|
|
|
<button type="submit">Delete Item</button>
|
|
</form>
|
|
</Modal>
|