Skip to content

Commit

Permalink
add 'change' and 'disable when done' functionality to data inptu
Browse files Browse the repository at this point in the history
  • Loading branch information
MaHaWo committed Oct 18, 2024
1 parent c79c449 commit 4ff8432
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
7 changes: 5 additions & 2 deletions frontend/src/lib/components/DataInput/DataInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
export let textTrigger: string = 'noAdditionalText';
export let showTextField: boolean = false;
export let additionalInput: any = null;
export let disabled: boolean = false;
// data to display and event handlers for dynamcis.
export let properties: any = {};
Expand Down Expand Up @@ -53,6 +53,7 @@
$: valid = evalValid(value);
$: highlight = !valid && properties.required === true;
$: showTextField = checkShowTextfield(value);
$: console.log('value in datainput: ', value);
</script>

{#if label}
Expand All @@ -62,8 +63,9 @@
<div class="space-y-4">
<svelte:component
this={component}
{disabled}
class={highlight
? 'rounded border-2 border-primary-600 dark:border-primary-600 ' + componentClass
? 'border-primary-600 dark:border-primary-600 rounded border-2 ' + componentClass
: componentClass}
bind:value
{...properties}
Expand All @@ -74,6 +76,7 @@

{#if showTextField === true}
<Textarea
{disabled}
bind:value={additionalInput}
on:blur={additionalEventHandlers['on:blur']}
on:change={additionalEventHandlers['on:change']}
Expand Down
28 changes: 21 additions & 7 deletions frontend/src/lib/components/UserDataInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,42 @@
label={element.props.label}
properties={element.props}
textTrigger={element.props.textTrigger}
disabled={done}
eventHandlers={{
'on:change': () => {
done = false;
element?.onchange();
'on:change': (e) => {
if (element.onchange) {
element.onchange(e);
}
},
'on:blur': element.onblur,
'on:click': element.onclick
}}
additionalEventHandlers={{
'on:change': () => {
done = false;
'on:change': (e) => {
if (element.additionalOnChange) {
element.additionalOnChange(e);
}
},
'on:blur': element.onblur,
'on:click': element.onclick
}}
/>
{/each}
{#if done}
<div class="m-2 flex items-center justify-center p-2 text-gray-700 dark:text-gray-400">
<CheckCircleOutline size="xl" color="green" class="m-2" />
<div
class="m-2 flex w-full items-center justify-center p-2 text-gray-700 dark:text-gray-400"
>
<CheckCircleOutline size="xl" color="green" class="" />
{$_('userData.submitSuccessMessage')}
</div>

<Button
type="button"
class="dark:bg-primay-700 bg-primary-700 hover:bg-primary-800 dark:hover:bg-primary-800 w-full text-center text-sm text-white hover:text-white"
on:click={(e) => {
done = false;
}}>{$_('userData.changeButtonLabel')}</Button
>
{:else}
<Button
class="dark:bg-primay-700 bg-primary-700 hover:bg-primary-800 dark:hover:bg-primary-800 w-full text-center text-sm text-white hover:text-white"
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"alertMessageMissing": "Bitte füllen Sie die benötigten Felder (hervorgehoben) aus.",
"alertMessageError": "Ein Fehler ist aufgetreten",
"submitButtonLabel": "Abschließen",
"changeButtonLabel": "Ändern",
"submitSuccessMessage": "Vielen Dank!",
"yearOfBirth": {
"label": "Geburtsjahr",
Expand Down

0 comments on commit 4ff8432

Please sign in to comment.