Skip to content

Commit

Permalink
Ajout Popup suppression dans tout les composants
Browse files Browse the repository at this point in the history
Ajout route dans popup lancertraitement
  • Loading branch information
SamuelQuetin committed Jul 3, 2024
1 parent 27073dc commit 1761346
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 88 deletions.
6 changes: 5 additions & 1 deletion src/components/DialogLancerTraitement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<v-btn v-if="!isFinished" color="primary" @click="dialog = false" aria-label="Annuler">Annuler</v-btn>
<v-spacer v-else></v-spacer>
<v-btn v-if="!isFinished" color="primary" @click="confirm()" aria-label="Valider">Valider</v-btn>
<v-btn v-else color="primary" @click="router.push('exemplarisation-tableau')" aria-label="OK">OK</v-btn>
<v-btn v-else color="primary" @click="router.push(route)" aria-label="OK">OK</v-btn>
</v-card-actions>
</v-card>
</v-skeleton-loader>
Expand All @@ -36,6 +36,10 @@ const props = defineProps({
type: Boolean,
default: false
},
route: {
required: true,
type: String,
}
})
const title = ref('Lancement du traitement en production');
const body = ref('Êtes-vous sûr de vouloir lancer le traitement en production ?<br/> Aucune annulation n\'est possible.');
Expand Down
63 changes: 63 additions & 0 deletions src/components/DialogSuppression.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<template>
<v-dialog v-model="dialog" width="500">
<v-skeleton-loader
:loading="isLoading"
class="mx-auto"
elevation="12"
width="500"
type="table-heading, list-item-two-line, table-tfoot"
>
<v-card>
<v-card-title>Suppression</v-card-title>
<v-divider></v-divider>
<v-card-text>Êtes-vous certain de vouloir supprimer définitivement cette demande ?</v-card-text>
<v-card-actions>

<v-container class="d-flex justify-space-between">
<v-btn @click="cancel()">Annuler</v-btn>
<v-btn @click="confirm()">Confirmer</v-btn>
</v-container>
</v-card-actions>
</v-card>
</v-skeleton-loader>
</v-dialog>
</template>
<script setup>
import demandesService from '@/service/DemandesService';
import router from '@/router';
import { ref } from 'vue';
const dialog = defineModel();
const emits = defineEmits(['supp'])
const props = defineProps({
returnToAccueil: {
required: false,
type: Boolean,
},
demande: {
required: true,
type: Object
}
})
const isLoading = ref(false);
function confirm() {
isLoading.value = true;
demandesService.deleteDemande(props.demande.id, props.demande.type)
.then(()=>{
if(props.returnToAccueil){
router.push('/accueil');
}
emits('supp');
}).finally(() => {
isLoading.value = false;
dialog.value = false;
})
}
function cancel() {
dialog.value = false;
}
</script>

16 changes: 7 additions & 9 deletions src/views/Exemplarisation/ExempSteps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</v-btn>
<v-btn
:disabled="!fileSelected"
@click="launchTraitement"
@click="uploadFile"
>
Lancer le traitement en simulation
</v-btn>
Expand All @@ -97,7 +97,8 @@
</v-col>
</v-row>
</v-container>
<dialog-lancer-traitement v-model="dialog" :is-loading="isLoading" @launch="launchDemande()"></dialog-lancer-traitement>
<dialog-lancer-traitement v-model="dialog" :is-loading="isLoading" route="/exemplarisation-tableau" @launch="launchDemande()"></dialog-lancer-traitement>
<dialog-suppression v-model="suppDialog" :demande="demande" return-to-accueil></dialog-suppression>
</template>

