Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: should be able to close the form if no change has been made #514

Merged
merged 3 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions client/src/lib/components/DatasetForm/DatasetForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@
};

const handleFieldChange = async (event: Event) => {
dispatch("touched", true);
handleChange(event);
dispatch("touched", true);
};

const hasError = (error: string | string[]) => {
Expand Down Expand Up @@ -248,7 +248,6 @@
value={$form.title}
error={$errors.title}
on:input={handleFieldChange}
on:blur={handleFieldChange}
/>

<TextareaField
Expand All @@ -259,7 +258,6 @@
value={$form.description}
error={$errors.description}
on:input={handleFieldChange}
on:blur={handleFieldChange}
/>

<InputField
Expand All @@ -270,7 +268,6 @@
value={$form.service}
error={$errors.service}
on:input={handleFieldChange}
on:blur={handleFieldChange}
/>

<GeographicalCoverageField
Expand Down Expand Up @@ -337,7 +334,6 @@
value={$form.technicalSource}
error={$errors.technicalSource}
on:input={handleFieldChange}
on:blur={handleFieldChange}
/>
</div>

Expand Down Expand Up @@ -435,7 +431,6 @@
value={$form.url}
error={$errors.url}
on:input={handleFieldChange}
on:blur={handleFieldChange}
/>

<LicenseField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</h1>
<p>
Il semblerait que vous ayez effectué des modifications non sauvegardées
sur cette fiche de données. souhaitez-vous vraiment quitter ce formulaire
sur cette fiche de données. Souhaitez-vous vraiment quitter ce formulaire
et perdre votre saisie ?
</p>
</div>
Expand Down
7 changes: 3 additions & 4 deletions client/src/routes/(app)/fiches/[id]/edit/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

let loading = false;

let formHasBeenTouched = false;
let formHasbeenTouched = false;

const onSave = async (event: CustomEvent<DatasetFormData>) => {
if (!Maybe.Some(dataset)) {
Expand Down Expand Up @@ -80,8 +80,7 @@
Catalogue : {dataset.catalogRecord.organization.name}
</p>
</div>

{#if formHasBeenTouched}
{#if formHasbeenTouched}
<button
class="fr-btn fr-icon-close-line fr-btn--icon fr-btn--secondary"
data-fr-opened="false"
Expand Down Expand Up @@ -117,7 +116,7 @@
submitLabel="Enregistrer les modifications"
loadingLabel="Modification en cours..."
on:save={onSave}
on:touched={() => (formHasBeenTouched = true)}
on:touched={() => (formHasbeenTouched = true)}
/>

{#if $isAdmin}
Expand Down