Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 82x 82x 82x 82x 1x 1x 1x 1x 1x 1x 1x | import { Component, Input } from '@angular/core';
import { catchError, Observable, of } from 'rxjs';
import { LoadingComponent } from '../../loading/loading.component';
import { ActionComponent } from '../action.component';
@Component({
selector: 'app-confirm-action',
templateUrl: './confirm-action.component.html',
styleUrls: ['./confirm-action.component.scss'],
host: { 'class': 'action' },
imports: [LoadingComponent]
})
export class ConfirmActionComponentI extends ActionComponent {
@Input()
message = $localize`are you sure?`;
@Input()
warning = '';
@Input()
action: () => Observable<any|never> = () => of(null);
@Input()
minDelayMs = 1000;
confirming = false;
acting = false;
minTimeout = false;
override reset() {
this.confirming = false;
this.acting = false;
}
override active() {
return this.confirming || this.acting;
}
confirm() {
this.confirming = false;
this.acting = true;
this.minTimeout = true;
setTimeout(() => this.minTimeout = false, this.minDelayMs);
this.action().pipe(
catchError(() => of(null)),
).subscribe(() => this.acting = false);
}
}
|