Newer
Older
<template>
<div>
<b-button
id="back-button"
variant="primary"
@click="goBackToNext"
>
<b-icon-arrow-bar-left/>
</b-button>
<div class="signup-container">
</div>
<div class="signup-form">
<h4 class="title">
{{ $t('profile.title') }}
<span class="sub-title">{{ $t('profile.subtitle') }}</span>
<b-overlay
:show="loadingUserInformation"
rounded="lg"
:style="'padding: 5px;'"
variant="white"
>
<form>
<hr class="divider">
<div class="row g-2 align-items-center">
<div class="col-3">
<label class="col-form-label">{{ $t('words.username') }}</label>
</div>
<div class="col">
<div class="input-group flex-nowrap">
v-model="formUser.username"
type="text"
class="form-control"
disabled
>
</div>
</div>
</div>
<div class="row g-2 align-items-center">
<div class="col-3">
<label class="col-form-label required">{{ $t('words.firstname') }}</label>
</div>
<div class="col">
<ValidationProvider ref="first_name" rules="required" v-slot="{ classes, errors }">
<div class="control" :class="classes">
v-model="formUser.first_name"
type="text"
class="form-control"
>
<span class="form-errors">{{ errors[0] }}</span>
</div>
</ValidationProvider>
</div>
</div>
<div class="row g-2 align-items-center">
<div class="col-3">
<label class="col-form-label required">{{ $t('words.lastname') }}</label>
</div>
<div class="col">
<ValidationProvider ref="last_name" rules="required" v-slot="{ classes, errors }">
<div class="control" :class="classes">
v-model="formUser.last_name"
type="text"
class="form-control"
>
<span class="form-errors">{{ errors[0] }}</span>
</div>
</ValidationProvider>
</div>
</div>
<div class="row g-2 align-items-center">
<div class="col-3">
<label class="col-form-label">
</label>
</div>
<div class="col">
<ValidationProvider ref="email" rules="required|email" v-slot="{ classes, errors }">
<div class="control" :class="classes">
v-model="formUser.email"
type="mail"
class="form-control"
disabled
>
<span class="form-errors">{{ errors[0] }}</span>
</div>
</ValidationProvider>
</div>
</div>
<div class="row g-2 align-items-center">
<div class="col-3">
<label class="col-form-label">{{ $t('words.phone') }}</label>
</div>
<div class="col">
<ValidationProvider ref="phone_number" v-slot="{ classes, errors }">
<div class="control" :class="classes">
v-model="formUser.phone_number"
type="text"
class="form-control"
placeholder=""
>
<span class="form-errors">{{ errors[0] }}</span>
</div>
</ValidationProvider>
</div>
</div>
<div class="row g-2 align-items-center">
<div class="col-3">
<label class="col-form-label">
{{ $t('profile.form.personalDetails.reason') }}
</label>
<textarea data-test="userProfile-comments"
v-model="formUser.comments"
class="form-control"
/>
</div>
</div>
<div class="row g-2 align-items-center" style="margin-bottom: 0.5em;">
<div class="col-3">
<label
class="col-form-label"
style="font-size: 0.87em;"
>
{{ $t('profile.form.personalDetails.organisation.label') }}
</label>
</div>
<div v-if="userData" class="col">
<div v-if="userData.usergroup_roles.length === 0">
{{ $t('profile.form.personalDetails.organisation.noOrganisation') }}
</div>
<b-list-group
v-else
>
<b-list-group-item
v-for="usergroup of userData.usergroup_roles"

Florent Lavelle
committed
:key="usergroup.usergroup.id"

Florent Lavelle
committed
<b>{{ usergroup.usergroup.display_name }}</b>

Florent Lavelle
committed
<b>{{ organisationsRoles.find(el => el.choice === usergroup.role).label }}</b>
</b-list-group-item>
</b-list-group>
</div>
</div>
<div class="row g-2 align-items-center">
<div class="col-3">
</div>

Florent Lavelle
committed
<div v-if="userData && $config.client.mail" class="col">
<div
style="margin: 0 0.5em 0.5em 0.1em; font-size: 0.9em; font-style: italic;"
>

