mirror of
https://github.com/bitwarden/browser
synced 2026-02-05 11:13:44 +00:00
directly reference parent form for status rather than subscribe to it
This commit is contained in:
@@ -1,15 +1,7 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
import { CommonModule } from "@angular/common";
|
||||
import {
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
DestroyRef,
|
||||
inject,
|
||||
Input,
|
||||
OnInit,
|
||||
ViewChild,
|
||||
} from "@angular/core";
|
||||
import { ChangeDetectorRef, Component, Input, OnInit, ViewChild } from "@angular/core";
|
||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||
import { FormBuilder, ReactiveFormsModule } from "@angular/forms";
|
||||
import { shareReplay } from "rxjs";
|
||||
@@ -64,12 +56,12 @@ export class AdditionalOptionsSectionComponent implements OnInit {
|
||||
/** True when the form is in `partial-edit` mode */
|
||||
isPartialEdit = false;
|
||||
|
||||
/** True when the form allows new fields to be added */
|
||||
allowNewField = true;
|
||||
|
||||
@Input() disableSectionMargin: boolean;
|
||||
|
||||
private destroyRef = inject(DestroyRef);
|
||||
/** True when the form allows new fields to be added */
|
||||
get allowNewField(): boolean {
|
||||
return this.additionalOptionsForm.enabled;
|
||||
}
|
||||
|
||||
constructor(
|
||||
private cipherFormContainer: CipherFormContainer,
|
||||
@@ -102,17 +94,6 @@ export class AdditionalOptionsSectionComponent implements OnInit {
|
||||
this.additionalOptionsForm.disable();
|
||||
this.isPartialEdit = true;
|
||||
}
|
||||
|
||||
// Disable adding new URIs when the cipher form is disabled
|
||||
this.cipherFormContainer.formStatusChange$
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((status) => {
|
||||
if (status === "disabled") {
|
||||
this.allowNewField = false;
|
||||
} else if (status === "enabled") {
|
||||
this.allowNewField = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Opens the add custom field dialog */
|
||||
|
||||
Reference in New Issue
Block a user