Commit 134c91e2 authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FEAT #17812 TIME 0:15 delegated user can give parallel opinion

parent 6aaa6dfa
......@@ -14,6 +14,9 @@
<b *ngIf="data.resIds.length > 1" color="primary" class="highlight">{{data.resIds.length}}
{{'lang.elements' | translate}}</b> ?
</div>
<div mat-line *ngIf="delegation.isDelegated && !noResourceToProcess" class="delegationMsg">
{{'lang.signInsteadOf' | translate}}&nbsp;<b style="overflow: hidden;text-overflow: ellipsis;" [title]="delegation.userDelegated">{{ delegation.userDelegated }}</b>
</div>
<div class="alert-message alert-message-info" *ngIf="data.resIds.length == 1 && !noResourceToProcess"
role="alert" style="margin-top: 30px;"
[innerHTML]="'<b>' + ownerOpinion + '</b> '+ ('lang.askOpinionUser' | translate) + ' :<br/><br/>' + opinionContent">
......
......@@ -116,4 +116,11 @@
img {
margin: 10px;
}
}
\ No newline at end of file
}
.delegationMsg {
color: var(--maarch-color-danger);;
font-size: 12px;
margin-top: 20px;
display: flex !important;
}
......@@ -28,6 +28,11 @@ export class GiveAvisParallelActionComponent implements OnInit {
ownerOpinion: string = '';
opinionContent: string = '';
delegation: any = {
isDelegated: false,
userDelegated: null
};
constructor(
public translate: TranslateService,
public http: HttpClient,
......@@ -36,7 +41,8 @@ export class GiveAvisParallelActionComponent implements OnInit {
@Inject(MAT_DIALOG_DATA) public data: any,
public functions: FunctionsService) { }
ngOnInit() {
async ngOnInit() {
await this.isRedirected();
this.checkAvisParallel();
}
......@@ -78,7 +84,9 @@ export class GiveAvisParallelActionComponent implements OnInit {
}
executeAction(realResSelected: number[]) {
const noteContent: string = `[${this.translate.instant('lang.avisUserState')}] ${this.noteEditor.getNoteContent()}`;
const delegateMsg: string = this.translate.instant('lang.insteadOf').replace(/^.{1}/g, this.translate.instant('lang.insteadOf')[0].toLowerCase());
const avisUserState: string = this.delegation.isDelegated ? `${this.translate.instant('lang.avisUserState').toUpperCase()} ${delegateMsg} ${this.delegation.userDelegated}` : this.translate.instant('lang.avisUserState');
const noteContent: string = `[${avisUserState}] ${this.noteEditor.getNoteContent()}`;
this.noteEditor.setNoteContent(noteContent);
this.http.put(this.data.processActionRoute, { resources: realResSelected, note: this.noteEditor.getNote()}).pipe(
tap((data: any) => {
......@@ -100,4 +108,28 @@ export class GiveAvisParallelActionComponent implements OnInit {
isValidAction() {
return !this.noResourceToProcess && !this.functions.empty(this.noteEditor.getNoteContent());
}
isRedirected() {
return new Promise((resolve) => {
this.http.get('../rest/currentUser/profile').pipe(
tap((data: any) => {
const userId: number = parseInt(this.data.userId, 10);
this.delegation.isDelegated = userId !== data.id ? true : false;
if (this.delegation.isDelegated) {
this.http.get('../rest/users/' + userId).pipe(
tap((user: any) => {
this.delegation.userDelegated = `${user.firstname} ${user.lastname}`;
})
).subscribe();
}
resolve(true);
}),
catchError((err: any) => {
this.notify.handleErrors(err);
return of(false);
})
).subscribe();
});
}
}
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