Florent Lavelle
committed
{{ $t('profile.form.personalDetails.organisation.help') }}
<a :href="`mailto:${$config.client.mail}`">
{{ $config.client.mail }}
</a>.
</div>
</div>
</div>
</form>
<div class="form-footer">
<b-button
:disabled="(!formUser.first_name || !formUser.last_name || !formUser.email)"
data-test="userProfile-submitUserInformations"
@click.prevent="handleSubmit(submitUserInformations)"
variant="primary"
>
</b-button>
</div>
</b-overlay>
</ValidationObserver>
<ValidationObserver v-slot="{ handleSubmit }">
<b-overlay
:show="loadingUserEmail"
rounded="lg"
variant="white"
:style="'padding: 5px;'"
>
<form>
<hr class="divider">
<div class="row g-2 align-items-center">
<div class="col-3" style="padding-right: 0;">
<label
class="col-form-label required"
style="font-size: 0.9em;"
>
{{ $t('profile.form.emailChange.label') }}
</label>
</div>
<div class="col">
<ValidationProvider ref="email" rules="email" v-slot="{ classes, errors }">
<div class="control" :class="classes">
v-model="formEmail.new_email"
type="mail"
class="form-control"
>
<span class="form-errors">{{ errors[0] }}</span>
</div>
</ValidationProvider>
</div>
</div>
<div class="row g-2 align-items-center">
<div class="col-3">
</div>
<div class="col">
<div
style="margin: 0 0.5em 0.5em 0.5em; font-size: 0.8em; font-style: italic;"
>
</div>
</div>
</div>
</form>
<div class="form-footer">
<b-button
:disabled="!formEmail.new_email"
:pressed="btnPressed"
@click.prevent="handleSubmit(submitNewEmail)"
variant="primary"
>
</b-button>
</div>
</b-overlay>
</ValidationObserver>
<ValidationObserver v-slot="{ handleSubmit }">
<b-overlay
:show="loadingUserPassword"
rounded="lg"
variant="white"
:style="'padding: 5px;'"
>
<form>
<hr class="divider">
<div class="row g-2 align-items-center">
<div class="col-3" style="padding-right: 0;">
<label class="col-form-label required" style="font-size: 0.9em;">
{{ $t('profile.form.passwordChange.oldLabel') }}
</label>
</div>
<div class="col">
<ValidationProvider ref="password" rules="required" v-slot="{ classes, errors }">
<div class="control" :class="classes">
<div class="input-group flex-nowrap">
v-model="formPassword.password"
class="form-control"
:type="showPassword ? 'text' : 'password'"
:placeholder="$t('profile.form.passwordChange.oldLabel')"
<span class="input-group-text">
<b-icon data-test="userProfile-toggleShowPassword"
:icon="showPassword?'eye-slash-fill':'eye-fill'"
@click="showPassword = !showPassword"
/>
</span>
</div>
<span class="form-errors">{{ errors[0] }}</span>
</div>
</ValidationProvider>
</div>
</div>
<div class="row g-2 align-items-center">
<div class="col-3" style="padding-right: 0;">
<label
class="col-form-label required"
style="font-size: 0.9em;">{{ $t('profile.form.passwordChange.newLabel') }}</label>
</div>
<div class="col">
<ValidationProvider ref="newPassword1" v-slot="{ classes, errors }" vid="confirmation">
<div class="control" :class="classes">
<div class="input-group flex-nowrap">
<input data-test="userProfile-newPassword1"
v-model="formPassword.newPassword1"
:type="showNewPassword2 ? 'text' : 'password'"
class="form-control"
:placeholder="$t('profile.form.passwordChange.newPlaceholder')"
<span class="input-group-text">
<b-icon data-test="userProfile-toggleShowNewPassword"
:icon="showNewPassword2?'eye-slash-fill':'eye-fill'"
@click="showNewPassword2 = !showNewPassword2"
/>
</span>
</div>
<span class="form-errors">{{ errors[0] }}</span>
</div>
</ValidationProvider>
</div>
</div>
<div class="row g-2 align-items-center">
<div class="col-3" style="padding-right: 0;">
<label
class="col-form-label"
style="font-size: 0.9em;"></label>
</div>
<div class="col">
<ValidationProvider ref="newPassword2" rules="confirmed:confirmation" v-slot="{ classes, errors }">
<div class="control" :class="classes">
<div class="input-group flex-nowrap">
<input data-test="userProfile-newPassword2"
v-model="formPassword.newPassword2"
class="form-control"
:type="showNewPassword2 ? 'text' : 'password'"
:placeholder="$t('profile.form.passwordChange.confirmPlaceholder')"
<span class="input-group-text">
<b-icon data-test="userProfile-toggleShowNewPassword2"
:icon="showNewPassword2?'eye-slash-fill':'eye-fill'"
@click="showNewPassword2 = !showNewPassword2"
/>
</span>
</div>
<span class="form-errors">{{ errors[0] }}</span>
</div>
</ValidationProvider>
</div>
</div>
<div class="row g-2 align-items-center">
<div class="col-3">
</div>
<div class="col">
<div class="infos">
<ul>
<li>{{ $t('profile.form.passwordChange.passwordHelp')[0] }}</li>
<li>{{ $t('profile.form.passwordChange.passwordHelp')[1] }}</li>
<li>{{ $t('profile.form.passwordChange.passwordHelp')[2] }}</li>
<li>{{ $t('profile.form.passwordChange.passwordHelp')[3] }}</li>
</ul>
</div>
</div>
</div>
</form>
<div class="form-footer">
<b-button
:disabled="(!formPassword.password || !formPassword.newPassword1 || !formPassword.newPassword2)"
:pressed="btnPressed"
data-test="userProfile-submitNewPassword"
@click.prevent="handleSubmit(submitNewPassword)"
variant="primary"
>
</b-button>
</div>
</b-overlay>
</ValidationObserver>
</div>
</div>
<small class="footer">
<p>
{{ $t('footer') }} <a href="https://www.neogeo.fr/" target="_blank" rel="noopener">Neogeo-Technologies</a>
</p>
</small>
</div>
</template>
<script>
import { mapState, mapMutations, mapActions } from 'vuex';
import Swal from "sweetalert2";
import "sweetalert2/dist/sweetalert2.min.css";
import {
ValidationObserver,
ValidationProvider,
extend,
configure,
} from 'vee-validate';
import { required, email, confirmed } from 'vee-validate/dist/rules';
extend('required', {
...required,
});
extend('email', {
...email,
});
extend('confirmed', {
...confirmed,
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
});
configure({
classes: {
valid: 'is-valid',
invalid: 'is-invalid',
},
});
export default {
name: 'UserProfile',
components: {
ValidationObserver,
ValidationProvider,
},
data() {
return {
loadingUserInformation: false,
loadingUserPassword: false,
loadingUserEmail: false,
formUser: {
first_name: null,
last_name: null,
email: null,
phone_number: null,
comments: null,
username: null
},
formEmail: {
new_email: null
},
formPassword: {
password: null,
newPassword1: null,
newPassword2: null
},
isOrganisationSelected: false,
organisation: null,
btnPressed: false,
showPassword: false,
showNewPassword2: false,
};
},
computed: {
...mapState('user', [
'userData',
'userError',
'success'
]),
...mapState('organisations', ['organisationsRoles']),
...mapState('sign-in', [
'next'
]),
logoPath() {
return require(process.env.VUE_APP_LOGO);
}
watch: {
'$i18n.locale': function(newValue, oldValue) {
if (newValue !== oldValue) {
this.$refs.form.validate();
}
},
userError(newValue) {
if (newValue) {
for (const [key, value] of Object.entries(newValue)) {
this.$refs[key].applyResult({
errors: value,
valid: false,
failedRules: {}
});
}
}
}
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
created() {
this.SET_NEXT(this.$route.query.next || process.env.VUE_APP_NEXT_DEFAULT);
if (!this.userData) {
this.loadingUserInformation = true;
this.GET_USER_DETAIL()
.then(() => {
this.formUser = {
...this.formUser,
...this.userData
};
this.loadingUserInformation = false;
});
}
if (this.organisationsRoles.length === 0) {
this.GET_ORGANISATIONS_ROLES();
}
},
methods: {
...mapMutations('sign-in', [
'SET_NEXT'
]),
...mapActions('user', [
'GET_USER_DETAIL',
'UPDATE_USER_DETAIL'
]),
...mapActions('organisations', [
'GET_ORGANISATIONS_ROLES'
]),
goBackToNext() {
if (
this.$config.authorizedRedirections.some(reg => {
return reg.test(decodeURIComponent(this.next))
})
) {
this.$router.push(this.$route.path);
window.location.pathname = this.next;
} else {
this.$router.push({ name: 'NotFound' });
}
},
submitUserInformations() {
this.loadingUserInformation = true
this.UPDATE_USER_DETAIL(this.formUser)
.then(() => {
this.GET_USER_DETAIL()
.then(() => {
this.formUser = {
...this.formUser,
...this.userData
};
this.loadingUserInformation = false;
})
.catch(() => {
this.loadingUserInformation = false;
});
})
.catch(() => {
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
this.loadingUserInformation = false;
});
},
submitNewEmail() {
const data = {
new_email: this.formEmail.new_email,
};
this.loadingUserEmail = true;
this.UPDATE_USER_DETAIL(data)
.then(() => {
this.loadingUserEmail = false;
Swal.fire({
position: 'center',
heightAuto: false,
icon: 'success',
text: `Un e-mail est envoyé à votre nouvelle adresse.
Il contient un lien de validation sur lequel vous devez
cliquer pour confirmer le changement.
`,
showConfirmButton: true,
confirmButtonText: 'OK',
confirmButtonColor: '#187CC6'
});
});
},
submitNewPassword() {
const data = {
password: this.formPassword.password,
new_password: this.formPassword.newPassword2
};
this.loadingUserPassword = true;
this.UPDATE_USER_DETAIL(data)
.then(() => {
this.loadingUserPassword = false;
if (this.success && this.success.length) {
Swal.fire({
position: 'center',
heightAuto: false,
icon: 'success',
text: `Votre mot de passe a bien été modifié.
Vous allez être redirigé vers la page de connexion.
`,
showConfirmButton: true,
confirmButtonText: 'OK',
confirmButtonColor: '#187CC6'
}).then((result) => {
if (result.isConfirmed) {
this.$router.push({ name: 'SignIn' });
}
});
}
});
}
}
}
</script>
<style lang="less" scoped>
#back-button {
font-size: 1.5em;
position: -webkit-sticky; /* Safari */
position: sticky;
top: 5%;
left: 40px;
align-self: flex-start;
border: 2px solid #9BD0FF;
border-radius: 8px;
letter-spacing: 1px;
}
.signup-container {
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
width: 800px;
height: fit-content;
.signup-form {
margin: 5rem 1rem;
h4.title {
color: #373b3d;
.sub-title {
font-size: 75%;
color: #6b7479;
}
}
hr.solid {
border-top: 2px solid #373b3d;
}
h5 {
color: #6b7479;
}
form {
margin-top: 32px;
h5 {
margin-bottom: 20px;
margin-top: 40px;
color: #373b3d;
}
.row {
margin-bottom: 1.6rem;
}
.input-group {
span {
cursor: pointer;
border-bottom-left-radius: 0;
border-top-left-radius: 0;
border-left: none
}
}
}
.infos {
font-size: 0.7em;
font-style: italic;
margin-right: 1em;
ul {
padding-left: 1rem;
}
}
.form-footer {
display: flex;
justify-content: flex-end;
margin-left: 7px;
margin-top: 30px;
button {
margin-left: 2em;
}
button.btn-primary {
border: 2px solid #9BD0FF;
border-radius: 8px;
}
button.btn-outline-secondary {
background-color: #F7F8FA;
border: 2px solid #A9B2B9;
border-radius: 8px;
color: #2F3234;
}
button.btn-outline-secondary:hover {
color: white;
background-color: #4b4b4b;
}
}
}
}
.form-errors {
color: #EB0600 !important;
}
.form-success {
color: #30C963 !important;
}
.footer {
position: relative;
bottom: 0;
font-size: small;
margin-top: 2rem;
}
.footer a {
text-decoration: none;
}
</style>