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

feat(forms): add FormBuilder.record() method #46485

Closed
wants to merge 1 commit into from

Conversation

cexbrayat
Copy link
Member

@cexbrayat cexbrayat commented Jun 24, 2022

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

The new FormRecord entity introduced in Angular v14 does not have its builder method.

What is the new behavior?

This commit adds it, allowing to write:

const fb = new FormBuilder();
fb.record({ a: 'one' });

This works for both the FormBuilder and the NonNullableFormBuilder

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@cexbrayat cexbrayat requested a review from dylhunn Jun 24, 2022
@ngbot ngbot bot modified the milestone: Backlog Jun 24, 2022
Copy link
Contributor

@dylhunn dylhunn left a comment

One more thing, can you also accept your API changes once all code changes are made?

yarn bazel run //packages/forms:forms_api.accept  

* * `updateOn`: The event upon which the control should be updated (options: 'change' | 'blur'
* | submit').
*/
record<T>(controls: {[key: string]: T}, options: AbstractControlOptions|null = null):
Copy link
Contributor

@dylhunn dylhunn Jul 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for this compile error is that the type constraint on the FormRecord class is overly specific. I sent more details on Slack.

Copy link
Member Author

@cexbrayat cexbrayat Jul 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed on Slack, I relaxed the type of FormRecord from FormRecord<TControl extends AbstractControl<ɵValue<TControl>, ɵRawValue<TControl>> = AbstractControl> to FormRecord<TControl extends AbstractControl = AbstractControl>.

@cexbrayat cexbrayat force-pushed the feat/form-builder-record branch 2 times, most recently from ffeb711 to aec7b0b Compare Jul 13, 2022
@cexbrayat cexbrayat marked this pull request as ready for review Jul 13, 2022
@cexbrayat cexbrayat force-pushed the feat/form-builder-record branch from aec7b0b to 7a5c5f7 Compare Jul 13, 2022
Copy link
Contributor

@dylhunn dylhunn left a comment

reviewed-for: fw-forms, fw-core, public-api

@dylhunn dylhunn requested review from AndrewKushnir and removed request for dylhunn Jul 13, 2022
@dylhunn
Copy link
Contributor

dylhunn commented Jul 13, 2022

@AndrewKushnir Can I get your review on this when you have time? I'm hoping to merge this for 14.1.

Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

@cexbrayat the change looks great, just one comment about a potential refactoring to reduce the amount of code (and an app bundle size eventually).

packages/forms/src/form_builder.ts Outdated Show resolved Hide resolved
@pullapprove pullapprove bot requested a review from alxhub Jul 13, 2022
The new `FormRecord` entity introduced in Angular v14 does not have its builder method.
This commit adds it, allowing to write:

```
const fb = new FormBuilder();
fb.record({ a: 'one' });
```

This works for both the `FormBuilder` and the `NonNullableFormBuilder`
@cexbrayat cexbrayat force-pushed the feat/form-builder-record branch from 7a5c5f7 to 1d8acec Compare Jul 14, 2022
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Reviewed-for: public-api

@dylhunn dylhunn added action: merge PR author is ready for this to merge and removed action: cleanup action: review labels Jul 15, 2022
Copy link
Contributor

@jessicajaniuk jessicajaniuk left a comment

reviewed-for: size-tracking

@jessicajaniuk
Copy link
Contributor

jessicajaniuk commented Jul 15, 2022

This PR was merged into the repository by commit 426af91.

@angular-automatic-lock-bot
Copy link

angular-automatic-lock-bot bot commented Aug 15, 2022

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge PR author is ready for this to merge comp: forms forms: strictly typed target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants