Skip to content

Commit

Permalink
FEAT Ajout suppression demande SUPP & Archivage demande SUPP
Browse files Browse the repository at this point in the history
REFACTOR Sur tdb :
isActiveDemandesDisplayed => isArchiveDemandeDisplayed
  • Loading branch information
SamuelQuetin committed Aug 26, 2024
1 parent 81074be commit a881450
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
6 changes: 5 additions & 1 deletion src/components/Supp/TypeFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</template>
<script setup>
const emits = defineEmits(['clicked'])
const emits = defineEmits(['clicked','deleted'])
const props = defineProps({
isLoading: {
type: Boolean,
Expand All @@ -37,6 +37,10 @@ function onClick(type) {
emits('clicked')
}
function deleted() {
emits('deleted');
}
</script>

<style scoped>
Expand Down
13 changes: 10 additions & 3 deletions src/views/Suppression/SuppSteps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
</v-container>
</v-stepper-window-item>
<v-stepper-window-item>
<type-file v-if="!typeFileSelected" v-model="typeFileSelected" @clicked="setTypeSelected()"></type-file>
<select-file v-else-if="!isLoaded" :is-loading="isLoading" v-model="fileSelected" :typeFile="typeFileSelected">Selection du fichier {{typeFileSelected}}</select-file>
<download-file v-if="isLoaded" :file-link="fileLink" :file-name="fileName" @clicked="isDownloaded = true">Téléchargement du fichier PPN/RCR/EPN</download-file>
<type-file v-if="!typeFileSelected" v-model="typeFileSelected" @clicked="setTypeSelected()" @deleted="deleteDemande()"></type-file>
<select-file v-else-if="!isLoaded" :is-loading="isLoading" v-model="fileSelected" :typeFile="typeFileSelected" @deleted="deleteDemande()">Selection du fichier {{typeFileSelected}}</select-file>
<download-file v-if="isLoaded" :file-link="fileLink" :file-name="fileName" @clicked="isDownloaded = true" @deleted="deleteDemande()">Téléchargement du fichier PPN/RCR/EPN</download-file>
<v-alert
v-if="alertMessage"
:type="alertType"
Expand Down Expand Up @@ -132,6 +132,7 @@
</v-col>
</v-row>
</v-container>
<dialog-suppression v-model="suppDialog" :demande="demande" return-to-accueil></dialog-suppression>
</template>

<script setup>
Expand All @@ -142,6 +143,7 @@ import demandesService from '@/service/DemandesService';
import DownloadFile from "@/components/Modif/DownloadFile.vue";
import router from '@/router'
import Rcr from '@/components/Rcr.vue';
import DialogSuppression from '@/components/Dialog/DialogSuppression.vue';
const currentStep = ref(0);
const demande = ref();
Expand All @@ -161,6 +163,7 @@ const isLoading = ref(false);
const alertMessage = ref('');
const alertType = ref('success');
const dialog = ref(false);
const suppDialog = ref(false);
onMounted(()=>{
if (props.id) {
Expand Down Expand Up @@ -309,4 +312,8 @@ function raz(){
isLoaded.value = false;
isDownloaded.value = false;
}
function deleteDemande() {
suppDialog.value = true;
}
</script>
22 changes: 11 additions & 11 deletions src/views/Suppression/SuppTable.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<template>
<v-container fluid>
<v-chip :variant="isActiveDemandesDisplayed ? 'plain' : 'tonal'" style="margin-right: 10px" @click="switchArchiveActiveDisplay(!isActiveDemandesDisplayed)">
<v-chip :variant="isArchiveDemandesDisplayed ? 'plain' : 'tonal'" style="margin-right: 10px" @click="switchArchiveActiveDisplay(!isArchiveDemandesDisplayed)">
Suppression d'exemplaires
</v-chip>
<v-chip :variant="!isActiveDemandesDisplayed ? 'plain' : 'tonal'" @click="switchArchiveActiveDisplay(!isActiveDemandesDisplayed)">
<v-chip :variant="!isArchiveDemandesDisplayed ? 'plain' : 'tonal'" @click="switchArchiveActiveDisplay(!isArchiveDemandesDisplayed)">
Suppression d'exemplaires archivées
</v-chip>
<v-chip variant="text">
<v-tooltip activator="parent" location="bottom">
<template v-slot:activator="{ props }">
<label>
<input type="checkbox" v-model="extendedAllILN" style="margin-right: 5px"
@change="loadItems('SUPP', isActiveDemandesDisplayed)">
@change="loadItems('SUPP', isArchiveDemandesDisplayed)">
<span v-bind="props">Affichage étendu sur tous les ILN</span>
</label>
</template>
Expand Down Expand Up @@ -104,7 +104,7 @@
</template>
</v-data-table>
<dialog-suppression v-model="suppDialog" :demande="suppDemande"
@supp="loadItems('SUPP', isActiveDemandesDisplayed)"></dialog-suppression>
@supp="loadItems('SUPP', isArchiveDemandesDisplayed)"></dialog-suppression>
</template>

<script setup>
Expand Down Expand Up @@ -230,11 +230,11 @@ const isDialogOpen = computed(() => {
});
//Actives or archives demands displayed
const isActiveDemandesDisplayed = ref(false);
const isArchiveDemandesDisplayed = ref(false);
//Data initialisation
onMounted(() => {
loadItems('SUPP', isActiveDemandesDisplayed.value);
loadItems('SUPP', isArchiveDemandesDisplayed.value);
contentsDemandesFromServer.value = [...contentsDemandesFromServer.value];
demandesService.getTypeTraitement()
.then(response => {
Expand All @@ -246,7 +246,7 @@ onMounted(() => {
});
polling = setInterval(() => {
if (!isDialogOpen.value) {
loadItems('SUPP', isActiveDemandesDisplayed.value)
loadItems('SUPP', isArchiveDemandesDisplayed.value)
.then(() => {
filterItems();
});
Expand All @@ -259,8 +259,8 @@ onBeforeUnmount(() => {
});
function switchArchiveActiveDisplay(value) {
isActiveDemandesDisplayed.value = value;
loadItems('SUPP', isActiveDemandesDisplayed.value);
isArchiveDemandesDisplayed.value = value;
loadItems('SUPP', isArchiveDemandesDisplayed.value);
}
async function loadItems(type, archive) {
Expand Down Expand Up @@ -330,7 +330,7 @@ async function archiverDemande(item) {
try {
await demandesService.archiverDemande('SUPP', item.id);
// Mettre à jour les données après l'archivage réussi
await loadItems('SUPP');
await loadItems('SUPP',isArchiveDemandesDisplayed.value);
emit('backendSuccess');
} catch (error) {
console.error(error);
Expand All @@ -345,7 +345,7 @@ function onRowClick(item) {
}
function saveComment() {
loadItems('SUPP', isActiveDemandesDisplayed.value)
loadItems('SUPP', isArchiveDemandesDisplayed.value)
.then(() => {
filterItems();
});
Expand Down

0 comments on commit a881450

Please sign in to comment.