Angular Material: OneOf Enum Control Renderer#2551
Angular Material: OneOf Enum Control Renderer#2551daniel-shuy wants to merge 5 commits intoeclipsesource:masterfrom
Conversation
✅ Deploy Preview for jsonforms-examples ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
sdirix
left a comment
There was a problem hiding this comment.
Thank you for your contribution! ❤️
packages/angular-material/src/library/controls/one-of-enum.renderer.ts
Outdated
Show resolved
Hide resolved
3f7d65d to
e94da20
Compare
e94da20 to
fc55e41
Compare
|
The modification of the |
fc55e41 to
bf1d6ed
Compare
packages/angular-material/src/library/controls/enum.renderer.ts
Outdated
Show resolved
Hide resolved
|
Hi @sdirix, any update? |
sdirix
left a comment
There was a problem hiding this comment.
Looks good, but I saw a minor issue.
| export class EnumControlRenderer extends OneOfEnumControlRenderer { | ||
| // eslint-disable-next-line @angular-eslint/no-input-rename | ||
| @Input('options') | ||
| set stringOptions(strOptions: string[]) { | ||
| this.options = strOptions.map((str) => { | ||
| return { | ||
| label: str, | ||
| value: str, | ||
| }; | ||
| }); | ||
| } |
There was a problem hiding this comment.
The old AutocompleteControlRenderer accepted EnumOption[] | string[] via @Input. This setter only handles string[]. If someone has <AutocompleteControlRenderer [options]="enumOptionArray">, the setter will silently produce garbage.
We should remove the old component completely so they get an obvious error or make it backward compatible. If we remove it, we should mention it in the migration guide
There was a problem hiding this comment.
Actually, the @Input was previously changed by me in a previous PR (#2535) from string[] to EnumOption[] | string[] so that users can pass in options with different labels from their values to the AutocompleteControlRenderer. I reverted that change since the new OneOfEnumControlRenderer should be used for that purpose instead.
Since #2535 is not part of any release, the @Input type can be safely reverted back to string[].
Renamed
AutocompleteControlRenderertoEnumControlRendererto be consistent with other renderer setsThe
OneOfEnumControlRendererhas the same implementation as theEnumControlRenderer, the only difference being that it takes inEnumOption[]instead ofstring[], so that a different label can be displayed instead of the value:jsonforms/packages/core/src/mappers/renderer.ts
Lines 320 to 323 in 3a9bc74
oneOf.constis mapped toEnumOption.valueoneOf.titleis mapped toEnumOption.label