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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 9x 9x 9x 9x 9x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import { FormBuilder, UntypedFormGroup } from '@angular/forms';
import { defer } from 'lodash-es';
import { catchError, Observable, of } from 'rxjs';
import { GenFormComponent } from '../../../form/plugins/gen/gen.component';
import { Plugin } from '../../../model/plugin';
import { Ref } from '../../../model/ref';
import { AdminService } from '../../../service/admin.service';
import { LoadingComponent } from '../../loading/loading.component';
import { ActionComponent } from '../action.component';
@Component({
selector: 'app-inline-plugin',
templateUrl: './inline-plugin.component.html',
styleUrls: ['./inline-plugin.component.scss'],
host: { 'class': 'action' },
imports: [GenFormComponent, LoadingComponent]
})
export class InlinePluginComponent extends ActionComponent {
@Input()
action: (plugins: any) => Observable<any|never> = () => of(null);
@Input()
plugin!: Plugin;
@Input()
value?: Partial<Ref>;
@Output()
error = new EventEmitter<string>();
editing = false;
acting = false;
group: UntypedFormGroup = this.fb.group({});
constructor(
public admin: AdminService,
private fb: FormBuilder,
) {
super();
}
@ViewChild('gen')
set gen(c: GenFormComponent) {
Eif (!c) return;
this.group = this.fb.group({
[this.plugin.tag]: this.fb.group({}),
});
defer(() => c.setValue(this.value?.plugins || {}));
}
override reset() {
this.editing = false;
this.acting = false;
}
override active() {
return this.editing || this.acting;
}
save() {
this.editing = false;
this.acting = true;
this.action(this.group.value).pipe(
catchError(() => of(null)),
).subscribe(() => this.acting = false);
}
}
|