Skip to content

Commit

Permalink
Merge pull request #119 from abes-esr/develop
Browse files Browse the repository at this point in the history
merge dev to test
  • Loading branch information
pierre-maraval authored Sep 17, 2024
2 parents c470138 + c9f5329 commit bd5b18b
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 56 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Item",
"version": "3.0.0",
"version": "3.0.1-SNAPSHOT",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
47 changes: 26 additions & 21 deletions src/components/Email.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
<span v-else>Modifier les informations de votre compte</span>
</v-card-title>
<v-card-text>
<v-form ref="form" class="pt-5">
<v-form
ref="form"
class="pt-5"
@submit.prevent="validate()">
<span>
Votre adresse mail est obligatoire pour utiliser l'application. Pour ajouter plusieurs adresses mail, séparez-les par des points virgules ;
</span>
Expand All @@ -17,7 +20,7 @@
id="email"
v-model="emailModel"
:rules="rules"
@keyup.enter="validate()">
>
</v-text-field>
</v-form>
<v-alert
Expand Down Expand Up @@ -80,25 +83,27 @@ onMounted(() => {
emailModel.value = props.email;
});
function validate() {
if(!props.email){
itemService.creerEmail(props.userId, emailModel.value)
.then(result => {
emits('validate', result.data.email);
})
.catch(err => {
messageError.value = err.response.data.message;
throw err;
});
} else {
itemService.modifierEmail(props.userId, emailModel.value)
.then(result => {
emits('validate', result.data.email);
})
.catch(err => {
messageError.value = err.response.data.message;
throw err;
});
async function validate() {
if(!isDisabled.value) {
if (!props.email) {
itemService.creerEmail(props.userId, emailModel.value)
.then(result => {
emits('validate', result.data.email);
})
.catch(err => {
messageError.value = err.response.data.message;
throw err;
});
} else {
itemService.modifierEmail(props.userId, emailModel.value)
.then(result => {
emits('validate', result.data.email);
})
.catch(err => {
messageError.value = err.response.data.message;
throw err;
});
}
}
}
</script>
4 changes: 2 additions & 2 deletions src/components/Simulation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import RecapDemande from '@/components/RecapDemande.vue';
import NavigateNotice from '@/components/NavigateNotice.vue';
import { onMounted, ref } from 'vue';
import demandesService from '@/service/ItemService';
import itemService from '@/service/ItemService';
const props = defineProps({
demande: {
Expand Down Expand Up @@ -103,7 +103,7 @@ onMounted(() => {
function refresh() {
isLoading.value = true;
alertMessageError.value = null;
demandesService.simulerLigne(props.demande.id, nbNotice.value.nbNoticeEnCours, props.demande.type)
itemService.simulerLigne(props.demande.id, nbNotice.value.nbNoticeEnCours, props.demande.type)
.then(response => {
numeroPPNNotice.value = response.data[0];
noticeAvant.value = response.data[1];
Expand Down
81 changes: 49 additions & 32 deletions src/views/Suppression/SuppSteps.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<v-container :class="(currentStep === 4) ? '' : 'fill-height'" fluid>
<v-container :class="(currentStep === 3) ? '' : 'fill-height'" fluid>
<v-row align="center" justify="center">
<v-col :md="(currentStep === 4) ? '' : '7'">
<v-col :md="(currentStep === 3) ? '' : '7'">
<v-stepper v-model="currentStep" @update:model-value="changeEtape()" alt-labels>
<v-stepper-header>
<v-stepper-item
Expand Down Expand Up @@ -33,6 +33,12 @@
subtitle="du fichier"
>
</v-stepper-item>
<v-divider></v-divider>
<v-stepper-item
icon="mdi-numeric-4"
title="Simulation"
>
</v-stepper-item>
</v-stepper-header>

<v-stepper-window>
Expand Down Expand Up @@ -105,44 +111,40 @@
@click="uploadFileFinal()"
:loading="isLoading"
>
Lancer le traitement en production
Lancer le traitement en simulation
</v-btn>
</v-container>
</v-stepper-window-item>
<v-stepper-window-item>
<simulation :demande="demande" label-before="Exemplaire(s) existant(s)" label-after="Exemplaire(s) restant(s)" @deleted="deleteDemande()"></simulation>
<v-container class="d-flex justify-space-between">
<v-btn @click="prev">
précédent
</v-btn>
<v-btn large @click="dialog = true"
aria-label="Lancer le traitement en production">Lancer le traitement en production
</v-btn>
</v-container>
</v-stepper-window-item>
</v-stepper-window>
</v-stepper>
<v-dialog
v-model="dialog"
width="500"
>
<v-card>
<v-card-title class="headline" primary-title>Traitement validé</v-card-title>
<v-card-text>Votre demande est en cours de traitement.<br/>Un mail vous sera envoyé quand celui-ci sera
terminé.
<br>Vous pouvez retrouver l'ensemble de vos demandes sur votre tableau de bord ITEM. Rubrique "Gérer mes
suppressions".
</v-card-text>
<v-divider></v-divider>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary" @click="router.push('suppression-tableau')" aria-label="OK">OK</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</v-col>
</v-row>
</v-container>
<dialog-lancer-traitement v-model="dialog" :is-loading="isLoading" rubrique="Gérer mes suppressions" route="/suppression-tableau" @launch="launchDemande()"></dialog-lancer-traitement>
<dialog-suppression v-model="suppDialog" :demande="demande" return-to-accueil></dialog-suppression>
</template>

<script setup>
import { onMounted, ref } from 'vue';
import TypeFile from '@/components/Supp/TypeFile.vue';
import SelectFile from '@/components/SelectFile.vue';
import demandesService from '@/service/ItemService';
import itemService from '@/service/ItemService';
import DownloadFile from "@/components/Modif/DownloadFile.vue";
import router from '@/router'
import Rcr from '@/components/Rcr.vue';
import Simulation from "@/components/Simulation.vue";
import DialogLancerTraitement from '@/components/Dialog/DialogLancerTraitement.vue';
import DialogSuppression from '@/components/Dialog/DialogSuppression.vue';
const currentStep = ref(0);
Expand All @@ -167,7 +169,7 @@ const suppDialog = ref(false);
onMounted(()=>{
if (props.id) {
demandesService.getDemande(props.id, "SUPP")
itemService.getDemande(props.id, "SUPP")
.then(response => {
demande.value = response.data;
switch (demande.value.etatDemande) {
Expand All @@ -188,6 +190,11 @@ onMounted(()=>{
typeFileSelected.value = demande.value.typeSuppression;
currentStep.value = 2;
break;
case 'En simulation':
rcrSelected.value = demande.value.rcr;
typeFileSelected.value = demande.value.typeSuppression;
currentStep.value = 3;
break;
}
}).catch(() => {
router.replace("/suppression");
Expand All @@ -201,7 +208,7 @@ function createDemande() {
next();
} else if (demande.value) {
isLoading.value = true;
demandesService.modifierRcrDemande(demande.value.id, rcrSelected.value, 'SUPP')
itemService.modifierRcrDemande(demande.value.id, rcrSelected.value, 'SUPP')
.then(response => {
demande.value = response.data;
next();
Expand All @@ -212,7 +219,7 @@ function createDemande() {
});
} else {
isLoading.value = true;
demandesService.creerDemande(rcrSelected.value, 'SUPP')
itemService.creerDemande(rcrSelected.value, 'SUPP')
.then(response => {
demande.value = response.data;
next();
Expand All @@ -228,11 +235,11 @@ function uploadFile() {
alertMessage.value = '';
alertType.value = 'success';
isLoading.value = true;
demandesService.uploadDemande(demande.value.id, fileSelected.value, 'SUPP')
itemService.uploadDemande(demande.value.id, fileSelected.value, 'SUPP')
.then(() => {
alertMessage.value = "Fichier envoyé";
isLoaded.value = true;
demandesService.getFile(demande.value.id, 'SUPP','fichier_prepare', '.csv')
itemService.getFile(demande.value.id, 'SUPP','fichier_prepare', '.csv')
.then(response => {
let blob = new Blob([response.data], {type: 'application/csv'});
fileLink.value = window.URL.createObjectURL(blob);
Expand All @@ -248,19 +255,19 @@ function uploadFile() {
});
}
function setTypeSelected(){
demandesService.modifierTypeFileDemande(demande.value.id, typeFileSelected.value)
itemService.modifierTypeFileDemande(demande.value.id, typeFileSelected.value)
}
function changeEtape() {
if (((currentStep.value + 1) === 1) || ((currentStep.value + 1) === 2 && !typeFileSelected.value)) {
demandesService.choixEtape(demande.value.id, 1, 'SUPP')
itemService.choixEtape(demande.value.id, 1, 'SUPP')
.then(response => {
demande.value = response.data;
});
typeFileSelected.value = null;
}
if ((currentStep.value + 1) === 2 && typeFileSelected.value) { //Changement d'etat pour le chargement du fichier car le back est perdu sinon
demandesService.choixEtape(demande.value.id, 2, 'SUPP')
itemService.choixEtape(demande.value.id, 2, 'SUPP')
.then(response => {
demande.value = response.data;
});
Expand All @@ -271,10 +278,10 @@ function uploadFileFinal() {
alertMessage.value = '';
alertType.value = 'success';
isLoading.value = true;
demandesService.uploadDemande(demande.value.id, fileFinalSelected.value, 'SUPP')
itemService.uploadDemande(demande.value.id, fileFinalSelected.value, 'SUPP')
.then(() => {
alertMessage.value = "Fichier envoyé";
dialog.value = true;
next();
})
.catch(err => {
alertMessage.value = err.response.data.message;
Expand Down Expand Up @@ -313,6 +320,16 @@ function raz(){
isDownloaded.value = false;
}
function launchDemande(){
isLoading.value = true;
itemService.lancerDemande(demande.value.id,'SUPP')
.then(response => {
demande.value = response.data;
}).finally(() => {
isLoading.value = false;
})
}
function deleteDemande() {
suppDialog.value = true;
}
Expand Down

0 comments on commit bd5b18b

Please sign in to comment.