Commit 3a9f9bb0 authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FEAT #17812 TIME 2:30 delegated user can give parallel opinion

parent 07c6daaa
......@@ -15,6 +15,6 @@
<img src="assets/spinner.gif"/>
</div>
</app-root>
<script src="runtime-es2015.497d8eb67297abf47895.js" type="module"></script><script src="runtime-es5.497d8eb67297abf47895.js" nomodule defer></script><script src="polyfills-es5.c174c1516561194600a5.js" nomodule defer></script><script src="polyfills-es2015.b86be9c6fde12488a69f.js" type="module"></script><script src="scripts.b9f328a06b6423d59d32.js" defer></script><script src="main-es2015.e9859ecbc8311c451d20.js" type="module"></script><script src="main-es5.e9859ecbc8311c451d20.js" nomodule defer></script></body>
<script src="runtime-es2015.497d8eb67297abf47895.js" type="module"></script><script src="runtime-es5.497d8eb67297abf47895.js" nomodule defer></script><script src="polyfills-es5.c174c1516561194600a5.js" nomodule defer></script><script src="polyfills-es2015.b86be9c6fde12488a69f.js" type="module"></script><script src="scripts.b9f328a06b6423d59d32.js" defer></script><script src="main-es2015.3ace5fe55e5de2a105b2.js" type="module"></script><script src="main-es5.3ace5fe55e5de2a105b2.js" nomodule defer></script></body>
</html>
\ No newline at end of file
......@@ -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;
}
}
.delegationMsg {
color: var(--maarch-color-danger);;
font-size: 12px;
margin-top: 20px;
display: flex !important;
}
\ No newline at end of file
......@@ -16,7 +16,6 @@ export class GiveAvisParallelActionComponent implements OnInit {
loading: boolean = false;
resourcesWarnings: any[] = [];
resourcesErrors: any[] = [];
......@@ -27,6 +26,12 @@ export class GiveAvisParallelActionComponent implements OnInit {
ownerOpinion: string = '';
opinionContent: string = '';
delegation: any = {
isDelegated: false,
userDelegated: null
};
@ViewChild('noteEditor', { static: true }) noteEditor: NoteEditorComponent;
constructor(
......@@ -37,7 +42,8 @@ export class GiveAvisParallelActionComponent implements OnInit {
@Inject(MAT_DIALOG_DATA) public data: any,
public functions: FunctionsService) { }
ngOnInit() {
async ngOnInit() {
await this.isRedirected();
this.checkAvisParallel();
}
......@@ -45,7 +51,6 @@ export class GiveAvisParallelActionComponent implements OnInit {
this.loading = true;
this.resourcesErrors = [];
this.resourcesWarnings = [];
this.http.post('../rest/resourcesList/users/' + this.data.userId + '/groups/' + this.data.groupId + '/baskets/' + this.data.basketId + '/actions/' + this.data.action.id + '/checkGiveParallelOpinion', { resources: this.data.resIds }).pipe(
tap((data: any) => {
if (!this.functions.empty(data.resourcesInformations.warning)) {
......@@ -79,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) => {
......@@ -101,4 +108,27 @@ 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