Skip to content

Commit

Permalink
Merge pull request #744 from rufener/bugfix
Browse files Browse the repository at this point in the history
Bugfix
  • Loading branch information
rufener authored Aug 28, 2023
2 parents a837320 + accf2f6 commit c7779ab
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion front/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ VUE_APP_API_URL="{API_URL}"

PUBLIC_PATH = "{PUBLIC_PATH}"
VUE_APP_STATUS = "development"
VUE_APP_VERSION = "1.10.3"
VUE_APP_VERSION = "1.10.4"


#==================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ <h3>Répartition des émoluments dans les factures</h3>
<td class="tg-0lax position">{{ form_detail.travauxBureau28.nom }}</td>
<td class="tg-0lax alignCenter unite">{{ form_detail.travauxBureau28.unite }}</td>
<td class="tg-0lax alignRight prix_unitaire">{{ form_detail.travauxBureau28.prix_unitaire }} CHF</td>
<td class="tg-0lax nombre"><md-field class="nbField"><md-input :disabled="disabled || !form_general.utilise" v-model="form_detail.travauxBureau28.nombre" class="nbInput" v-bind:class="{ highlightEmolument: Number(form_detail.travauxBureau28.nombre)>0, hideNulls: Number(form_detail.travauxBureau28.nombre)==0 }" @keyup="updateMontants()" @focus="$event.target.select()" onkeypress="return /[0-9]|[.]/g.test(event.key)"></md-input></md-field></td>
<td class="tg-0lax nombre"><md-field class="nbField"><md-input :disabled="disabled" v-model="form_detail.travauxBureau28.nombre" class="nbInput" v-bind:class="{ highlightEmolument: Number(form_detail.travauxBureau28.nombre)>0, hideNulls: Number(form_detail.travauxBureau28.nombre)==0 }" @keyup="updateMontants()" @focus="$event.target.select()" onkeypress="return /[0-9]|[.]/g.test(event.key)"></md-input></md-field></td>
<td class="tg-0lax montant alignRight"><span v-if="Number(form_detail.travauxBureau28.montant>0)">{{ form_detail.travauxBureau28.montant }} CHF</span></td>
<template v-for="i in form_general.nb_batiments">
<td class="tg-0lax nombre batiment-separator notEditable"></td>
Expand Down Expand Up @@ -1308,7 +1308,7 @@ <h3>Répartition des émoluments dans les factures</h3>
<td class="tg-0lax position">{{ form_detail.travauxBureau37.nom }}</td>
<td class="tg-0lax alignCenter unite">{{ form_detail.travauxBureau37.unite }}</td>
<td class="tg-0lax alignRight prix_unitaire">{{ form_detail.travauxBureau37.prix_unitaire }} CHF</td>
<td class="tg-0lax nombre"><md-field class="nbField"><md-input :disabled="disabled || !form_general.utilise" v-model="form_detail.travauxBureau37.nombre" class="nbInput" v-bind:class="{ highlightEmolument: Number(form_detail.travauxBureau37.nombre)>0, hideNulls: Number(form_detail.travauxBureau37.nombre)==0 }" @keyup="updateMontants()" @focus="$event.target.select()" onkeypress="return /[0-9]|[.]/g.test(event.key)"></md-input></md-field></td>
<td class="tg-0lax nombre"><md-field class="nbField"><md-input :disabled="disabled" v-model="form_detail.travauxBureau37.nombre" class="nbInput" v-bind:class="{ highlightEmolument: Number(form_detail.travauxBureau37.nombre)>0, hideNulls: Number(form_detail.travauxBureau37.nombre)==0 }" @keyup="updateMontants()" @focus="$event.target.select()" onkeypress="return /[0-9]|[.]/g.test(event.key)"></md-input></md-field></td>
<td class="tg-0lax montant alignRight"><span v-if="Number(form_detail.travauxBureau37.montant>0)">{{ form_detail.travauxBureau37.montant }} CHF</span></td>
<template v-for="i in form_general.nb_batiments">
<td class="tg-0lax nombre batiment-separator notEditable"></td>
Expand Down
33 changes: 18 additions & 15 deletions front/src/components/Login/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ export default {
headers: {"Accept": "application/json"}
}
)
.then(response =>{
.then(response => {
if(response && response.data && response.data.id){
this.processLogin(response.data);
if (process.env.VUE_APP_SERVICE_MO === response.data.service) {
this.$router.push(this.$route.query.redirect || { name: "Cockpit"});
} else {
this.$router.push(this.$route.query.redirect || { name: "Preavis"});
}
this.processLogin(response.data).then(() => {
if (process.env.VUE_APP_SERVICE_MO === response.data.service) {
this.$router.push(this.$route.query.redirect || { name: "Cockpit"});
} else {
this.$router.push(this.$route.query.redirect || { name: "Preavis"});
}
});
} else {
this.showProgess = false;
this.$refs.userpass.value = "";
Expand Down Expand Up @@ -78,20 +78,23 @@ export default {
/**
* Process login
*/
processLogin (data) {
localStorage.setItem('infolica_user', JSON.stringify(data));
setCurrentUserFunctions().then(() => {
this.$root.$emit("notesMaj_hasAdminRights");
async processLogin (data) {
return new Promise((resolve) => {
localStorage.setItem('infolica_user', JSON.stringify(data));
setCurrentUserFunctions().then(() => {
this.$root.$emit("notesMaj_hasAdminRights");
});
this.$root.$emit('infolica_user_logged_in', data);
localStorage.removeItem('infolica_cockpit_searchParams');
resolve();
});
this.$root.$emit('infolica_user_logged_in', data);
localStorage.removeItem('infolica_cockpit_searchParams');
},
/**
* Process logout
*/
processLogout () {
localStorage.setItem('infolica_user', null);
localStorage.removeItem('infolica_user');
this.$root.$emit('notesMaj_set_default_params');
this.$root.$emit('infolica_user_logged_out');
Expand Down
2 changes: 1 addition & 1 deletion front/src/components/Notifications/Notifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default {
this.msg = msg;
this.isError = true;
this.showSnackbar = true;
this.duration = 10000;
this.duration = 7500;
});
//Show Alert Dialog
Expand Down
10 changes: 8 additions & 2 deletions front/src/services/exceptionsHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ export const handleException = function (error, component) {
}
//Not authorized
else if(code === 403){
let a = component.$router.push({name: "Login", query: { redirect: component.$router.currentRoute.path }});
a.then(() => { component.$root.$emit("ShowError", "Veuillez vous connecter pour continuer") });
const currentRoute = component.$router.currentRoute;
if (currentRoute.name !== 'Login') {
const a = component.$router.push({name: "Login", query: { redirect: currentRoute.path }});
a.then(() => {
localStorage.removeItem('infolica_user');
component.$root.$emit("ShowError", "Veuillez vous connecter pour continuer") ;
});
}
}
//Custom error
else if(error && error.msg){
Expand Down
18 changes: 5 additions & 13 deletions front/src/services/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@ const moment = require('moment')
* Check if the user is logged in
*/
export const checkLogged = function () {
var session_user = JSON.parse(localStorage.getItem('infolica_user')) || null;

//Set current user functions
if(session_user){
setCurrentUserFunctions();
} else {
alert("Veuillez vous connecter pour continuer");
}

let session_user = JSON.parse(localStorage.getItem('infolica_user')) || null;
return session_user !== null;
};

Expand All @@ -22,7 +14,7 @@ export const checkLogged = function () {
* Check permission
*/
export const checkPermission = function (fonction) {
var session_user = JSON.parse(localStorage.getItem('infolica_user')) || null;
let session_user = JSON.parse(localStorage.getItem('infolica_user')) || null;

if(session_user && session_user.fonctions && session_user.fonctions.indexOf(fonction) > -1){
return true;
Expand All @@ -36,7 +28,7 @@ export const checkPermission = function (fonction) {
* Get current user role id
*/
export const getCurrentUserRoleId = function () {
var session_user = JSON.parse(localStorage.getItem('infolica_user')) || null;
let session_user = JSON.parse(localStorage.getItem('infolica_user')) || null;
return (session_user && session_user.role_id) ? session_user.role_id : null;
};

Expand All @@ -52,8 +44,8 @@ export const setCurrentUserFunctions = async function () {
})
.then(response =>{
if(response && response.data){
var session_user = JSON.parse(localStorage.getItem('infolica_user')) || null;
let session_user = JSON.parse(localStorage.getItem('infolica_user')) || null;

if(session_user){
session_user.fonctions = response.data.fonctions;
session_user.role_id = response.data.role_id;
Expand Down

0 comments on commit c7779ab

Please sign in to comment.