Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/1493 - Restore updateOn blur which got dropped due to git revert #2085

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class CommitteeInfoComponent extends DestroyerComponent implements OnInit
committeeAccount$: Observable<CommitteeAccount> | undefined;
mostRecentFilingPdfUrl: string | null | undefined = undefined;
stateOptions: PrimeOptions = [];
form: FormGroup = this.fb.group({});
form: FormGroup = this.fb.group({}, { updateOn: 'blur' });
formProperties: string[] = [
'name',
'committee_id',
Expand Down Expand Up @@ -72,7 +72,7 @@ export class CommitteeInfoComponent extends DestroyerComponent implements OnInit
}

ngOnInit(): void {
this.form = this.fb.group(SchemaUtils.getFormGroupFields(this.formProperties));
this.form = this.fb.group(SchemaUtils.getFormGroupFields(this.formProperties), { updateOn: 'blur' });
this.stateOptions = LabelUtils.getPrimeOptions(StatesCodeLabels);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ enum SubmissionStates {
export class FeedbackOverlayComponent {
@ViewChild(OverlayPanel) op!: OverlayPanel;

form: FormGroup = this.fb.group({
action: ['', [Validators.required, Validators.maxLength(2000)]],
feedback: ['', [Validators.maxLength(2000)]],
about: ['', Validators.maxLength(2000)],
});
form: FormGroup = this.fb.group(
{
action: ['', [Validators.required, Validators.maxLength(2000)]],
feedback: ['', [Validators.maxLength(2000)]],
about: ['', Validators.maxLength(2000)],
},
{ updateOn: 'blur' },
);
formSubmitted = false;
SubmissionStatesEnum = SubmissionStates;
submitStatus = this.SubmissionStatesEnum.DRAFT;
Expand Down
13 changes: 8 additions & 5 deletions front-end/src/app/login/debug-login/debug-login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ export class DebugLoginComponent {
private loginService: LoginService,
private router: Router,
) {
this.form = this.fb.group({
emailId: ['', [Validators.required, emailValidator]],
committeeId: ['', [Validators.required, committeeIdValidator]],
loginPassword: ['', Validators.required],
});
this.form = this.fb.group(
{
emailId: ['', [Validators.required, emailValidator]],
committeeId: ['', [Validators.required, committeeIdValidator]],
loginPassword: ['', Validators.required],
},
{ updateOn: 'blur' },
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ export class SecurityNoticeComponent extends DestroyerComponent implements OnIni
formSubmitted = false;
userLoginData?: UserLoginData;

form = new FormGroup({
'security-consent-annual': new FormControl(false),
});
form = new FormGroup(
{
'security-consent-annual': new FormControl(false),
},
{ updateOn: 'blur' },
);

constructor(
private store: Store,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class CashOnHandComponent extends DestroyerComponent implements OnInit {
formProperties: string[] = ['L6a_cash_on_hand_jan_1_ytd', 'cash_on_hand_date'];
report: Form3X | undefined;
formSubmitted = false;
form: FormGroup = this.fb.group(SchemaUtils.getFormGroupFields(this.formProperties));
form: FormGroup = this.fb.group(SchemaUtils.getFormGroupFields(this.formProperties), { updateOn: 'blur' });

constructor(
public router: Router,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,13 @@ describe('CreateF3XStep1Component', () => {
expectedThroughMessage: string | null,
) => {
const validator = buildNonOverlappingCoverageValidator(existingCoverage);
const group = new FormGroup({
coverage_from_date: new FormControl(controlFromDate),
coverage_through_date: new FormControl(controlThroughDate),
});
const group = new FormGroup(
{
coverage_from_date: new FormControl(controlFromDate),
coverage_through_date: new FormControl(controlThroughDate),
},
{ updateOn: 'blur' },
);
validator(group);
console.log(group.get('coverage_from_date')?.errors);
expect(group.get('coverage_from_date')?.errors).toEqual(
Expand Down
6 changes: 2 additions & 4 deletions front-end/src/app/reports/shared/main-form-base.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export abstract class MainFormBaseComponent extends DestroyerComponent implement
abstract webprintURL: string;

formSubmitted = false;
form: FormGroup = new FormGroup({});
form: FormGroup = new FormGroup({}, { updateOn: 'blur' });
reportId?: string;

constructor(
Expand All @@ -41,9 +41,7 @@ export abstract class MainFormBaseComponent extends DestroyerComponent implement

ngOnInit(): void {
this.reportId = this.activatedRoute.snapshot.params['reportId'];
this.form = this.fb.group(SchemaUtils.getFormGroupFieldsNoBlur(this.formProperties, this.fb), {
updateOn: 'blur',
});
this.form = this.fb.group(SchemaUtils.getFormGroupFieldsNoBlur(this.formProperties, this.fb), { updateOn: 'blur' });
const activeReport$ = this.store.select(selectActiveReport).pipe(takeUntil(this.destroy$));
const committeeAccount$ = this.store.select(selectCommitteeAccount).pipe(takeUntil(this.destroy$));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class ReportLevelMemoComponent extends DestroyerComponent implements OnIn
assignedMemoText: MemoText = new MemoText();

formSubmitted = false;
form: FormGroup = this.fb.group({});
form: FormGroup = this.fb.group({}, { updateOn: 'blur' });

constructor(
private store: Store,
Expand All @@ -48,7 +48,7 @@ export class ReportLevelMemoComponent extends DestroyerComponent implements OnIn

ngOnInit(): void {
// Intialize FormGroup, this must be done here. Not working when initialized only above the constructor().
this.form = this.fb.group(SchemaUtils.getFormGroupFields(this.formProperties));
this.form = this.fb.group(SchemaUtils.getFormGroupFields(this.formProperties), { updateOn: 'blur' });

this.store
.select(selectCommitteeAccount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export class SubmitReportStep2Component extends DestroyerComponent implements On
];
report?: Report;
formSubmitted = false;
form: FormGroup = this.fb.group(SchemaUtils.getFormGroupFields(this.formProperties));
form: FormGroup = this.fb.group(SchemaUtils.getFormGroupFieldsNoBlur(this.formProperties, this.fb), {
updateOn: 'blur',
});
loading: 0 | 1 | 2 = 0;
backdoorCodeHelpText =
'This is only needed if you have amended or deleted <b>more than 50% of the activity</b> in the original report, or have <b>fixed an incorrect date range</b>.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Report } from 'app/shared/models/report.model';
styleUrls: ['../transaction.scss'],
})
export class TransactionInputComponent implements OnInit {
@Input() form: FormGroup = new FormGroup([]);
@Input() form: FormGroup = new FormGroup([], { updateOn: 'blur' });
@Input() formSubmitted = false;
@Input() activeReport$?: Observable<Report>;
@Input() transaction?: Transaction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class CommitteeMemberDialogComponent extends DestroyerComponent implement
};
});

form: FormGroup = new FormGroup({});
form: FormGroup = new FormGroup({}, { updateOn: 'blur' });
formSubmitted = false;

@ViewChild('dialog') dialog?: ElementRef;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export class ContactDialogComponent extends DestroyerComponent implements OnInit
...SchemaUtils.getSchemaProperties(contactOrganizationSchema),
]),
]),
{ updateOn: 'blur' },
);
formSubmitted = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ describe('AdditionalInfoInputComponent', () => {

fixture = TestBed.createComponent(AdditionalInfoInputComponent);
component = fixture.componentInstance;
component.form = new FormGroup({
contribution_purpose_descrip: new FormControl(''),
text4000: new FormControl(''),
});
component.form = new FormGroup(
{
contribution_purpose_descrip: new FormControl(''),
text4000: new FormControl(''),
},
{ updateOn: 'blur' },
);
component.templateMap = testTemplateMap;
component.transaction = testScheduleATransaction;
if (component.transaction.transactionType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ describe('AddressInputComponent', () => {

fixture = TestBed.createComponent(AddressInputComponent);
component = fixture.componentInstance;
component.form = new FormGroup({
contributor_street_1: new FormControl(''),
contributor_street_2: new FormControl(''),
contributor_city: new FormControl(''),
contributor_state: new FormControl(''),
contributor_zip: new FormControl(''),
});
component.form = new FormGroup(
{
contributor_street_1: new FormControl(''),
contributor_street_2: new FormControl(''),
contributor_city: new FormControl(''),
contributor_state: new FormControl(''),
contributor_zip: new FormControl(''),
},
{ updateOn: 'blur' },
);
component.templateMap = testTemplateMap;
fixture.detectChanges();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ describe('AmountInputComponent', () => {

fixture = TestBed.createComponent(AmountInputComponent);
component = fixture.componentInstance;
component.form = new FormGroup({
contribution_date: new FormControl(''),
memo_code: new FormControl(''),
contribution_amount: new FormControl(''),
contribution_aggregate: new FormControl(''),
disbursement_date: new FormControl(''),
dissemination_date: new FormControl(''),
expenditure_date: new FormControl(''),
});
component.form = new FormGroup(
{
contribution_date: new FormControl(''),
memo_code: new FormControl(''),
contribution_amount: new FormControl(''),
contribution_aggregate: new FormControl(''),
disbursement_date: new FormControl(''),
dissemination_date: new FormControl(''),
expenditure_date: new FormControl(''),
},
{ updateOn: 'blur' },
);
component.templateMap = testTemplateMap;
fixture.detectChanges();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Transaction } from 'app/shared/models/transaction.model';
})
export abstract class BaseInputComponent extends DestroyerComponent {
@Input() transaction?: Transaction;
@Input() form: FormGroup = new FormGroup([]);
@Input() form: FormGroup = new FormGroup([], { updateOn: 'blur' });
@Input() formSubmitted = false;
@Input() templateMap: TransactionTemplateMapType = {} as TransactionTemplateMapType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@ describe('CandidateInputComponent', () => {

fixture = TestBed.createComponent(CandidateInputComponent);
component = fixture.componentInstance;
component.form = new FormGroup({
donor_candidate_fec_id: new FormControl(''),
donor_candidate_last_name: new FormControl(''),
donor_candidate_first_name: new FormControl(''),
donor_candidate_middle_name: new FormControl(''),
donor_candidate_prefix: new FormControl(''),
donor_candidate_suffix: new FormControl(''),
donor_candidate_office: new FormControl(''),
donor_candidate_state: new FormControl(''),
donor_candidate_district: new FormControl(''),
});
component.form = new FormGroup(
{
donor_candidate_fec_id: new FormControl(''),
donor_candidate_last_name: new FormControl(''),
donor_candidate_first_name: new FormControl(''),
donor_candidate_middle_name: new FormControl(''),
donor_candidate_prefix: new FormControl(''),
donor_candidate_suffix: new FormControl(''),
donor_candidate_office: new FormControl(''),
donor_candidate_state: new FormControl(''),
donor_candidate_district: new FormControl(''),
},
{ updateOn: 'blur' },
);
component.templateMap = testTemplateMap;
fixture.detectChanges();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ describe('CandidateOfficeInputComponent', () => {

fixture = TestBed.createComponent(CandidateOfficeInputComponent);
component = fixture.componentInstance;
component.form = new FormGroup({
donor_candidate_last_name: new FormControl(''),
donor_candidate_first_name: new FormControl(''),
donor_candidate_middle_name: new FormControl(''),
donor_candidate_prefix: new FormControl(''),
donor_candidate_suffix: new FormControl(''),
});
component.form = new FormGroup(
{
donor_candidate_last_name: new FormControl(''),
donor_candidate_first_name: new FormControl(''),
donor_candidate_middle_name: new FormControl(''),
donor_candidate_prefix: new FormControl(''),
donor_candidate_suffix: new FormControl(''),
},
{ updateOn: 'blur' },
);

component.form.addControl(testCandidateOfficeFormControlName, new FormControl());
component.officeFormControlName = testCandidateOfficeFormControlName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ describe('CommitteeInputComponent', () => {

fixture = TestBed.createComponent(CommitteeInputComponent);
component = fixture.componentInstance;
component.form = new FormGroup({
contributor_organization_name: new FormControl(''),
donor_committee_fec_id: new FormControl(''),
donor_committee_name: new FormControl(''),
});
component.form = new FormGroup(
{
contributor_organization_name: new FormControl(''),
donor_committee_fec_id: new FormControl(''),
donor_committee_name: new FormControl(''),
},
{ updateOn: 'blur' },
);
component.templateMap = testTemplateMap;
fixture.detectChanges();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ describe('ElectionInputComponent', () => {

fixture = TestBed.createComponent(ElectionInputComponent);
component = fixture.componentInstance;
component.form = new FormGroup({
election_code: new FormControl(''),
election_other_description: new FormControl(''),
});
component.form = new FormGroup(
{
election_code: new FormControl(''),
election_other_description: new FormControl(''),
},
{ updateOn: 'blur' },
);
component.transaction = getTestTransactionByType(ScheduleETransactionTypes.MULTISTATE_INDEPENDENT_EXPENDITURE);
component.templateMap = testTemplateMap;
fixture.detectChanges();
Expand Down Expand Up @@ -58,10 +61,13 @@ describe('ElectionInputComponent', () => {
it('should disable all fields', () => {
fixture = TestBed.createComponent(ElectionInputComponent);
component = fixture.componentInstance;
component.form = new FormGroup({
election_code: new FormControl(''),
election_other_description: new FormControl(''),
});
component.form = new FormGroup(
{
election_code: new FormControl(''),
election_other_description: new FormControl(''),
},
{ updateOn: 'blur' },
);
component.form.disable();
component.templateMap = testTemplateMap;
fixture.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ describe('EmployerInputComponent', () => {

fixture = TestBed.createComponent(EmployerInputComponent);
component = fixture.componentInstance;
component.form = new FormGroup({
contributor_employer: new FormControl(''),
contributor_occupation: new FormControl(''),
});
component.form = new FormGroup(
{
contributor_employer: new FormControl(''),
contributor_occupation: new FormControl(''),
},
{ updateOn: 'blur' },
);
component.templateMap = testTemplateMap;
fixture.detectChanges();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('LinkedReportInputComponent', () => {
component.templateMap = Object.assign(testTemplateMap, {
date2: 'other_date',
});
component.form = new FormGroup({});
component.form = new FormGroup({}, { updateOn: 'blur' });
component.form.addControl('other_date', new FormControl());
component.form.addControl(testTemplateMap['date'], new FormControl());
component.ngOnInit();
Expand Down
Loading