Skip to content

Add context for array operation#2317

Merged
sdirix merged 1 commit into
eclipsesource:masterfrom
eneufeld:arrayContext
Apr 11, 2024
Merged

Add context for array operation#2317
sdirix merged 1 commit into
eclipsesource:masterfrom
eneufeld:arrayContext

Conversation

@eneufeld

@eneufeld eneufeld commented Apr 9, 2024

Copy link
Copy Markdown
Member

Currently it is very hard to figure out in the middleware what array operation happend to lead to the current array state. There are cases were this information is valuable. To support this all update actions can now have a 'context'. Here we added a specific 'UpdateArrayContext'.

Contributed on behalf of STMicroelectronics

@eneufeld eneufeld requested a review from sdirix April 9, 2024 10:08
@netlify

netlify Bot commented Apr 9, 2024

Copy link
Copy Markdown

Deploy Preview for jsonforms-examples ready!

Name Link
🔨 Latest commit 2fcf638
🔍 Latest deploy log https://app.netlify.com/sites/jsonforms-examples/deploys/661564a6ecd1d3000834bba3
😎 Deploy Preview https://deploy-preview-2317--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.

@coveralls

coveralls commented Apr 9, 2024

Copy link
Copy Markdown

Coverage Status

coverage: 84.795% (-0.009%) from 84.804%
when pulling 2fcf638 on eneufeld:arrayContext
into c74b8ba on eclipsesource:master.

@sdirix sdirix left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good and thanks for adding the tests. Please have a look at my comments.

Comment thread packages/core/src/actions/actions.ts
Comment thread packages/core/src/actions/actions.ts Outdated
Comment thread packages/core/src/actions/actions.ts Outdated
Comment thread packages/core/src/actions/actions.ts Outdated
Comment on lines +80 to +81
const firstValueType = typeof context.values[0];
return context.values.every((v) => typeof v === firstValueType);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this check is not necessary. JSON Schema supports different types in arrays.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

but we don't support this in jsonforms, so all newly added values must be of the same type
I'm fine removing this check

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't support it in JSON Forms in our current renderers but there is no restriction for that in JSON Schema and custom/future renderers might support that.

Comment thread packages/core/src/actions/actions.ts
Currently it is very hard to figure out in the middleware what array
operation happend to lead to the current array state.
There are cases were this information is valuable.
To support this all update actions can now have a 'context'.
Here we added a specific 'UpdateArrayContext'.

Contributed on behalf of STMicroelectronics
@eneufeld eneufeld requested a review from sdirix April 9, 2024 15:54
@lucas-koehler lucas-koehler added this to the 3.3 milestone Apr 10, 2024

@sdirix sdirix left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Works for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants