Angular Material: Translate Autocomplete Control Renderer #2535
+99
−19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
The company I work for (SICPA Product Security) is considering adopting JSON Forms for a project.
Unfortunately the project is written in Angular, and I noticed that the Angular Material renderer set is missing quite a lot of supported features compared to the React/Vue renderer sets.
As such, I have been testing the Angular Material renderer set quite thoroughly, and will be contributing some missing features, especially to the Angular Material renderer set.
Description
The Angular Material renderer set renders enums using the
AutocompleteControlRenderer.Unlike the other renderer sets,
AutocompleteControlRendererdoes not translate the enum values.This PR updates
AutocompleteControlRendererto usemapStateToEnumControlProps(JsonFormsState, OwnPropsOfControl & OwnPropsOfEnum)like the other renderer sets, which translates the enum values as labels, while keeping the original values as the values:jsonforms/packages/core/src/mappers/renderer.ts
Lines 676 to 707 in e642b3d
For backwards compatibility, I've allowed the
options@Input to still take instring[](by typing it asEnumOption[] | string[]), but it will not be translated if astring[]is passed.