Skip to content
Snippets Groups Projects
Commit 1bf043b1 authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT #15049 TIME 0:05 reset record management action

parent f9288a47
No related branches found
No related tags found
No related merge requests found
<div class="mat-dialog-content-container">
<h1 mat-dialog-title>{{data.action.label}}</h1>
<div mat-dialog-content>
<div *ngIf="checking" class="checking" color="primary" style="display:flex;height:100%;justify-content: center;padding: 30px;">
<mat-spinner diameter="24"></mat-spinner>&nbsp;{{'lang.checkInProgress' | translate}} ...
</div>
<div *ngIf="loading" class="loading" color="primary">
<mat-spinner></mat-spinner>
</div>
<div class="row" *ngIf="!checking">
<div class="alert-message alert-message-info" role="alert" style="margin-top: 0px;" [innerHTML]="'lang.resetRecordManagementDesc' | translate"></div>
<ng-container *ngIf="data.resIds.length > 0">
<div>
{{'lang.makeActionOn' | translate}}
<b *ngIf="data.resIds.length === 0" color="primary"
class="highlight">{{'lang.currentIndexingMail' | translate}}</b>
<b *ngIf="data.resIds.length === 1" color="primary" class="highlight">{{data.resource.chrono}}</b>
<b *ngIf="data.resIds.length > 1" color="primary" class="highlight">{{data.resIds.length}}
{{'lang.elements' | translate}}</b> ?
</div>
<div>
<div *ngIf="resourcesErrors.length > 0" class="alert-message alert-message-danger mailList">
<p>
{{'lang.canNotMakeAction' | translate}} :
</p>
<ul>
<li *ngFor="let ressource of resourcesErrors">
<b>{{ressource.alt_identifier}}</b> : {{'lang.' + ressource.reason | translate}}
</li>
</ul>
</div>
</div>
</ng-container>
<div *ngIf="selectedRes.length > 0">
<app-note-editor #noteEditor [resIds]="selectedRes"></app-note-editor>
</div>
</div>
</div>
<span class="divider-modal"></span>
<div mat-dialog-actions class="actions">
<button mat-raised-button mat-button color="primary" [disabled]="loading || selectedRes.length == 0"
(click)="onSubmit()">{{'lang.validate' | translate}}</button>
<button mat-raised-button mat-button [disabled]="loading" [mat-dialog-close]="">{{'lang.cancel' | translate}}</button>
</div>
</div>
\ No newline at end of file
.loading {
position: absolute;
display: flex;
height: 100%;
justify-content: center;
width: 100%;
left: 0px;
top: 0px;
align-items: center;
z-index: 1;
background: rgba(255, 255, 255, 0.8);
}
.checking {
display: flex;
height: 100%;
justify-content: center;
align-items: center;
padding: 30px;
}
\ No newline at end of file
import { HttpClient } from '@angular/common/http';
import { Component, Inject, OnInit, ViewChild } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
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 { of } from 'rxjs';
import { catchError, finalize, tap } from 'rxjs/operators';
@Component({
selector: 'app-reset-record-management',
templateUrl: './reset-record-management.component.html',
styleUrls: ['./reset-record-management.component.scss']
})
export class ResetRecordManagementComponent implements OnInit {
loading: boolean = false;
checking: boolean = true;
resourcesErrors: any[] = [];
selectedRes: number[] = [];
@ViewChild('noteEditor', { static: false }) noteEditor: NoteEditorComponent;
constructor(
public translate: TranslateService,
public http: HttpClient,
private notify: NotificationService,
public dialogRef: MatDialogRef<ResetRecordManagementComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
public functions: FunctionsService
) { }
ngOnInit(): void {
this.checkReply();
}
checkReply() {
this.http.post(`../rest/resourcesList/users/${this.data.userId}/groups/${this.data.groupId}/baskets/${this.data.basketId}/checkReplyRecordManagement`, { resources: this.data.resIds, resetAction: true }).pipe(
tap((data: any) => {
this.resourcesErrors = data.resourcesInformations.errors;
this.selectedRes = data.resourcesInformations.success;
}),
finalize(() => this.checking = false),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();
}
onSubmit() {
this.loading = true;
this.executeAction();
}
executeAction() {
this.http.put(this.data.processActionRoute, { resources: this.selectedRes, note: this.noteEditor.getNote(), data: {resetAction: true} }).pipe(
tap((data: any) => {
if (!data) {
this.dialogRef.close(this.selectedRes);
}
if (data && data.errors != null) {
this.notify.error(data.errors);
}
}),
finalize(() => this.loading = false),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment