Add cancel and save buttons to form

This commit is contained in:
Alexis Sellier
2021-05-07 10:30:27 +02:00
parent a9a0b7baee
commit de39348776
2 changed files with 30 additions and 1 deletions
+27
View File
@@ -9,8 +9,14 @@
</script>
<script lang="typescript">
import { createEventDispatcher } from 'svelte';
export let fields: Field[];
export let editable = false ;
const dispatch = createEventDispatcher();
const save = () => dispatch('save');
const cancel = () => dispatch('cancel');
</script>
<style>
@@ -55,6 +61,18 @@
.label {
border: 1px solid transparent;
}
.actions {
margin-top: 2rem;
text-align: center;
visibility: hidden;
}
.actions button {
margin-left: 1rem;
}
.actions.editable {
visibility: visible;
}
</style>
<div class="fields">
@@ -69,3 +87,12 @@
</div>
{/each}
</div>
<div class="actions" class:editable>
<button on:click={cancel} class="small">
Cancel
</button>
<button on:click={save} class="small primary">
Save
</button>
</div>
+3 -1
View File
@@ -28,6 +28,8 @@
return registration;
});
const save = () => {};
$: isOwner = (registration: Registration): boolean => {
return registration.owner === ($session && $session.address);
};
@@ -61,7 +63,7 @@
Transfer
</button>
</header>
<Form {editable} {fields} />
<Form {editable} {fields} on:save={save} on:cancel={() => editable = false} />
</main>
{:else}
<Modal subtle>