Add modal for renaming operation
This commit is contained in:
@@ -11,6 +11,13 @@
|
|||||||
|
|
||||||
import timeElapsed from '$lib/helper/timeElapsed';
|
import timeElapsed from '$lib/helper/timeElapsed';
|
||||||
|
|
||||||
|
import Alert from '$lib/components/ui/Alert.svelte';
|
||||||
|
import Button from '$lib/components/ui/Button.svelte';
|
||||||
|
import Modal from '$lib/components/ui/Modal/Modal.svelte';
|
||||||
|
import ModalTitle from '$lib/components/ui/Modal/ModalTitle.svelte';
|
||||||
|
import ModalContent from '$lib/components/ui/Modal/ModalContent.svelte';
|
||||||
|
import ModalFooter from '$lib/components/ui/Modal/ModalFooter.svelte';
|
||||||
|
|
||||||
/** @type {import('./$types').PageData} */
|
/** @type {import('./$types').PageData} */
|
||||||
/** export let data; */
|
/** export let data; */
|
||||||
|
|
||||||
@@ -20,6 +27,13 @@
|
|||||||
let list = [];
|
let list = [];
|
||||||
$: list;
|
$: list;
|
||||||
|
|
||||||
|
let open = false;
|
||||||
|
$: open;
|
||||||
|
let inProgress = false;
|
||||||
|
$: inProgress;
|
||||||
|
let err = false;
|
||||||
|
$: err;
|
||||||
|
|
||||||
let rename_input;
|
let rename_input;
|
||||||
$: rename_input;
|
$: rename_input;
|
||||||
|
|
||||||
@@ -49,6 +63,11 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function uploadSuccessful() {
|
||||||
|
console.log('reset');
|
||||||
|
open = false;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="-z-10 bg-white">
|
<div class="-z-10 bg-white">
|
||||||
@@ -133,19 +152,26 @@
|
|||||||
data_obj["new_name"] = new_name
|
data_obj["new_name"] = new_name
|
||||||
data_obj["old_name"] = event.currentTarget.id.split('__')[1]
|
data_obj["old_name"] = event.currentTarget.id.split('__')[1]
|
||||||
|
|
||||||
|
|
||||||
|
open = true;
|
||||||
|
inProgress = true;
|
||||||
|
|
||||||
const response = await fetch(url,
|
const response = await fetch(url,
|
||||||
{method: 'PUT', body: JSON.stringify( data_obj )
|
{method: 'PUT', body: JSON.stringify( data_obj )
|
||||||
})
|
})
|
||||||
|
|
||||||
|
inProgress = false;
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
err = true;
|
||||||
if (response.status == 400) {
|
if (response.status == 400) {
|
||||||
let json_res = await response.json()
|
let json_res = await response.json()
|
||||||
alert(json_res['msg'])
|
// alert(json_res['msg'])
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new Error(`Fehlgeschlagen: ${response.status}`)
|
throw new Error(`Fehlgeschlagen: ${response.status}`)
|
||||||
} else {
|
} else {
|
||||||
|
uploadSuccessful();
|
||||||
setTimeout(() => {window.location.reload()}, 500)
|
setTimeout(() => {window.location.reload()}, 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,4 +260,17 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Modal {open}
|
||||||
|
><ModalTitle>Umbenennen</ModalTitle><ModalContent>
|
||||||
|
{#if inProgress}
|
||||||
|
<p class="py-2 mb-1">Vorgang läuft...</p>
|
||||||
|
{/if}
|
||||||
|
{#if err}
|
||||||
|
<Alert class="w-full" type="error">Fehler beim Umbenennen</Alert>
|
||||||
|
{/if}
|
||||||
|
</ModalContent>
|
||||||
|
<ModalFooter><Button disabled={inProgress} on:click={uploadSuccessful}>Ok</Button></ModalFooter>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user