Skip to content

Commit

Permalink
Merge pull request #188 from abes-esr/Fix-Stop-traitement
Browse files Browse the repository at this point in the history
Ajout du catch du message d'erreur
  • Loading branch information
EryneKL authored Dec 6, 2024
2 parents 9f2c943 + 4d35ac8 commit 5884f37
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
23 changes: 13 additions & 10 deletions src/components/Supp/BtnStop.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
<template>
<v-btn icon="mdi-stop" variant="plain" @click="click">
<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 v-model="dialog" :id="id" @stop="emits('stop')" @on-error="throwError">
</dialog-confirmation-stop>
</template>
<script setup>
import DialogConfirmationStop from "@/components/Supp/DialogConfirmationStop.vue";
import {ref} from "vue";
import DialogConfirmationStop from '@/components/Supp/DialogConfirmationStop.vue';
import { ref } from 'vue';
const emits = defineEmits(['stop'])
const emits = defineEmits(['stop', 'onError']);
const props = defineProps({
id:{
required:true,
type:Number
id: {
required: true,
type: Number
}
})
});
const dialog = ref(false);
function click() {
dialog.value = true
dialog.value = true;
}
function throwError(err) {
emits('onError', err);
}
</script>
28 changes: 16 additions & 12 deletions src/components/Supp/DialogConfirmationStop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<v-card>
<v-card-title>Confirmation</v-card-title>
<v-card-text>
Voulez vous vraiment stopper le traitement sur la demande N°{{id}} ?
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>
Expand All @@ -13,21 +13,25 @@
</v-dialog>
</template>
<script setup>
import itemService from "@/service/ItemService";
import itemService from '@/service/ItemService';
const emits = defineEmits(['stop'])
const emits = defineEmits(['stop', 'onError']);
const dialog = defineModel();
const props = defineProps({
id:{
required:true,
type:Number
id: {
required: true,
type: Number
}
})
});
function stopDemande(){
itemService.stopDemande(props.id).finally(() => {
dialog.value = false;
emits('stop');
});
function stopDemande() {
itemService.stopDemande(props.id)
.catch(err => {
emits('onError', err);
})
.finally(() => {
dialog.value = false;
emits('stop');
});
}
</script>
17 changes: 10 additions & 7 deletions src/views/Suppression/SuppTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
</v-tooltip>
</v-chip>
</v-container>
<v-data-table :headers="filteredHeadingsDemandes" :items="contentsDemandesFrontFiltered" :items-length="totalItemsFound"
<v-data-table :headers="filteredHeadingsDemandes" :items="contentsDemandesFrontFiltered"
:items-length="totalItemsFound"
:loading="!isDataLoaded" show-expand :sort-by="sortBy"
item-key="id">
<template v-slot:body.prepend>
Expand Down Expand Up @@ -107,7 +108,8 @@
</td>
<td class="text-center">
<!-- Colonne Action -->
<btn-stop v-if="canStop(item)" :id="item.id" @stop="loadItems('SUPP', isArchiveDemandesDisplayed)"></btn-stop>
<btn-stop v-if="canStop(item)" :id="item.id" @stop="loadItems('SUPP', isArchiveDemandesDisplayed)"
@on-error="throwError"></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>
<v-btn v-if="item.etatDemande === 'Archivé'" variant="plain" icon="mdi-package-up" @click="restaurerDemande(item)"></v-btn>
Expand All @@ -127,15 +129,16 @@ import DialogSuppression from '@/components/Dialog/DialogSuppression.vue';
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";
import { useAuthStore } from '@/store/authStore';
import BtnStop from '@/components/Supp/BtnStop.vue';
import itemService from "@/service/ItemService";
//Emit
const emit = defineEmits(['backendError', 'backendSuccess']);
//Data
const isAdmin = useAuthStore().isAdmin();
const isAdmin = useAuthStore()
.isAdmin();
const extendedAllILN = ref(false);
const headingsDemandes = [
{
Expand Down Expand Up @@ -228,7 +231,7 @@ const headingsDemandes = [
];
const filteredHeadingsDemandes = computed(() =>
headingsDemandes.filter(heading => heading.display !== false)
)
);
const listStatut = [
'En saisie',
Expand Down Expand Up @@ -359,7 +362,7 @@ function canCancel(item) {
}
function canStop(item) {
return item.etatDemande === 'En cours de traitement' || item.etatDemande === 'En attente'
return item.etatDemande === 'En cours de traitement' || item.etatDemande === 'En attente';
}
//Suppression d'une demande
Expand Down

0 comments on commit 5884f37

Please sign in to comment.