feat(dashboard): dont close out of editor after submitting

This commit is contained in:
Jake/Rads 2022-06-23 22:41:38 +02:00
parent 13eaad59db
commit dd60f646b0
2 changed files with 15 additions and 7 deletions

View File

@ -8,6 +8,8 @@
const descriptions: string[] = JSON.parse(localStorage.getItem("pk-config"))?.description_templates; const descriptions: string[] = JSON.parse(localStorage.getItem("pk-config"))?.description_templates;
let loading: boolean = false; let loading: boolean = false;
let success = false;
export let group: Group; export let group: Group;
export let editMode: boolean; export let editMode: boolean;
@ -24,6 +26,7 @@
async function submit() { async function submit() {
let data = input; let data = input;
err = []; err = [];
success = false;
if (data.color && !/^#?[A-Fa-f0-9]{6}$/.test(input.color)) { if (data.color && !/^#?[A-Fa-f0-9]{6}$/.test(input.color)) {
err.push(`"${data.color}" is not a valid color, the color must be a 6-digit hex code. (example: #ff0000)`); err.push(`"${data.color}" is not a valid color, the color must be a 6-digit hex code. (example: #ff0000)`);
@ -41,7 +44,7 @@
let res = await api().groups(group.id).patch({data}); let res = await api().groups(group.id).patch({data});
group = {...group, ...res}; group = {...group, ...res};
err = []; err = [];
editMode = false; success = true;
loading = false; loading = false;
} catch (error) { } catch (error) {
console.log(error); console.log(error);
@ -90,8 +93,11 @@
</script> </script>
{#each err as error} {#each err as error}
<Alert color="danger">{@html error}</Alert> <Alert fade={false} color="danger">{@html error}</Alert>
{/each} {/each}
{#if success}
<Alert fade={false} color="success">Group information updated!</Alert>
{/if}
<Row> <Row>
<Col xs={12} lg={4} class="mb-2"> <Col xs={12} lg={4} class="mb-2">
<Label>Name:</Label> <Label>Name:</Label>

View File

@ -14,6 +14,7 @@
export let editMode: boolean; export let editMode: boolean;
let err: string[] = []; let err: string[] = [];
let success = false;
let input: Member = member; let input: Member = member;
@ -66,15 +67,13 @@
try { try {
let res = await api().members(member.id).patch({data}); let res = await api().members(member.id).patch({data});
member = res; member = res;
err = []; success = true;
editMode = false;
loading = false;
} catch (error) { } catch (error) {
console.log(error); console.log(error);
err.push(error.message); err.push(error.message);
err = err; err = err;
loading = false;
} }
loading = false;
} }
let deleteOpen: boolean = false; let deleteOpen: boolean = false;
@ -116,8 +115,11 @@
</script> </script>
{#each err as error} {#each err as error}
<Alert color="danger">{@html error}</Alert> <Alert fade={false} color="danger">{@html error}</Alert>
{/each} {/each}
{#if success}
<Alert fade={false} color="success">Member information updated!</Alert>
{/if}
<Row> <Row>
<Col xs={12} lg={4} class="mb-2"> <Col xs={12} lg={4} class="mb-2">
<Label>Name:</Label> <Label>Name:</Label>