Verified Commit 96e923cd authored by Alex ORLUC's avatar Alex ORLUC

FEAT #10771 TIME 4:30 add link MP account front

parent 187bb1d6
......@@ -10,6 +10,7 @@ import { AdministrationRoutingModule } from './administration-routing.m
import { AdministrationComponent } from './administration.component';
import { UsersAdministrationComponent, UsersAdministrationRedirectModalComponent } from './user/users-administration.component';
import { AccountLinkComponent } from './user/account-link/account-link.component';
import { GroupsAdministrationComponent, GroupsAdministrationRedirectModalComponent } from './group/groups-administration.component';
import { UserAdministrationComponent, UserAdministrationRedirectModalComponent } from './user/user-administration.component';
import { GroupAdministrationComponent } from './group/group-administration.component';
......@@ -103,7 +104,8 @@ import { ShippingAdministrationComponent } from './shipping/shippin
ListAdministrationComponent,
TemplateAdministrationCheckEntitiesModalComponent,
ShippingsAdministrationComponent,
ShippingAdministrationComponent
ShippingAdministrationComponent,
AccountLinkComponent
],
entryComponents: [
UsersAdministrationRedirectModalComponent,
......@@ -116,7 +118,8 @@ import { ShippingAdministrationComponent } from './shipping/shippin
TechnicalAdministrationComponent,
ListAdministrationComponent,
ListAdministrationComponent,
TemplateAdministrationCheckEntitiesModalComponent
TemplateAdministrationCheckEntitiesModalComponent,
AccountLinkComponent
],
})
export class AdministrationModule {}
\ No newline at end of file
<h1 mat-dialog-title>{{lang.linkAccount}}</h1>
<mat-dialog-content class="modal-container">
<mat-form-field appearance="outline" floatLabel="never" [style.fontSize.px]="10">
<input id="availableUsers" type="text" matInput placeholder="{{lang.searchUserInMaarchParapheur}}"
[matAutocomplete]="auto" [formControl]="userCtrl">
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="selectUser($event)" isOpen="true">
<mat-option *ngFor="let user of filteredUsers | async" [value]="user">
{{user.idToDisplay}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
<mat-list *ngIf="externalUser.inMaarchParapheur">
<mat-list-item >
<mat-icon class="avatarAccount" color="primary" mat-list-icon
[style.background-image]="'url('+externalUser.picture+')'"></mat-icon>
<h4 mat-line>{{externalUser.firstname}} {{externalUser.lastname}}</h4>
<p mat-line style="color:#666">{{externalUser.email}}</p>
<button mat-icon-button color="warn" [title]="lang.unlinkAccount" (click)="unlinkMaarchParapheurAccount()">
<mat-icon class="fas fa-unlink"></mat-icon>
</button>
</mat-list-item>
</mat-list>
<mat-form-field *ngIf="!externalUser.inMaarchParapheur">
<input type="text" matInput placeholder="{{lang.newLoginInMaarchParapheur}}" [(ngModel)]="externalUser.login">
</mat-form-field>
<div *ngIf="!externalUser.inMaarchParapheur" class="alert-message alert-message-danger" role="alert" style="margin-top: 30px;" [innerHTML]="lang.maarchParapheurAccountMsg + ' <b>' + externalUser.login + '</b> ' + lang.maarchParapheurAccountMsg2"></div>
</mat-dialog-content>
<mat-dialog-actions>
<button color="primary" mat-raised-button (click)="this.dialogRef.close(externalUser);">{{lang.validate}}</button>
<button mat-raised-button (click)="this.dialogRef.close('');">{{lang.cancel}}</button>
</mat-dialog-actions>
\ No newline at end of file
@import '../../../../css/vars.scss';
.mat-dialog-title {
padding: 10px;
}
.avatarAccount {
border: solid 3px #F99830;
height: 45px !important;
width: 45px !important;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.modal-container{
height: auto;
}
.modal-body{
min-height: auto;
}
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
import { LANG } from '../../../translate.component';
import { AutoCompletePlugin } from '../../../../plugins/autocomplete.plugin';
import { HttpClient } from '@angular/common/http';
import { NotificationService } from '../../../notification.service';
declare function $j(selector: any): any;
@Component({
templateUrl: 'account-link.component.html',
styleUrls: ['account-link.component.scss'],
providers: [NotificationService]
})
export class AccountLinkComponent extends AutoCompletePlugin {
lang: any = LANG;
externalUser: any = {
inMaarchParapheur: false,
login: '',
firstname: '',
lastname: '',
email: '',
picture: ''
};
constructor(public http: HttpClient, @Inject(MAT_DIALOG_DATA) public data: any, public dialogRef: MatDialogRef<AccountLinkComponent>, private notify: NotificationService) {
super(http, ['signatureBookUsersNotLinked']);
}
ngOnInit(): void {
this.http.get(this.coreUrl + 'rest/autocomplete/maarchParapheurUsers', { params: { "search": this.data.user.lastname, "exludeAlreadyConnected": 'true' } })
.subscribe((dataUsers: any) => {
if ( dataUsers.length > 0) {
this.externalUser = dataUsers[0];
this.externalUser.inMaarchParapheur = true;
this.http.get("../../rest/maarchParapheur/user/" + this.externalUser.id + "/picture")
.subscribe((data: any) => {
this.externalUser.picture = data.picture;
}, (err) => {
this.notify.handleErrors(err);
});
} else {
this.externalUser.inMaarchParapheur = false;
this.externalUser = this.data.user;
this.externalUser.login = this.data.user.user_id;
this.externalUser.email = this.data.user.mail;
}
}, (err: any) => {
this.notify.handleErrors(err);
});
}
selectUser(event: any) {
$j('#availableUsers').blur();
this.userCtrl.setValue('');
this.externalUser = event.option.value;
this.externalUser.inMaarchParapheur = true;
this.http.get("../../rest/maarchParapheur/user/" + this.externalUser.id + "/picture")
.subscribe((data: any) => {
this.externalUser.picture = data.picture;
}, (err) => {
this.notify.handleErrors(err);
});
}
unlinkMaarchParapheurAccount() {
this.externalUser.inMaarchParapheur = false;
this.externalUser = this.data.user;
this.externalUser.email = this.data.user.mail;
}
}
......@@ -30,22 +30,29 @@
{{lang.changePassword}}
</p>
</a>
<a mat-list-item *ngIf="user.canCreateMaarchParapheurUser" (click)="sendToMaarchParapheur()"
<a mat-list-item *ngIf="user.canCreateMaarchParapheurUser" (click)="linkMaarchParapheurAccount()"
title="{{lang.createUserInMaarchParapheur}}">
<mat-icon color="primary" mat-list-icon class="fa fa-user"></mat-icon>
<mat-icon color="primary" mat-list-icon class="fa fa-link"></mat-icon>
<p mat-line>
{{lang.createUserInMaarchParapheur}}
</p>
</a>
<a style="opacity:0.7" mat-list-item *ngIf="user.external_id.maarchParapheur" disabled
title="{{lang.userCreatedInMaarchParapheur}}">
<mat-icon color="primary" mat-list-icon class="fa fa-user"></mat-icon>
<p mat-line>
{{lang.userCreatedInMaarchParapheur}}
{{lang.linkAccount}}
</p>
</a>
</mat-nav-list>
<mat-divider></mat-divider>
<mat-list *ngIf="maarchParapheurLink.login !== ''">
<h3 mat-subheader>Compte Maarch Parapheur</h3>
<mat-list-item>
<mat-icon class="avatarAccount" color="primary" mat-list-icon [style.background-image]="'url('+maarchParapheurLink.picture+')'"></mat-icon>
<p mat-line class="accountInfo">
<span>
{{maarchParapheurLink.login}}
</span>
<button mat-icon-button color="warn" (click)="unlinkMaarchParapheurAccount()" title="{{lang.unlinkAccount}}">
<mat-icon class="fas fa-unlink"></mat-icon>
</button>
</p>
</mat-list-item>
</mat-list>
</mat-sidenav>
<mat-sidenav-content>
<div *ngIf="loading" style="display:flex;height:100%;">
......
......@@ -15,4 +15,24 @@
.vertical-divider{
height: 80%;
}
.avatarAccount {
border: solid 3px #F99830;
height: 45px !important;
width: 45px !important;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.accountInfo {
margin-left: 20px !important;
display: flex !important;
span {
flex: 1;
align-items: center;
display: flex;
}
}
\ No newline at end of file
......@@ -1009,4 +1009,12 @@ export const LANG_EN = {
"visaWorkflowWillBeSend" : "Visa workflow will be send to Maarch Parapheur",
"usersNotExistedInMaarchParapheur" : "Some users does not exist in Maarch Parapheur",
"usersMissingInSignatureBook" : "missing in Maarch Parapheur",
"unlinkAccount" : "Unlink account",
"accountLinked" : "Account linked",
"accountUnlinked" : "Account unlinked",
"linkAccount" : "Link Maarch Parapheur account",
"maarchParapheurAccountMsg" : "A <b>new</b> account with login",
"maarchParapheurAccountMsg2" : " will be created in Maarch Parapheur.",
"searchUserInMaarchParapheur" : "Search an user in Maarch Parapheur",
"newLoginInMaarchParapheur" : "New Maarch Parapheur Login",
};
......@@ -1042,4 +1042,12 @@ export const LANG_FR = {
"visaWorkflowWillBeSend" : "Le circuit visa des courriers sera envoyé à Maarch Parapheur",
"usersNotExistedInMaarchParapheur" : "Certains utilisateurs n'existent pas dans Maarch Parapheur",
"usersMissingInSignatureBook" : "non présent dans Maarch Parapheur",
"unlinkAccount" : "Dissocier le compte",
"accountLinked" : "Compte associé",
"accountUnlinked" : "Compte dissocié",
"linkAccount" : "Lier un compte Maarch Parapheur",
"maarchParapheurAccountMsg" : "Un <b>nouveau</b> compte avec l'identifiant",
"maarchParapheurAccountMsg2" : "sera créé dans Maarch Parapheur.",
"searchUserInMaarchParapheur" : "Recherche un utilisateur dans Maarch Parapheur",
"newLoginInMaarchParapheur" : "Nouvel identifiant Maarch Parapheur",
};
\ No newline at end of file
......@@ -1036,4 +1036,11 @@ export const LANG_NL = {
"visaWorkflowWillBeSend" : "Visa workflow will be send to Maarch Parapheur", //_TO_TRANSLATE
"usersNotExistedInMaarchParapheur" : "Some users does not exist in Maarch Parapheur", //_TO_TRANSLATE
"usersMissingInSignatureBook" : "missing in Maarch Parapheur", //_TO_TRANSLATE
"unlinkAccount" : "Unlink account", //_TO_TRANSLATE
"accountLinked" : "Account linked", //_TO_TRANSLATE
"accountUnlinked" : "Account unlinked", //_TO_TRANSLATE
"maarchParapheurAccountMsg" : "A <b>new</b> account with login", //_TO_TRANSLATE
"maarchParapheurAccountMsg2" : " will be created in Maarch Parapheur.", //_TO_TRANSLATE
"searchUserInMaarchParapheur" : "Search unlinked an user in Maarch Parapheur", //_TO_TRANSLATE
"newLoginInMaarchParapheur" : "New Maarch Parapheur Login", //_TO_TRANSLATE
};
......@@ -72,6 +72,22 @@ export class AutoCompletePlugin {
});
}
if (target.indexOf('signatureBookUsersNotLinked') != -1) {
this.userCtrl = new FormControl();
this.userCtrl.valueChanges.pipe(
debounceTime(300),
filter(value => value ? value.length > 2 : false),
distinctUntilChanged(),
switchMap(data => this.http.get(this.coreUrl + 'rest/autocomplete/maarchParapheurUsers', { params: { "search": data, "exludeAlreadyConnected": 'true' } }))
).subscribe((response: any) => {
this.filteredUsers = this.userCtrl.valueChanges
.pipe(
startWith(''),
map(user => user ? this.autocompleteFilterUser(user) : response.slice())
);
});
}
if (target.indexOf('statuses') != -1) {
this.statusCtrl = new FormControl();
this.http.get(this.coreUrl + 'rest/autocomplete/statuses')
......
Markdown is supported
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