import { Component, inject, signal } from '@angular/core'; import { BeheerDefaultFill, BffApiV1Service } from 'api-client'; import { UtrechtComponentsModule } from 'ui'; /** * The beheer default-fill editor (S-15b): a beheerder reads and edits the ZGW default-fill values the * ACL stamps on every zaak (ADR-0003). Load and save go through the BFF (`/beheer/default-fill`), * which proxies the ACL (ADR-0025). A save takes effect on the next zaak (the ACL reads it per zaak). */ @Component({ selector: 'app-default-fill-page', imports: [UtrechtComponentsModule], templateUrl: './default-fill-page.html', }) export class DefaultFillPage { private readonly bff = inject(BffApiV1Service); protected readonly bronorganisatie = signal(''); protected readonly verantwoordelijkeOrganisatie = signal(''); protected readonly vertrouwelijkheidaanduiding = signal(''); protected readonly loading = signal(false); protected readonly loaded = signal(false); protected readonly saving = signal(false); protected readonly failed = signal(false); protected readonly saved = signal(false); constructor() { this.load(); } load(): void { this.loading.set(true); this.failed.set(false); this.saved.set(false); this.bff.getBeheerDefaultFill().subscribe({ next: (d: BeheerDefaultFill) => { this.bronorganisatie.set(d.bronorganisatie); this.verantwoordelijkeOrganisatie.set(d.verantwoordelijkeOrganisatie); this.vertrouwelijkheidaanduiding.set(d.vertrouwelijkheidaanduiding); this.loading.set(false); this.loaded.set(true); }, error: () => { this.loading.set(false); this.loaded.set(true); this.failed.set(true); }, }); } save(): void { this.saving.set(true); this.failed.set(false); this.saved.set(false); this.bff .putBeheerDefaultFill({ bronorganisatie: this.bronorganisatie(), verantwoordelijkeOrganisatie: this.verantwoordelijkeOrganisatie(), vertrouwelijkheidaanduiding: this.vertrouwelijkheidaanduiding(), }) .subscribe({ next: () => { this.saving.set(false); this.saved.set(true); }, error: () => { this.saving.set(false); this.failed.set(true); }, }); } }