Commit 0bd40c59 authored by Jean Rabreau's avatar Jean Rabreau
Browse files

internal user profile update on demand #174

parent de2a2e5e
......@@ -87,7 +87,49 @@
</fieldset>
</fieldset>
<v-row>
<v-spacer />
<v-dialog v-model="wantRefresh">
<template v-slot:activator="{ attrs }">
<v-col>
<v-btn
tile
elevation="0"
v-bind="attrs"
@click="wantRefresh = true"
>
<v-icon left>
mdi-update
</v-icon>
{{ $t('profile.update.wanted.button') }}
</v-btn>
</v-col>
</template>
<v-card>
<v-card-title>
{{ $t('profile.update.wanted.deco') }}
</v-card-title>
<v-card-text>
{{ $t('profile.update.wanted.next') }}
</v-card-text>
<v-card-actions>
<v-btn
tile
elevation="0"
color="secondary"
@click="wantRefresh = false"
>
{{ $t('btn.cancel') }}
</v-btn>
<v-btn
tile
elevation="0"
color="primary"
@click="onRefresh"
>
{{ $t('btn.validate') }}
</v-btn>
</v-card-actions>
</v-card>
</v-dialog> <v-spacer />
<v-col class="flex-grow-0">
<v-btn
tile
......@@ -114,7 +156,8 @@
</template>
<script>
import RulesMixin from '@/mixins/RulesMixin';
import {mapActions, mapGetters} from 'vuex'
import RulesMixin from '@/mixins/RulesMixin'
export default {
name: 'ProfileFormPersonalInfo',
......@@ -137,9 +180,17 @@ export default {
newPersonalInfo: {
...this.personalInfo
},
wantRefresh: false
}
},
computed: {
...mapGetters('contrib', ['settings'])
},
methods: {
...mapActions('contrib', ['refreshProfile']),
onRefresh() {
this.refreshProfile()
},
onSubmit() {
if (this.$refs.personalInfoForm.validate()) {
this.$emit('update:personalInfo', this.newPersonalInfo);
......
......@@ -525,7 +525,11 @@ export const en_US = {
contact: "Contact",
update: {
success: "Your profile has been updated",
failure: "Your profile has not been updated"
failure: "Your profile has not been updated",
wanted: {
button: "Update my profile",
next: "My profile will be updated on next connexion"
}
},
changeMail: {
title : "Email change",
......
......@@ -539,7 +539,12 @@ export const fr_FR = {
contact: 'Contact',
update: {
success: "Votre profil à bien été mis à jour",
failure: "Votre profil n'a pas pu être mis à jour"
failure: "Votre profil n'a pas pu être mis à jour",
wanted: {
button: "Mettre à jour",
deco: "Vous allez être déconnecté",
next: "Vos informations seront mises à jour à la prochaine connexion, cette opération nécessite de se reconnecter."
}
},
changeMail: {
title : "Changement d'email",
......
......@@ -100,6 +100,7 @@ const Contrib = {
info: state.profile.info,
email: state.profile.email
}),
settings: state => state.profile.settings,
},
mutations: {
SET_PROFILE(state, userProfile) {
......@@ -245,6 +246,20 @@ const Contrib = {
authority.logOut()
commit('LOGIN', false)
},
refreshProfile({dispatch}) {
dispatch('updateProfile', {
settings: {
...this.settings,
refreshInfo: true
}
}).then(status => {
if (status) {
dispatch('logOut').then(() => document.location.reload())
}
})
},
/**
*
* @param context
......@@ -255,7 +270,7 @@ const Contrib = {
return authority.patch(`users/profile/`, profile)
.then(response => {
commit('SET_PROFILE', response.data)
dispatch(
return dispatch(
'dialog/displayInfo',
i18n.t('profile.update.success'),
{root: true}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment