-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajoute une modale de confirmation avant de supprimer un fichier (#788)
* add confirm modal before deleting example * open delete modal to delete notes files * force focusing button when closing notes modal * Revert "force focusing button when closing notes modal" This reverts commit 7d3e913. * Revert "open delete modal to delete notes files" This reverts commit 87c47a5. * make confirm button a danger button * make content in modal computed props * update changelog * typo
- Loading branch information
1 parent
5c59f00
commit aa5d75b
Showing
3 changed files
with
121 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
confiture-web-app/src/components/audit/DeleteFileModal.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<script setup lang="ts"> | ||
import { computed, ref } from "vue"; | ||
import DsfrModal from "../ui/DsfrModal.vue"; | ||
const modal = ref<InstanceType<typeof DsfrModal>>(); | ||
const isOpen = ref(false); | ||
const props = defineProps<{ | ||
mimeType?: string; | ||
}>(); | ||
defineEmits(["confirm", "cancel"]); | ||
defineExpose({ | ||
show: () => { | ||
isOpen.value = true; | ||
modal.value?.show(); | ||
}, | ||
hide: () => modal.value?.hide(), | ||
isOpen | ||
}); | ||
const isImage = computed(() => { | ||
return props.mimeType && props.mimeType.startsWith("image"); | ||
}); | ||
const title = computed(() => { | ||
return isImage.value | ||
? "Voulez-vous supprimer cette image ?" | ||
: "Voulez-vous supprimer ce fichier ?"; | ||
}); | ||
const description = computed(() => { | ||
return isImage.value | ||
? "Cette image sera définitivement supprimée de votre audit." | ||
: "Ce fichier sera définitivement supprimé de votre audit."; | ||
}); | ||
const confirm = computed(() => { | ||
return isImage.value ? "Supprimer l’image" : "Supprimer le fichier"; | ||
}); | ||
</script> | ||
|
||
<template> | ||
<DsfrModal | ||
id="delete-file-modal" | ||
ref="modal" | ||
aria-labelledby="delete-file-modal-title" | ||
@closed="isOpen = false" | ||
> | ||
<div class="fr-container fr-container--fluid fr-container-md"> | ||
<div class="fr-grid-row fr-grid-row--center"> | ||
<div class="fr-col-12 fr-col-md-8"> | ||
<div class="fr-modal__body"> | ||
<div class="fr-modal__header"> | ||
<button | ||
class="fr-btn--close fr-btn" | ||
aria-controls="delete-file-modal" | ||
> | ||
Fermer | ||
</button> | ||
</div> | ||
<div class="fr-modal__content"> | ||
<h1 id="delete-file-modal-title" class="fr-modal__title"> | ||
{{ title }} | ||
</h1> | ||
<p>{{ description }}</p> | ||
</div> | ||
<div class="fr-modal__footer"> | ||
<ul | ||
class="fr-btns-group fr-btns-group--right fr-btns-group--inline-reverse fr-btns-group--inline-lg fr-btns-group--icon-left" | ||
> | ||
<li> | ||
<button | ||
class="fr-btn danger-button" | ||
@click="$emit('confirm')" | ||
> | ||
{{ confirm }} | ||
</button> | ||
</li> | ||
<li> | ||
<button | ||
class="fr-btn fr-btn--secondary" | ||
@click="$emit('cancel')" | ||
> | ||
Annuler | ||
</button> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</DsfrModal> | ||
</template> |