[PM-9589] Card Details Heading (#10023)
* only show branded card details when the brand isn't "other" * use TS for the dynamic brand heading rather than template logic
This commit is contained in:
parent
9eddbfc6e7
commit
2d4783932b
|
@ -1,12 +1,7 @@
|
||||||
<bit-section [formGroup]="cardDetailsForm">
|
<bit-section [formGroup]="cardDetailsForm">
|
||||||
<bit-section-header>
|
<bit-section-header>
|
||||||
<h2 bitTypography="h5">
|
<h2 bitTypography="h5">
|
||||||
<ng-container *ngIf="cardDetailsForm.value.brand; else defaultHeading">
|
{{ getSectionHeading() }}
|
||||||
{{ "cardBrandDetails" | i18n: cardDetailsForm.value.brand }}
|
|
||||||
</ng-container>
|
|
||||||
<ng-template #defaultHeading>
|
|
||||||
{{ "cardDetails" | i18n }}
|
|
||||||
</ng-template>
|
|
||||||
</h2>
|
</h2>
|
||||||
</bit-section-header>
|
</bit-section-header>
|
||||||
<bit-card>
|
<bit-card>
|
||||||
|
|
|
@ -28,7 +28,7 @@ describe("CardDetailsSectionComponent", () => {
|
||||||
imports: [CardDetailsSectionComponent, CommonModule, ReactiveFormsModule],
|
imports: [CardDetailsSectionComponent, CommonModule, ReactiveFormsModule],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: CipherFormContainer, useValue: cipherFormProvider },
|
{ provide: CipherFormContainer, useValue: cipherFormProvider },
|
||||||
{ provide: I18nService, useValue: mock<I18nService>() },
|
{ provide: I18nService, useValue: { t: (key: string) => key } },
|
||||||
],
|
],
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
});
|
});
|
||||||
|
@ -122,4 +122,24 @@ describe("CardDetailsSectionComponent", () => {
|
||||||
|
|
||||||
expect(component.cardDetailsForm.controls.brand.value).toBe("Visa");
|
expect(component.cardDetailsForm.controls.brand.value).toBe("Visa");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('displays brand heading text when "brand" is not "Other"', () => {
|
||||||
|
component.cardDetailsForm.patchValue({
|
||||||
|
brand: "Visa",
|
||||||
|
});
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const heading = fixture.debugElement.query(By.css("h2"));
|
||||||
|
|
||||||
|
expect(heading.nativeElement.textContent.trim()).toBe("cardBrandDetails");
|
||||||
|
|
||||||
|
component.cardDetailsForm.patchValue({
|
||||||
|
brand: "Other",
|
||||||
|
});
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(heading.nativeElement.textContent.trim()).toBe("cardDetails");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -145,6 +145,17 @@ export class CardDetailsSectionComponent implements OnInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get the section heading based on the card brand */
|
||||||
|
getSectionHeading(): string {
|
||||||
|
const { brand } = this.cardDetailsForm.value;
|
||||||
|
|
||||||
|
if (brand && brand !== "Other") {
|
||||||
|
return this.i18nService.t("cardBrandDetails", brand);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.i18nService.t("cardDetails");
|
||||||
|
}
|
||||||
|
|
||||||
/** Set form initial form values from the current cipher */
|
/** Set form initial form values from the current cipher */
|
||||||
private setInitialValues() {
|
private setInitialValues() {
|
||||||
const { cardholderName, number, brand, expMonth, expYear, code } = this.originalCipherView.card;
|
const { cardholderName, number, brand, expMonth, expYear, code } = this.originalCipherView.card;
|
||||||
|
|
Loading…
Reference in New Issue