Skip to content

Commit

Permalink
ITEM-366 Ajouter bouton stop dans le tableau de bord et de l'appel au ws
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelQuetin committed Dec 3, 2024
1 parent 04b9abd commit 3d0469e
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/components/Supp/BtnStop.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<template>
<v-btn icon="mdi-stop" variant="plain" @click="click">
</v-btn>
<dialog-confirmation-stop v-model="dialog" :id="id" @stop="emits('stop')">
</dialog-confirmation-stop>
</template>
<script setup>
import DialogConfirmationStop from "@/components/Supp/DialogConfirmationStop.vue";
import {ref} from "vue";
const emits = defineEmits(['stop'])
const props = defineProps({
id:{
required:true,
type:Number
}
})
const dialog = ref(false);
function click() {
dialog.value = true
}
</script>
33 changes: 33 additions & 0 deletions src/components/Supp/DialogConfirmationStop.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<template>
<v-dialog v-model="dialog" width="500">
<v-card>
<v-card-title>Confirmation</v-card-title>
<v-card-text>
Voulez vous vraiment stopper le traitement sur la demande N°{{id}} ?
</v-card-text>
<v-card-actions>
<v-btn @click="dialog=false">Refuser</v-btn>
<v-btn @click="stopDemande">Confirmer</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script setup>
import itemService from "@/service/ItemService";
const emits = defineEmits(['stop'])
const dialog = defineModel();
const props = defineProps({
id:{
required:true,
type:Number
}
})
function stopDemande(){
itemService.stopDemande(props.id).finally(() => {
dialog.value = false;
emits('stop');
});
}
</script>
4 changes: 4 additions & 0 deletions src/service/ItemService.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ export class ItemService {
return response.data
})
}

stopDemande(id) {
return this.client.patch('stopDemandeSupp/' + id);
}
}

export default new ItemService()
6 changes: 6 additions & 0 deletions src/views/Suppression/SuppTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
</td>
<td class="text-center">
<!-- Colonne Action -->
<btn-stop v-if="canStop(item)" :id="item.id" @stop="loadItems('SUPP', isArchiveDemandesDisplayed)"></btn-stop>
<v-btn v-if="canArchive(item)" variant="plain" icon="mdi-archive" @click="archiverDemande(item)"></v-btn>
<v-btn v-else-if="canCancel(item)" variant="plain" icon="mdi-delete" @click="supprimerDemande(item)"></v-btn>
</td>
Expand All @@ -125,6 +126,7 @@ import DialogCommentaire from '@/components/Dialog/DialogCommentaire.vue';
import MenuDownloadFile from '@/components/MenuDownloadFile.vue';
import moment from 'moment/moment';
import {useAuthStore} from "@/store/authStore";
import BtnStop from "@/components/Supp/BtnStop.vue";
//Emit
const emit = defineEmits(['backendError', 'backendSuccess']);
Expand Down Expand Up @@ -352,6 +354,10 @@ function canCancel(item) {
return item.etatDemande !== 'Terminé' && item.etatDemande !== 'En cours de traitement' && item.etatDemande !== 'En attente';
}
function canStop(item) {
return item.etatDemande === 'En cours de traitement' || item.etatDemande === 'En attente'
}
//Suppression d'une demande
function supprimerDemande(item) {
suppDialog.value = true;
Expand Down

0 comments on commit 3d0469e

Please sign in to comment.