Commit c1318dd2 authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FIX #17812 TIME 0:10 add delegation msg for actions request and validate parallel opinion

parent e7930b9b
......@@ -14,9 +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">
<app-maarch-message style="margin-bottom: -15px;" *ngIf="delegation.isDelegated && !noResourceToProcess" mode="danger">
{{'lang.signInsteadOf' | translate}}&nbsp;<b style="overflow: hidden;text-overflow: ellipsis;" [title]="delegation.userDelegated">{{ delegation.userDelegated }}</b>
</div>
</app-maarch-message>
<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">
......
......@@ -96,7 +96,8 @@ export class SendAvisParallelComponent implements AfterViewInit {
}
executeAction(realResSelected: number[]) {
const noteContent: string = `[${this.translate.instant('lang.avisUserAsk').toUpperCase()}] ${this.noteEditor.getNoteContent()}`;
const opinionUserState: string = this.translate.instant('lang.requestedOpinion').concat(' ', this.delegation.userDelegated);
const noteContent: string = this.delegation.isDelegated ? `[${this.translate.instant('lang.avisUserAsk').toUpperCase()}] ${this.noteEditor.getNoteContent()}${opinionUserState}` : `[${this.translate.instant('lang.avisUserAsk').toUpperCase()}] ${this.noteEditor.getNoteContent()}`;
this.noteEditor.setNoteContent(noteContent);
this.http.put(this.data.processActionRoute, { resources: realResSelected, note: this.noteEditor.getNote(), data: { opinionLimitDate: this.functions.formatDateObjectToDateString(this.opinionLimitDate, true, 'yyyy-mm-dd'), opinionCircuit : this.appAvisWorkflow.getWorkflow() } }).pipe(
tap((data: any) => {
......
......@@ -35,6 +35,11 @@ export class ValidateAvisParallelComponent implements OnInit, AfterViewInit {
availableRoles: any[] = [];
delegation: any = {
isDelegated: false,
userDelegated: null
};
constructor(
public translate: TranslateService,
public http: HttpClient,
......@@ -46,6 +51,15 @@ export class ValidateAvisParallelComponent implements OnInit, AfterViewInit {
ngOnInit() {
this.checkAvisCircuit();
const userId: number = parseInt(this.data.userId, 10);
if (userId !== this.headerService.user.id && !this.noResourceToProcess) {
this.delegation.isDelegated = true;
this.http.get('../rest/users/' + userId).pipe(
tap((user: any) => {
this.delegation.userDelegated = `${user.firstname} ${user.lastname}`;
})
).subscribe();
}
}
checkAvisCircuit() {
......@@ -93,7 +107,9 @@ export class ValidateAvisParallelComponent implements OnInit, AfterViewInit {
}
executeAction(realResSelected: number[]) {
const noteContent: string = `[${this.translate.instant('lang.avisUserAsk').toUpperCase()}] ${this.noteEditor.getNoteContent()}${this.translate.instant('lang.validateBy')} ${this.headerService.user.firstname} ${this.headerService.user.lastname}`;
const insteadOfMsg: string = `${this.translate.instant('lang.insteadOf').replace(/^.{1}/g, this.translate.instant('lang.insteadOf')[0].toLowerCase())} ${this.delegation.userDelegated}`;
const validatedOpinionMsg: string = `[${this.translate.instant('lang.avisUserAsk').toUpperCase()}] ${this.noteEditor.getNoteContent()}${this.translate.instant('lang.validateBy')} ${this.headerService.user.firstname} ${this.headerService.user.lastname}`;
const noteContent: string = !this.delegation.isDelegated ? validatedOpinionMsg : `${validatedOpinionMsg} ${insteadOfMsg}`;
this.noteEditor.setNoteContent(noteContent);
this.http.put(this.data.processActionRoute, { resources: realResSelected, data: { note: this.noteEditor.getNote(), opinionLimitDate: this.functions.formatDateObjectToDateString(this.opinionLimitDate, true), opinionCircuit: this.appAvisWorkflow.getWorkflow() } }).pipe(
tap((data: any) => {
......
......@@ -2520,5 +2520,6 @@
"contactsParameters_sector": "Sector",
"company": "Company",
"noRecipient": "No associated recipient.",
"delegatedOpinion": "Opinion given instead of"
"delegatedOpinion": "Opinion given instead of",
"requestedOpinion": "Opinion requested instead of"
}
......@@ -2518,5 +2518,6 @@
"mustSign": "La position de signature pour les utilisateurs externes est obligatoire.",
"company": "Organisation",
"noRecipient": "Aucun destinataire associé.",
"delegatedOpinion": "Avis donné à la place de"
"delegatedOpinion": "Avis donné à la place de",
"requestedOpinion": "Avis demandé à la place de"
}
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