diff --git a/lang/en.json b/lang/en.json index 7bb2c17bbbb92ceb57d71801ad0dcb4129fa477e..b0b43bb66b3caf80d376f4704219d8129aea77df 100755 --- a/lang/en.json +++ b/lang/en.json @@ -147,6 +147,7 @@ "visaWorkflow": "Visa workflow", "noteUser": "Note user", "mainDocument": "main document", - "search": "Search" + "search": "Search", + "substitution": "Délégation" } } diff --git a/lang/fr.json b/lang/fr.json index 2c4edad719aa7989b093731c3ae2c21f4b4a1cd0..08564c8bee5792224f06aff57fd1d56453454815 100755 --- a/lang/fr.json +++ b/lang/fr.json @@ -147,6 +147,7 @@ "visaWorkflow": "Circuit de visa", "noteUser": "Annotateur", "mainDocument": "document principal", - "search": "Rechercher" + "search": "Rechercher", + "substitution": "Délégation" } } diff --git a/src/app/user/controllers/SignatureController.php b/src/app/user/controllers/SignatureController.php index 07711e817e11c0eec841f0b50561998214a4d87d..76066c54600f7b86b1268b2bb76e4301eae23e87 100755 --- a/src/app/user/controllers/SignatureController.php +++ b/src/app/user/controllers/SignatureController.php @@ -60,6 +60,7 @@ class SignatureController if ($signature['fingerprint'] == $fingerprint) { $signatures[] = [ 'id' => $signature['id'], + 'substituted' => $signature['substituted'], 'encodedSignature' => base64_encode(file_get_contents($pathToSignature)) ]; } else { diff --git a/src/app/user/controllers/UserController.php b/src/app/user/controllers/UserController.php index 21183d5f2f1708a2743d20a258bcf47783eeb6a4..4640e1ebcec488e874fa4455f645f58c776f9fde 100755 --- a/src/app/user/controllers/UserController.php +++ b/src/app/user/controllers/UserController.php @@ -384,7 +384,7 @@ class UserController ValidatorModel::notEmpty($args, ['id']); ValidatorModel::intVal($args, ['id']); - $user = UserModel::getById(['select' => ['id', 'login', 'email', 'firstname', 'lastname', 'picture', 'preferences'], 'id' => $args['id']]); + $user = UserModel::getById(['select' => ['id', 'login', 'email', 'firstname', 'lastname', 'picture', 'preferences', 'substitute'], 'id' => $args['id']]); if (empty($user['picture'])) { $user['picture'] = base64_encode(file_get_contents('src/frontend/assets/user_picture.png')); diff --git a/src/frontend/app/profile/profile.component.html b/src/frontend/app/profile/profile.component.html index b75370048c4a75353e2636ea4e0d108c9319b553..3fe299baf61327d5b008add772557ce60082659d 100644 --- a/src/frontend/app/profile/profile.component.html +++ b/src/frontend/app/profile/profile.component.html @@ -196,10 +196,9 @@ </div> </div> </mat-tab> - <mat-tab label="{{'lang.administrations' | translate}}" - *ngIf="signaturesService.userLogged.canManageRestUsers"> + <mat-tab label="{{'lang.administrations' | translate}}"> <div class="profile-content"> - <div class="input-row"> + <div class="input-row" *ngIf="signaturesService.userLogged.canManageRestUsers"> <fieldset> <legend align="left">{{'lang.wsUser' | translate}}</legend> <div class="form-container"> @@ -232,6 +231,33 @@ </div> </fieldset> </div> + <div class="input-row"> + <fieldset> + <legend align="left">{{'lang.substitution' | translate}}</legend> + <div class="form-container"> + <div class="form-2-col"> + Utilisateur délégataire + </div> + <div class="form-2-col"> + <mat-form-field> + <mat-select placeholder="Choisissez un remplaçant" name="usersRest" + [(ngModel)]="profileInfo.substitute"> + <mat-option value=""></mat-option> + <ng-container *ngFor="let userRest of usersRest"> + <mat-option *ngIf="userRest.id !== profileInfo.id" + [value]="userRest.id"> + {{userRest.firstname}} + {{userRest.lastname}}</mat-option> + </ng-container> + </mat-select> + </mat-form-field> + </div> + </div> + <ng-container *ngIf="this.profileInfo.substitute !== '' && this.profileInfo.substitute !== undefined"> + <button type="button" class="signListButton" mat-stroked-button *ngFor="let signature of signaturesService.signaturesList; let i=index" (click)="toggleSignature(i)" [class.selected]="signature.substituted"><img [src]="sanitizer.bypassSecurityTrustUrl('data:image/png;base64,' + signature.encodedSignature)"/></button> + </ng-container> + </fieldset> + </div> </div> </mat-tab> </mat-tab-group> @@ -239,7 +265,8 @@ <button class="validate" mat-button color="primary" type="submit" [disabled]="allowValidate() || !profileForm.form.valid">{{ msgButton | translate}}</button> - <button *ngIf="signaturesService.mobileMode" class="cancel" mat-icon-button type="button" (tap)="closeProfile();"> + <button *ngIf="signaturesService.mobileMode" class="cancel" mat-icon-button type="button" + (tap)="closeProfile();"> <mat-icon fontSet="fas" fontIcon="fa-arrow-left fa-2x"></mat-icon> </button> </span> diff --git a/src/frontend/app/profile/profile.component.scss b/src/frontend/app/profile/profile.component.scss index 594ae4c3365b0d53a8790be7202b1218520c6f1a..472f7ecaafc563695ff3b000269a90cab1f179cb 100644 --- a/src/frontend/app/profile/profile.component.scss +++ b/src/frontend/app/profile/profile.component.scss @@ -54,6 +54,7 @@ } .avatarProfile { + z-index: 2; cursor: pointer; position: absolute; /*background: url(../../assets/user_sample.svg) $primary;*/ @@ -187,4 +188,18 @@ legend { .mat-icon { height:auto; +} + + +.signListButton { + margin:5px; + border: solid white; + + img { + width: 150px; + } +} + +.selected { + border: solid #F99830; } \ No newline at end of file diff --git a/src/frontend/app/profile/profile.component.ts b/src/frontend/app/profile/profile.component.ts index 3ea8d067c8e9f570ecbf2ad911b743183a422d7f..3f6512f0a203817c3629f09d97ab9d4e1625fcb6 100644 --- a/src/frontend/app/profile/profile.component.ts +++ b/src/frontend/app/profile/profile.component.ts @@ -22,6 +22,7 @@ export class ProfileComponent implements OnInit { @ViewChild('passwordContent') passwordContent: MatExpansionPanel; profileInfo: any = { + substitute: '', preferences: [] }; hideCurrentPassword: Boolean = true; @@ -199,8 +200,14 @@ export class ProfileComponent implements OnInit { 'lastname': this.profileInfo.lastname, 'email': this.profileInfo.email, 'picture': this.profileInfo.picture, - 'preferences': this.profileInfo.preferences + 'preferences': this.profileInfo.preferences, + 'substitute': this.profileInfo.substitute, }; + + if (this.profileInfo.substitute.userId !== '') { + alert('Vous avez choisie une délégation, vous ne pourrez plus viser ou signer de courrier.'); + } + if (this.profileInfo.picture === this.signaturesService.userLogged.picture) { profileToSend.picture = ''; } else { @@ -215,6 +222,7 @@ export class ProfileComponent implements OnInit { this.signaturesService.userLogged.lastname = this.profileInfo.lastname; this.signaturesService.userLogged.picture = data.user.picture; this.signaturesService.userLogged.preferences = data.user.preferences; + this.signaturesService.userLogged.substitute = data.user.substitute; this.profileInfo.picture = data.user.picture; this.setLang(this.signaturesService.userLogged.preferences.lang); this.cookieService.set( 'maarchParapheurLang', this.signaturesService.userLogged.preferences.lang ); @@ -248,6 +256,14 @@ export class ProfileComponent implements OnInit { this.msgButton = 'lang.validate'; this.closeProfile(); } + + if (this.profileInfo.substitute.userId !== '') { + this.http.patch('../rest/users/' + this.signaturesService.userLogged.id + '/signatures/substituted', {'signatures': this.signaturesService.signaturesList}) + .subscribe(() => { }, (err) => { + this.notificationService.handleErrors(err); + }); + } + }, (err) => { this.disableState = false; this.msgButton = 'lang.validate'; @@ -345,7 +361,7 @@ export class ProfileComponent implements OnInit { } swithToAdmin() { - if (this.usersRest.length === 0) { + /*if (this.usersRest.length === 0) { this.getPassRules(); this.http.get('../rest/users?mode=rest') .subscribe((data: any) => { @@ -355,6 +371,25 @@ export class ProfileComponent implements OnInit { }, (err: any) => { this.notificationService.handleErrors(err); }); + }*/ + + if (this.usersRest.length === 0) { + this.getPassRules(); + this.http.get('../rest/users') + .subscribe((data: any) => { + this.usersRest = data.users; + }, (err: any) => { + this.notificationService.handleErrors(err); + }); + } + + if (this.signaturesService.signaturesList.length === 0) { + this.http.get('../rest/users/' + this.profileInfo.id + '/signatures') + .subscribe((data: any) => { + this.signaturesService.signaturesList = data.signatures; + }, (err: any) => { + this.notificationService.handleErrors(err); + }); } } @@ -370,8 +405,11 @@ export class ProfileComponent implements OnInit { }); } - setLang(lang: any) { this.translate.use(lang); } + + toggleSignature(i: number) { + this.signaturesService.signaturesList[i].substituted = !this.signaturesService.signaturesList[i].substituted; + } }