From 74da4bdb57b1969903efe359e4fd6ccc16b62dba Mon Sep 17 00:00:00 2001 From: Hamza HRAMCHI <hamza.hramchi@xelians.fr> Date: Fri, 12 Aug 2022 12:02:04 +0200 Subject: [PATCH] FEAT #20561 TIME 0:15 add toggle to actions (6) --- .../reset-record-management.component.html | 11 +++++ .../reset-record-management.component.ts | 41 ++++++++++++++++++- ...isa-back-to-previous-action.component.html | 9 ---- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/frontend/app/actions/reset-record-management-action/reset-record-management.component.html b/src/frontend/app/actions/reset-record-management-action/reset-record-management.component.html index 51e37b5aee9..bf474c23088 100644 --- a/src/frontend/app/actions/reset-record-management-action/reset-record-management.component.html +++ b/src/frontend/app/actions/reset-record-management-action/reset-record-management.component.html @@ -35,6 +35,17 @@ <app-note-editor #noteEditor [resIds]="selectedRes"></app-note-editor> </div> </div> + <ng-container *ngIf="showToggle"> + <div class="row"> + <div class="col-md-12" style="margin: 10px 0px 10px 0px;"> + <mat-slide-toggle name="history" color="primary" + [title]="'lang.canGoToNextResDesc' | translate" [(ngModel)]="canGoToNextRes" [checked]="canGoToNextRes"> + {{'lang.canGoToNextRes' | translate}} + </mat-slide-toggle> + </div> + </div> + <mat-divider></mat-divider> + </ng-container> </div> <span class="divider-modal"></span> <div mat-dialog-actions class="actions"> diff --git a/src/frontend/app/actions/reset-record-management-action/reset-record-management.component.ts b/src/frontend/app/actions/reset-record-management-action/reset-record-management.component.ts index 9e7eadc4695..2b816bbca6f 100644 --- a/src/frontend/app/actions/reset-record-management-action/reset-record-management.component.ts +++ b/src/frontend/app/actions/reset-record-management-action/reset-record-management.component.ts @@ -1,10 +1,12 @@ import { HttpClient } from '@angular/common/http'; import { Component, Inject, OnInit, ViewChild } from '@angular/core'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { Router } from '@angular/router'; import { NoteEditorComponent } from '@appRoot/notes/note-editor.component'; import { TranslateService } from '@ngx-translate/core'; import { FunctionsService } from '@service/functions.service'; import { NotificationService } from '@service/notification/notification.service'; +import { SessionStorageService } from '@service/session-storage.service'; import { of } from 'rxjs'; import { catchError, finalize, tap } from 'rxjs/operators'; @@ -20,19 +22,27 @@ export class ResetRecordManagementComponent implements OnInit { resourcesErrors: any[] = []; selectedRes: number[] = []; + canGoToNextRes: boolean = false; + showToggle: boolean = false; + inLocalStorage: boolean = false; + @ViewChild('noteEditor', { static: false }) noteEditor: NoteEditorComponent; constructor( public translate: TranslateService, public http: HttpClient, - private notify: NotificationService, public dialogRef: MatDialogRef<ResetRecordManagementComponent>, + public functions: FunctionsService, @Inject(MAT_DIALOG_DATA) public data: any, - public functions: FunctionsService + private notify: NotificationService, + private functionsService: FunctionsService, + private router: Router, + private sessionStorage: SessionStorageService ) { } ngOnInit(): void { this.checkReply(); + this.getDefaultAction(); } checkReply() { @@ -49,8 +59,35 @@ export class ResetRecordManagementComponent implements OnInit { ).subscribe(); } + getDefaultAction() { + this.http.get(`../rest/resourcesList/users/${this.data.userId}/groups/${this.data.groupId}/baskets/${this.data.basketId}`) + .pipe( + tap((res: any) => { + if (!this.functionsService.empty(res.defaultAction.data.canGoToNextRes)) { + // Check if the option is activated for the current basket + if (res.defaultAction.data.canGoToNextRes === true) { + this.showToggle = this.router.url.includes('process'); + this.inLocalStorage = !this.functionsService.empty(this.sessionStorage.get(`canGoToNextRes_basket_${this.data.basketId}_group_${this.data.groupId}_action_${this.data.action.id}`)); + this.canGoToNextRes = this.inLocalStorage; + } else { + this.showToggle = this.canGoToNextRes = false; + this.sessionStorage.clearAllById(this.data); + } + } else { + this.showToggle = this.canGoToNextRes = false; + this.sessionStorage.clearAllById(this.data); + } + }), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe(); + } + onSubmit() { this.loading = true; + this.sessionStorage.checkSessionStorage(this.inLocalStorage, this.canGoToNextRes, this.data); this.executeAction(); } diff --git a/src/frontend/app/actions/visa-reject-back-to-previous-action/reject-visa-back-to-previous-action.component.html b/src/frontend/app/actions/visa-reject-back-to-previous-action/reject-visa-back-to-previous-action.component.html index 4602f60bf02..cd727e2e8d0 100755 --- a/src/frontend/app/actions/visa-reject-back-to-previous-action/reject-visa-back-to-previous-action.component.html +++ b/src/frontend/app/actions/visa-reject-back-to-previous-action/reject-visa-back-to-previous-action.component.html @@ -37,15 +37,6 @@ <div class="col-md-12"> <app-note-editor #noteEditor [resIds]="data.resIds"></app-note-editor> </div> - <ng-container *ngIf="showToggle"> - <div class="col-md-12" style="margin: 10px 0px 10px 0px;"> - <mat-slide-toggle name="history" color="primary" - [title]="'lang.canGoToNextResDesc' | translate" [(ngModel)]="canGoToNextRes" [checked]="canGoToNextRes"> - {{'lang.canGoToNextRes' | translate}} - </mat-slide-toggle> - </div> - <mat-divider></mat-divider> - </ng-container> </div> </div> <span class="divider-modal"></span> -- GitLab