2023-01-03 08:13:08 +00:00
|
|
|
<script lang="ts">
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
|
|
|
|
import {
|
|
|
|
Button,
|
|
|
|
Spinner,
|
|
|
|
} from 'sveltestrap';
|
|
|
|
|
|
|
|
import type { CustomForm } from '$lib/model/custom_form';
|
2023-01-18 17:35:25 +00:00
|
|
|
import { t } from '$lib/translations';
|
2023-01-03 08:13:08 +00:00
|
|
|
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
|
|
|
|
export let edit = false;
|
|
|
|
export let form: CustomForm|null = null;
|
|
|
|
export let nextInProgress = false;
|
|
|
|
export let previousInProgress = false;
|
|
|
|
export let submitForm: string|null = null;
|
|
|
|
|
|
|
|
let disabled = false;
|
|
|
|
$: disabled = nextInProgress || previousInProgress;
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div {...$$restProps}>
|
|
|
|
{#if form}
|
|
|
|
{#if (!form.previousEditButtonText || !edit) && form.previousButtonText}
|
|
|
|
<Button
|
|
|
|
type="button"
|
|
|
|
class="mx-1"
|
|
|
|
color="secondary"
|
|
|
|
outline
|
|
|
|
{disabled}
|
|
|
|
on:click={() => dispatch('previous-state')}
|
|
|
|
>
|
|
|
|
{#if previousInProgress}
|
|
|
|
<Spinner label="Spinning" size="sm" />
|
|
|
|
{/if}
|
2023-01-18 17:35:25 +00:00
|
|
|
{$t(form.previousButtonText)}
|
2023-01-03 08:13:08 +00:00
|
|
|
</Button>
|
|
|
|
{/if}
|
|
|
|
{#if (!form.nextEditButtonText || !edit) && form.nextButtonText}
|
|
|
|
<Button
|
|
|
|
type="submit"
|
|
|
|
class="mx-1"
|
|
|
|
color="primary"
|
|
|
|
{disabled}
|
|
|
|
form={submitForm}
|
|
|
|
>
|
|
|
|
{#if nextInProgress}
|
|
|
|
<Spinner label="Spinning" size="sm" />
|
|
|
|
{/if}
|
2023-01-18 17:35:25 +00:00
|
|
|
{$t(form.nextButtonText)}
|
2023-01-03 08:13:08 +00:00
|
|
|
</Button>
|
|
|
|
{/if}
|
|
|
|
{#if edit && form.previousEditButtonText}
|
|
|
|
<Button
|
|
|
|
type="button"
|
|
|
|
class="mx-1"
|
|
|
|
color="secondary"
|
|
|
|
outline
|
|
|
|
{disabled}
|
|
|
|
on:click={() => dispatch('previous-state')}
|
|
|
|
>
|
|
|
|
{#if previousInProgress}
|
|
|
|
<Spinner label="Spinning" size="sm" />
|
|
|
|
{/if}
|
2023-01-18 17:35:25 +00:00
|
|
|
{$t(form.previousEditButtonText)}
|
2023-01-03 08:13:08 +00:00
|
|
|
</Button>
|
|
|
|
{/if}
|
|
|
|
{#if edit && form.nextEditButtonText}
|
|
|
|
<Button
|
|
|
|
type="submit"
|
|
|
|
class="mx-1"
|
|
|
|
color="primary"
|
|
|
|
{disabled}
|
|
|
|
form={submitForm}
|
|
|
|
>
|
|
|
|
{#if nextInProgress}
|
|
|
|
<Spinner label="Spinning" size="sm" />
|
|
|
|
{/if}
|
2023-01-18 17:35:25 +00:00
|
|
|
{$t(form.nextEditButtonText)}
|
2023-01-03 08:13:08 +00:00
|
|
|
</Button>
|
|
|
|
{/if}
|
|
|
|
{:else}
|
|
|
|
<Button
|
|
|
|
type="button"
|
|
|
|
class="mx-1"
|
|
|
|
color="secondary"
|
|
|
|
outline
|
|
|
|
{disabled}
|
|
|
|
on:click={() => dispatch('previous-state')}
|
|
|
|
>
|
|
|
|
{#if previousInProgress}
|
|
|
|
<Spinner label="Spinning" size="sm" />
|
|
|
|
{/if}
|
2023-01-18 17:35:25 +00:00
|
|
|
{$t('common.cancel')}
|
2023-01-03 08:13:08 +00:00
|
|
|
</Button>
|
|
|
|
<Button
|
|
|
|
type="submit"
|
|
|
|
class="mx-1"
|
|
|
|
color="primary"
|
|
|
|
{disabled}
|
|
|
|
form={submitForm}
|
|
|
|
>
|
|
|
|
{#if nextInProgress}
|
|
|
|
<Spinner label="Spinning" size="sm" />
|
|
|
|
{/if}
|
2023-01-18 17:35:25 +00:00
|
|
|
{$t('common.next')} >
|
2023-01-03 08:13:08 +00:00
|
|
|
</Button>
|
|
|
|
{/if}
|
|
|
|
</div>
|