ajouté une confirmation de deletion et un label
This commit is contained in:
1 parent
b50f539087
commit
4081048a4b
1 file changed
+25
-2
@@ -18,7 +18,8 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
imageSelectedId: 0 as number
|
imageSelectedId: 0 as number,
|
||||||
|
sure: false as boolean
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -27,6 +28,17 @@ export default defineComponent({
|
|||||||
watch: {
|
watch: {
|
||||||
images() {
|
images() {
|
||||||
this.imageSelectedId = this.images.keys().next().value;
|
this.imageSelectedId = this.images.keys().next().value;
|
||||||
|
},
|
||||||
|
imageSelectedId() {
|
||||||
|
this.sure = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
confirmDelete() {
|
||||||
|
if (this.sure)
|
||||||
|
this.$emit('delete', this.imageSelectedId);
|
||||||
|
else
|
||||||
|
this.sure = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -34,10 +46,12 @@ export default defineComponent({
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex" v-if="images.keys != null">
|
<div class="flex" v-if="images.keys != null">
|
||||||
<div>
|
<div>
|
||||||
|
<label>Selectioner une image: </label>
|
||||||
<select v-model="imageSelectedId" style="width: min-content;margin: 15px;">
|
<select v-model="imageSelectedId" style="width: min-content;margin: 15px;">
|
||||||
<option v-for="[id, image] in images" :key="id" :value="id">{{ image.name }}</option>
|
<option v-for="[id, image] in images" :key="id" :value="id">{{ image.name }}</option>
|
||||||
</select>
|
</select>
|
||||||
<button @click="$emit('delete', imageSelectedId)">Delete</button>
|
<button @click="confirmDelete()" :class="sure ? 'confirm' : ''">
|
||||||
|
{{ sure ? "Confirmer" : "Supprimer" }}</button>
|
||||||
</div>
|
</div>
|
||||||
<Image v-if="imageSelectedId !== undefined" :id="imageSelectedId"></Image>
|
<Image v-if="imageSelectedId !== undefined" :id="imageSelectedId"></Image>
|
||||||
</div>
|
</div>
|
||||||
@@ -50,6 +64,15 @@ export default defineComponent({
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.confirm {
|
||||||
|
background-color: red;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
max-width: 90%;
|
max-width: 90%;
|
||||||
max-height: 60%;
|
max-height: 60%;
|
||||||
|
|||||||
Reference in new issue
Block a user