<script setup>
Expand All @@ -110,6 +111,7 @@ import Rcr from '@/components/Rcr.vue';
import TypeExemp from '@/components/Exemp/TypeExemp.vue';
import Simulation from "@/components/Simulation.vue";
import DialogLancerTraitement from '@/components/DialogLancerTraitement.vue';
import DialogSuppression from '@/components/DialogSuppression.vue';
const emits = defineEmits(['backendError', 'backendSuccess', 'login-success'])
const props = defineProps({id : {type: String}});
Expand All @@ -123,6 +125,7 @@ const alertMessage = ref();
const alertType = ref();
const isLoading = ref(false);
const dialog = ref(false);
const suppDialog = ref(false);
onMounted(()=>{
if(props.id){
Expand Down Expand Up @@ -205,7 +208,7 @@ function modifiTypeExemp() {
}
}
function launchTraitement() {
function uploadFile() {
alertMessage.value = '';
alertType.value = 'success';
isLoading.value = true;
Expand Down Expand Up @@ -234,12 +237,7 @@ function launchDemande(){
}
function deleteDemande(){
DemandesService.deleteDemande(demande.value.id, 'EXEMP')
.then(()=>{
router.push('/accueil');
}).catch(err => {
emits('backendError', err);
})
suppDialog.value = true;
}
function next() {
Expand Down
45 changes: 22 additions & 23 deletions src/views/Exemplarisation/ExempTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
</v-container>
<v-data-table :headers="headingsDemandes" :items="contentsDemandesFrontFiltered" :items-length="totalItemsFound"
:loading="!isDataLoaded" show-expand :sort-by="[{ key: 'dateModification', order: 'desc' }]"
item-key="id">
item-key="id"
>
<template v-slot:body.prepend>
<tr>
<td></td>
Expand Down Expand Up @@ -71,22 +72,22 @@
</template>

<template v-slot:item="{ item, expand }">
<tr @click="onRowClick(item)" @mouseover="onMouseOverRow(item)" @mouseleave="onMouseLeaveRow(item)"
<tr @mouseover="onMouseOverRow(item)" @mouseleave="onMouseLeaveRow(item)"
:class="{ 'highlighted-row': item.highlighted }" style="cursor: pointer;">
<td>
<v-btn icon="mdi-chevron-up" @click="item.expanded = !item.expanded" variant="text">
<v-icon>{{ item.expanded ? 'mdi-chevron-up' : 'mdi-chevron-down' }}</v-icon>
</v-btn>
</td>
<td class="text-right">{{ item.id }}</td>
<td class="text-right">{{ item.dateCreation }}</td>
<td class="text-right">{{ item.dateModification }}</td>
<td class="text-right">{{ item.iln }}</td>
<td class="text-right">{{ item.rcr }}</td>
<td class="text-right">{{ item.typeExemp }}</td>
<td class="text-right">{{ item.indexRecherche }}</td>
<td class="text-right">{{ item.etatDemande }}</td>
<td class="text-right">
<td @click="onRowClick(item)" class="text-right">{{ item.id }}</td>
<td @click="onRowClick(item)" class="text-right">{{ item.dateCreation }}</td>
<td @click="onRowClick(item)" class="text-right">{{ item.dateModification }}</td>
<td @click="onRowClick(item)" class="text-right">{{ item.iln }}</td>
<td @click="onRowClick(item)" class="text-right">{{ item.rcr }}</td>
<td @click="onRowClick(item)" class="text-right">{{ item.typeExemp }}</td>
<td @click="onRowClick(item)" class="text-right">{{ item.indexRecherche }}</td>
<td @click="onRowClick(item)" class="text-right">{{ item.etatDemande }}</td>
<td @click="onRowClick(item)" class="text-right">
<v-progress-linear v-model="item.pourcentageProgressionTraitement" :height="18" :striped="false"
color="grey-lighten-1" style="border: 1px solid grey; font-weight: bolder">
{{ item.pourcentageProgressionTraitement }} %
Expand All @@ -110,8 +111,9 @@
</td>
<td class="text-right">
<!-- Colonne Action -->
<v-icon v-if="canArchive(item)" @click="archiverDemande(item)">mdi-archive</v-icon>
<v-icon v-else-if="canCancel(item)" @click="supprimerDemande(item)">mdi-delete</v-icon>
<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>
</tr>
<tr v-if="item.expanded">
Expand All @@ -122,12 +124,14 @@
</tr>
</template>
</v-data-table>
<dialog-suppression v-model="suppDialog" :demande="suppDemande" @supp="loadItems('EXEMP', archiveFalseActiveTrue)"></dialog-suppression>
</template>

<script setup>
import { onMounted, ref } from 'vue';
import DemandesService from '@/service/DemandesService';
import router from '@/router';
import DialogSuppression from '@/components/DialogSuppression.vue';
const service = DemandesService;
Expand Down Expand Up @@ -204,6 +208,8 @@ const headingsDemandes = ref([
const contentsDemandesFromServer = ref([]);
const contentsDemandesFrontFiltered = ref([]);
const totalItemsFound = ref(0);
const suppDialog = ref(false);
const suppDemande = ref({});
//Progress bar displayed while fetching data
const isDataLoaded = ref(false);
Expand Down Expand Up @@ -298,16 +304,9 @@ function canCancel(item) {
}
//Suppression d'une demande
async function supprimerDemande(item) {
try {
await service.supprimerDemande('EXEMP', item.id);
// Mettre à jour les données après la suppression réussie
await loadItems('EXEMP');
emit('backendSuccess');
} catch (error) {
console.error(error);
emit('backendError', error);
}
function supprimerDemande(item) {
suppDialog.value = true;
suppDemande.value = item;
}
//Archivage d'une demande
Expand Down
23 changes: 17 additions & 6 deletions src/views/Modification/ModifSteps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@
</v-col>
</v-row>
</v-container>
<dialog-lancer-traitement v-model="dialog" :is-loading="isLoading" route="/modification-tableau" @launch="launchDemande()"></dialog-lancer-traitement>
<dialog-suppression v-model="suppDialog" :demande="demande" return-to-accueil></dialog-suppression>
</template>

<script setup>
Expand All @@ -157,6 +159,8 @@ import SelectFile from '@/components/SelectFile.vue';
import DownloadFile from '@/components/Modif/DownloadFile.vue';
import TypeTraitement from '@/components/Modif/TypeTraitement.vue';
import Simulation from "@/components/Simulation.vue";
import DialogLancerTraitement from '@/components/DialogLancerTraitement.vue';
import DialogSuppression from '@/components/DialogSuppression.vue';
const currentStep = ref(0);
Expand All @@ -169,6 +173,8 @@ const alertType = ref();
const isLoaded = ref(false);
const isLoading = ref(false);
const isDownloaded = ref(false);
const dialog = ref(false);
const suppDialog = ref(false);
const fileLink = ref('');
const fileName = ref('');
const typeTraitementSelected = ref();
Expand Down Expand Up @@ -303,17 +309,22 @@ function modifierTypeTraitementModifDemande() {
});
}
function launchDemande(){
isLoading.value = true;
demandesService.lancerDemande(demande.value.id,'MODIF')
.then(response => {
demande.value = response.data;
}).finally(() => {
isLoading.value = false;
})
}
function downloaded() {
isDownloaded.value = true;
}
function deleteDemande() {
demandesService.deleteDemande(demande.value.id, 'MODIF')
.then(() => {
router.push('/accueil');
}).catch(err => {
emits('backendError', err);
})
suppDialog.value = true;
}
function next() {
Expand Down
41 changes: 19 additions & 22 deletions src/views/Modification/ModifTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,22 @@
</template>

<template v-slot:item="{ item, expand }">
<tr @click="onRowClick(item)" @mouseover="onMouseOverRow(item)" @mouseleave="onMouseLeaveRow(item)"
<tr @mouseover="onMouseOverRow(item)" @mouseleave="onMouseLeaveRow(item)"
:class="{ 'highlighted-row': item.highlighted }" style="cursor: pointer;">
<td>
<v-btn icon="mdi-chevron-up" @click="item.expanded = !item.expanded" variant="text">
<v-icon>{{ item.expanded ? 'mdi-chevron-up' : 'mdi-chevron-down' }}</v-icon>
</v-btn>
</td>
<td class="text-right">{{ item.id }}</td>
<td class="text-right">{{ item.dateCreation }}</td>
<td class="text-right">{{ item.dateModification }}</td>
<td class="text-right">{{ item.iln }}</td>
<td class="text-right">{{ item.rcr }}</td>
<td class="text-right">{{ item.zone }}</td>
<td class="text-right">{{ item.traitement }}</td>
<td class="text-right">{{ item.etatDemande }}</td>
<td class="text-right">
<td @click="onRowClick(item)" class="text-right">{{ item.id }}</td>
<td @click="onRowClick(item)" class="text-right">{{ item.dateCreation }}</td>
<td @click="onRowClick(item)" class="text-right">{{ item.dateModification }}</td>
<td @click="onRowClick(item)" class="text-right">{{ item.iln }}</td>
<td @click="onRowClick(item)" class="text-right">{{ item.rcr }}</td>
<td @click="onRowClick(item)" class="text-right">{{ item.zone }}</td>
<td @click="onRowClick(item)" class="text-right">{{ item.traitement }}</td>
<td @click="onRowClick(item)" class="text-right">{{ item.etatDemande }}</td>
<td @click="onRowClick(item)" class="text-right">
<v-progress-linear v-model="item.pourcentageProgressionTraitement" :height="18" :striped="false"
color="grey-lighten-1" style="border: 1px solid grey; font-weight: bolder">
{{ item.pourcentageProgressionTraitement }} %
Expand Down Expand Up @@ -123,8 +123,8 @@
</td>
<td class="text-right">
<!-- Colonne Action -->
<v-icon v-if="canArchive(item)" @click="archiverDemande(item)">mdi-archive</v-icon>
<v-icon v-else-if="canCancel(item)" @click="supprimerDemande(item)">mdi-delete</v-icon>
<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>
</tr>
<tr v-if="item.expanded">
Expand All @@ -135,12 +135,14 @@
</tr>
</template>
</v-data-table>
<dialog-suppression v-model="suppDialog" :demande="suppDemande" @supp="loadItems('MODIF', archiveFalseActiveTrue)"></dialog-suppression>
</template>

<script setup>
import { onMounted, ref } from 'vue';
import DemandesService from '@/service/DemandesService';
import router from "@/router";
import DialogSuppression from '@/components/DialogSuppression.vue';
const service = DemandesService;
Expand Down Expand Up @@ -217,6 +219,8 @@ const headingsDemandes = ref([
const contentsDemandesFromServer = ref([]);
const contentsDemandesFrontFiltered = ref([]);
const totalItemsFound = ref(0);
const suppDialog = ref(false);
const suppDemande = ref({});
//Progress bar displayed while fetching data
const isDataLoaded = ref(false);
Expand Down Expand Up @@ -313,16 +317,9 @@ function canCancel(item) {
}
//Suppression d'une demande
async function supprimerDemande(item) {
try {
await service.supprimerDemande('MODIF', item.id);
// Mettre à jour les données après la suppression réussie
await loadItems('MODIF');
emit('backendSuccess');
} catch (error) {
console.error(error);
emit('backendError', error);
}
function supprimerDemande(item) {
suppDialog.value = true;
suppDemande.value = item;
}
//Archivage d'une demande
Expand Down
Loading

0 comments on commit 1761346

Please sign in to comment.