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: added select control renderer for enums and oneOf #2264

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mhorsche
Copy link

Added <mat-select> control for enum and oneOf types. Enable multi-selection for array type. Not sure if RankedTester ist properly defined, could need help with that.

Copy link

netlify bot commented Jan 30, 2024

Deploy Preview for jsonforms-examples ready!

Name Link
🔨 Latest commit df3072a
🔍 Latest deploy log https://app.netlify.com/sites/jsonforms-examples/deploys/65b953ae1efac50008494cfd
😎 Deploy Preview https://deploy-preview-2264--jsonforms-examples.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@CLAassistant
Copy link

CLAassistant commented Jan 30, 2024

CLA assistant check
All committers have signed the CLA.

@lucas-koehler
Copy link
Contributor

Hi! Thanks for your PR ❤️ We'll try to have a look soon!

@coveralls
Copy link

Coverage Status

coverage: 84.678% (-0.1%) from 84.796%
when pulling df3072a on mhorsche:master
into 9d3f706 on eclipsesource:master.

Copy link
Contributor

@lucas-koehler lucas-koehler left a comment

Choose a reason for hiding this comment

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

Hi @mhorsche , thanks again for the contribution ❤️
The control already seems to work quite well. I have some inline comments.
Please have a look at the comments and add some test cases for the new renderer in packages/angular-material/test. Generally, we require at least basic tests for every renderer.

/*
The MIT License

Copyright (c) 2017-2019 EclipseSource Munich
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Copyright (c) 2017-2019 EclipseSource Munich
Copyright (c) 2024 EclipseSource Munich

return {
const: el.const,
label: el.title ? el.title : el.const,
// disabled: el.readOnly ? true : false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be removed?

<mat-option
*ngFor="let option of optionElements"
[value]="option.const"
[disabled]="option.disabled ? true : false"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be removed?

)
);

interface OptionOfSelect {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of defining a new type, I think we can reuse the EnumOption type from @jsonforms/core. The disabled property does not seem to be needed after all.

/* change scope to items of the array */
scope = scope.items as JsonSchema;
}
console.log(scope);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a leftover from development? It should likely be removed


export const SelectControlRendererTester: RankedTester = rankWith(
5,
/* Can be used for simple Enums or OneOf, autocomplete functionallity needs autocomplete.rederer */
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/* Can be used for simple Enums or OneOf, autocomplete functionallity needs autocomplete.rederer */
/* Can be used for simple Enums or OneOf, autocomplete functionality needs autocomplete.renderer */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants