Skip to content

Commit

Permalink
ITEM-386 Ajouter action "Restaurer"
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelQuetin committed Dec 5, 2024
1 parent 42c2d90 commit 056372f
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 53 deletions.
4 changes: 4 additions & 0 deletions src/service/ItemService.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ export class ItemService {
stopDemande(id) {
return this.client.patch('stopDemandeSupp/' + id);
}

restaurerDemande(id, typeDemande) {
return this.client.patch('restaurerDemande/' + typeDemande + '/' + id )
}
}

export default new ItemService()
39 changes: 24 additions & 15 deletions src/views/Exemplarisation/ExempTable.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<template>

<v-container fluid>
<v-chip :variant="isActiveDemandesDisplayed ? 'plain' : 'tonal'" style="margin-right: 10px"
@click="switchArchiveActiveDisplay(!isActiveDemandesDisplayed)">Demandes d'exemplarisation
<v-chip :variant="isArchiveDemandesDisplayed ? 'plain' : 'tonal'" style="margin-right: 10px"
@click="switchArchiveActiveDisplay(!isArchiveDemandesDisplayed)">Demandes d'exemplarisation
</v-chip>
<v-chip :variant="!isActiveDemandesDisplayed ? 'plain' : 'tonal'"
@click="switchArchiveActiveDisplay(!isActiveDemandesDisplayed)">Demandes d'exemplarisation archivées
<v-chip :variant="!isArchiveDemandesDisplayed ? 'plain' : 'tonal'"
@click="switchArchiveActiveDisplay(!isArchiveDemandesDisplayed)">Demandes d'exemplarisation archivées
</v-chip>
<v-chip variant="text">
<v-tooltip v-if="isAdmin" activator="parent" location="bottom">
<template v-slot:activator="{ props }">
<label>
<input type="checkbox" v-model="extendedAllILN" style="margin-right: 5px"
@change="loadItems('EXEMP', isActiveDemandesDisplayed)">
@change="loadItems('EXEMP')">
<span v-bind="props">Affichage étendu sur tous les ILN</span>
</label>
</template>
Expand Down Expand Up @@ -121,13 +121,13 @@
<!-- Colonne Action -->
<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>
</td>
</tr>
</template>
</v-data-table>
<dialog-suppression v-model="suppDialog" :demande="suppDemande"
@supp="loadItems('EXEMP', isActiveDemandesDisplayed)"></dialog-suppression>
@supp="loadItems('EXEMP')"></dialog-suppression>
</template>

<script setup>
Expand Down Expand Up @@ -288,11 +288,11 @@ const isDialogOpen = computed(() => {
});
//Actives or archives demands displayed
const isActiveDemandesDisplayed = ref(false);
const isArchiveDemandesDisplayed = ref(false);
//Data initialisation
onMounted(() => {
loadItems('EXEMP', isActiveDemandesDisplayed.value);
loadItems('EXEMP');
contentsDemandesFromServer.value = [...contentsDemandesFromServer.value];
itemService.getTypeExemp()
.then(response => {
Expand All @@ -304,7 +304,7 @@ onMounted(() => {
});
polling = setInterval(() => {
if (!isDialogOpen.value) {
loadItems('EXEMP', isActiveDemandesDisplayed.value)
loadItems('EXEMP')
.then(() => {
filterItems();
});
Expand All @@ -317,13 +317,13 @@ onBeforeUnmount(() => {
});
function switchArchiveActiveDisplay(value) {
isActiveDemandesDisplayed.value = value;
loadItems('EXEMP', isActiveDemandesDisplayed.value);
isArchiveDemandesDisplayed.value = value;
loadItems('EXEMP');
}
async function loadItems(type, archive) {
async function loadItems(type) {
try {
const response = await itemService.fetchDemandes(type, archive, extendedAllILN.value);
const response = await itemService.fetchDemandes(type, isArchiveDemandesDisplayed.value, extendedAllILN.value);
contentsDemandesFromServer.value = response.data;
contentsDemandesFrontFiltered.value = response.data.map((item) => ({
...item,
Expand Down Expand Up @@ -374,6 +374,15 @@ function supprimerDemande(item) {
suppDemande.value = item;
}
function restaurerDemande(item) {
itemService.restaurerDemande(item.id, "EXEMP").then(() => {
loadItems('EXEMP');
}).catch(error => {
console.error(error);
emit('backendError', error);
});
}
//Archivage d'une demande
async function archiverDemande(item) {
try {
Expand All @@ -394,7 +403,7 @@ function onRowClick(item) {
}
function saveComment() {
loadItems('EXEMP', isActiveDemandesDisplayed.value)
loadItems('EXEMP')
.then(() => {
filterItems();
});
Expand Down
39 changes: 24 additions & 15 deletions src/views/Modification/ModifTable.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<template>
<v-container fluid>
<!--:variant="isActiveDemandesDisplayed ? 'plain' : 'tonal'" -->
<v-chip :variant="isActiveDemandesDisplayed ? 'plain' : 'tonal'" style="margin-right: 10px"
@click="switchArchiveActiveDisplay(!isActiveDemandesDisplayed)">Demandes de modification
<v-chip :variant="isArchiveDemandesDisplayed ? 'plain' : 'tonal'" style="margin-right: 10px"
@click="switchArchiveActiveDisplay(!isArchiveDemandesDisplayed)">Demandes de modification
</v-chip>
<v-chip :variant="!isActiveDemandesDisplayed ? 'plain' : 'tonal'"
@click="switchArchiveActiveDisplay(!isActiveDemandesDisplayed)">Demandes de modification archivées
<v-chip :variant="!isArchiveDemandesDisplayed ? 'plain' : 'tonal'"
@click="switchArchiveActiveDisplay(!isArchiveDemandesDisplayed)">Demandes de modification archivées
</v-chip>
<v-chip variant="text">
<v-tooltip v-if="isAdmin" activator="parent" location="bottom">
<template v-slot:activator="{ props }">
<label>
<input type="checkbox" v-model="extendedAllILN" style="margin-right: 5px"
@change="loadItems('MODIF', isActiveDemandesDisplayed)">
@change="loadItems('MODIF')">
<span v-bind="props">Affichage étendu sur tous les ILN</span>
</label>
</template>
Expand Down Expand Up @@ -120,12 +119,13 @@
<!-- Colonne Action -->
<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>
</td>
</tr>
</template>
</v-data-table>
<dialog-suppression v-model="suppDialog" :demande="suppDemande"
@supp="loadItems('MODIF', isActiveDemandesDisplayed)"></dialog-suppression>
@supp="loadItems('MODIF')"></dialog-suppression>
</template>

<script setup>
Expand Down Expand Up @@ -286,11 +286,11 @@ const isDialogOpen = computed(() => {
});
//Actives or archives demands displayed
const isActiveDemandesDisplayed = ref(false);
const isArchiveDemandesDisplayed = ref(false);
//Data initialisation
onMounted(() => {
loadItems('MODIF', isActiveDemandesDisplayed.value);
loadItems('MODIF');
contentsDemandesFromServer.value = [...contentsDemandesFromServer.value];
itemService.getTypeTraitement()
.then(response => {
Expand All @@ -302,7 +302,7 @@ onMounted(() => {
});
polling = setInterval(() => {
if (!isDialogOpen.value) {
loadItems('MODIF', isActiveDemandesDisplayed.value)
loadItems('MODIF')
.then(() => {
filterItems();
});
Expand All @@ -315,13 +315,13 @@ onBeforeUnmount(() => {
});
function switchArchiveActiveDisplay(value) {
isActiveDemandesDisplayed.value = value;
loadItems('MODIF', isActiveDemandesDisplayed.value);
isArchiveDemandesDisplayed.value = value;
loadItems('MODIF');
}
async function loadItems(type, archive) {
async function loadItems(type) {
try {
const response = await itemService.fetchDemandes(type, archive, extendedAllILN.value);
const response = await itemService.fetchDemandes(type, isArchiveDemandesDisplayed.value, extendedAllILN.value);
contentsDemandesFromServer.value = response.data;
contentsDemandesFrontFiltered.value = response.data.map((item) => ({
...item,
Expand Down Expand Up @@ -383,6 +383,15 @@ function supprimerDemande(item) {
suppDemande.value = item;
}
function restaurerDemande(item) {
itemService.restaurerDemande(item.id, "MODIF").then(() => {
loadItems('MODIF');
}).catch(error => {
console.error(error);
emit('backendError', error);
});
}
//Archivage d'une demande
async function archiverDemande(item) {
try {
Expand All @@ -403,7 +412,7 @@ function onRowClick(item) {
}
function saveComment() {
loadItems('MODIF', isActiveDemandesDisplayed.value)
loadItems('MODIF')
.then(() => {
filterItems();
});
Expand Down
42 changes: 26 additions & 16 deletions src/views/Recouvrement/RecouvTable.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)">Demandes de recouvrement
<v-chip :variant="isArchiveDemandesDisplayed ? 'plain' : 'tonal'" style="margin-right: 10px"
@click="switchArchiveActiveDisplay(!isArchiveDemandesDisplayed)">Demandes de recouvrement
</v-chip>
<v-chip :variant="!isActiveDemandesDisplayed ? 'plain' : 'tonal'"
@click="switchArchiveActiveDisplay(!isActiveDemandesDisplayed)">Demandes de recouvrement archivées
<v-chip :variant="!isArchiveDemandesDisplayed ? 'plain' : 'tonal'"
@click="switchArchiveActiveDisplay(!isArchiveDemandesDisplayed)">Demandes de recouvrement archivées
</v-chip>
<v-chip variant="text">
<v-tooltip v-if="isAdmin" activator="parent" location="bottom">
<template v-slot:activator="{ props }">
<label>
<input type="checkbox" v-model="extendedAllILN" style="margin-right: 5px"
@change="loadItems('RECOUV', isActiveDemandesDisplayed)">
@change="loadItems('RECOUV')">
<span v-bind="props">Affichage étendu sur tous les ILN</span>
</label>
</template>
Expand Down Expand Up @@ -108,12 +108,13 @@
<!-- Colonne Action -->
<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>
</td>
</tr>
</template>
</v-data-table>
<dialog-suppression v-model="suppDialog" :demande="suppDemande"
@supp="loadItems('RECOUV', isActiveDemandesDisplayed)"></dialog-suppression>
@supp="loadItems('RECOUV')"></dialog-suppression>
</template>

<script setup>
Expand Down Expand Up @@ -260,15 +261,15 @@ const isDialogOpen = computed(() => {
});
//Actives or archives demands displayed
const isActiveDemandesDisplayed = ref(false);
const isArchiveDemandesDisplayed = ref(false);
//Data initialisation
onMounted(() => {
loadItems('RECOUV', isActiveDemandesDisplayed.value);
loadItems('RECOUV');
contentsDemandesFromServer.value = [...contentsDemandesFromServer.value];
polling = setInterval(() => {
if (!isDialogOpen.value) {
loadItems('RECOUV', isActiveDemandesDisplayed.value)
loadItems('RECOUV')
.then(() => {
filterItems();
});
Expand All @@ -281,13 +282,13 @@ onBeforeUnmount(() => {
});
function switchArchiveActiveDisplay(value) {
isActiveDemandesDisplayed.value = value;
loadItems('RECOUV', isActiveDemandesDisplayed.value);
isArchiveDemandesDisplayed.value = value;
loadItems('RECOUV');
}
async function loadItems(type, archive) {
async function loadItems(type) {
try {
const response = await itemService.fetchDemandes(type, archive, extendedAllILN.value);
const response = await itemService.fetchDemandes(type, isArchiveDemandesDisplayed.value, extendedAllILN.value);
contentsDemandesFromServer.value = response.data;
contentsDemandesFrontFiltered.value = response.data.map((item) => ({
...item,
Expand Down Expand Up @@ -337,12 +338,21 @@ function supprimerDemande(item) {
suppDemande.value = item;
}
function restaurerDemande(item) {
itemService.restaurerDemande(item.id, "RECOUV").then(() => {
loadItems('RECOUV')
}).catch(error => {
console.error(error);
emit('backendError', error);
});
}
//Archivage d'une demande
async function archiverDemande(item) {
try {
await itemService.archiverDemande('EXEMP', item.id);
await itemService.archiverDemande('RECOUV', item.id);
// Mettre à jour les données après l'archivage réussi
await loadItems('EXEMP');
await loadItems('RECOUV');
emit('backendSuccess');
} catch (error) {
console.error(error);
Expand All @@ -360,7 +370,7 @@ function saveAction() {
}
function saveComment() {
loadItems('RECOUV', isActiveDemandesDisplayed.value)
loadItems('RECOUV')
.then(() => {
filterItems();
});
Expand Down
Loading

0 comments on commit 056372f

Please sign in to comment.