mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
[PM-7896] Cipher Form - Additional Options section (#9928)
* [PM-7896] Adjust cipher form container to expose config and original cipher view for children * [PM-7896] Add initial additional options section * [PM-7896] Add tests * [PM-7896] Add TODO comments for Custom Fields * [PM-7896] Hide password reprompt checkbox when unavailable * [PM-7896] Fix storybook
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||
import { FormBuilder, ReactiveFormsModule } from "@angular/forms";
|
||||
import { shareReplay } from "rxjs";
|
||||
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { CipherRepromptType } from "@bitwarden/common/vault/enums";
|
||||
import {
|
||||
CardComponent,
|
||||
CheckboxModule,
|
||||
FormFieldModule,
|
||||
SectionComponent,
|
||||
SectionHeaderComponent,
|
||||
TypographyModule,
|
||||
} from "@bitwarden/components";
|
||||
|
||||
import { PasswordRepromptService } from "../../../services/password-reprompt.service";
|
||||
import { CipherFormContainer } from "../../cipher-form-container";
|
||||
|
||||
@Component({
|
||||
selector: "vault-additional-options-section",
|
||||
templateUrl: "./additional-options-section.component.html",
|
||||
standalone: true,
|
||||
imports: [
|
||||
SectionComponent,
|
||||
SectionHeaderComponent,
|
||||
TypographyModule,
|
||||
JslibModule,
|
||||
CardComponent,
|
||||
FormFieldModule,
|
||||
ReactiveFormsModule,
|
||||
CheckboxModule,
|
||||
CommonModule,
|
||||
],
|
||||
})
|
||||
export class AdditionalOptionsSectionComponent implements OnInit {
|
||||
additionalOptionsForm = this.formBuilder.group({
|
||||
notes: [null as string],
|
||||
reprompt: [false],
|
||||
});
|
||||
|
||||
passwordRepromptEnabled$ = this.passwordRepromptService.enabled$.pipe(
|
||||
shareReplay({ refCount: false, bufferSize: 1 }),
|
||||
);
|
||||
|
||||
constructor(
|
||||
private cipherFormContainer: CipherFormContainer,
|
||||
private formBuilder: FormBuilder,
|
||||
private passwordRepromptService: PasswordRepromptService,
|
||||
) {
|
||||
this.cipherFormContainer.registerChildForm("additionalOptions", this.additionalOptionsForm);
|
||||
|
||||
this.additionalOptionsForm.valueChanges.pipe(takeUntilDestroyed()).subscribe((value) => {
|
||||
this.cipherFormContainer.patchCipher({
|
||||
notes: value.notes,
|
||||
reprompt: value.reprompt ? CipherRepromptType.Password : CipherRepromptType.None,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.cipherFormContainer.originalCipherView) {
|
||||
this.additionalOptionsForm.patchValue({
|
||||
notes: this.cipherFormContainer.originalCipherView.notes,
|
||||
reprompt:
|
||||
this.cipherFormContainer.originalCipherView.reprompt === CipherRepromptType.Password,
|
||||
});
|
||||
}
|
||||
|
||||
if (this.cipherFormContainer.config.mode === "partial-edit") {
|
||||
this.additionalOptionsForm.disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user