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

Cell renderer set for vue vanilla (work in progress) #2279

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

davewwww
Copy link
Contributor

regarding: #1720

Hi,

I have tried to implement a proposal for the missing cell feature in vue vanilla.

What do you think, does it work so far?

Copy link

netlify bot commented Feb 12, 2024

Deploy Preview for jsonforms-examples failed.

Name Link
🔨 Latest commit 893774b
🔍 Latest deploy log https://app.netlify.com/sites/jsonforms-examples/deploys/65f8089a4083d0000718c7ea

@sdirix sdirix self-requested a review February 14, 2024 10:24
Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

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

Hi @davewwww,

I discussed with the team. We very much like leveraging the cells mechanism and using it similar to the React Vanilla approach. If this PR is properly finished, then we don't even need the ControlWrapper customization mechanism anymore. Instead one can simply override the InputControlRenderer with the same end result. As this is the cleaner approach, we would prefer that.

Would you be willing to finish this contribution, i.e. removing most of the current control renderers which we have, replacing them with a cell variant?

packages/vue-vanilla/src/cells/TextCell.vue Show resolved Hide resolved
Comment on lines 27 to 26
const input = useVanillaControl(
useJsonFormsControl(props),
(target) => target.value || undefined
);
Copy link
Member

Choose a reason for hiding this comment

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

We should implement and use cell specific variants of the useJsonFormsControl and maybe useVanillaControl bindings, like we do in React.

By reusing the one for the renderers, we will calculate a lot of unnecessary props here (e.g. label) which are then never used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sdirix is the implementation in the current commit as you imagine it? I have used the useVanillaCell() and useJsonFormsCell() functions at the cells, whereby the useVanillaCell() is actually only a copy of the useVanillaControl(), so far correct?

Comment on lines 27 to 36
//stringControlRendererEntry,
multiStringControlRendererEntry,
numberControlRendererEntry,
integerControlRendererEntry,
//numberControlRendererEntry,
//integerControlRendererEntry,
enumControlRendererEntry,
oneOfEnumControlRendererEntry,
dateControlRendererEntry,
dateTimeControlRendererEntry,
timeControlRendererEntry,
booleanControlRendererEntry,
Copy link
Member

Choose a reason for hiding this comment

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

I think we could get rid of all the renderers in favor of cells, except maybe the boolean one.

Copy link
Contributor Author

@davewwww davewwww Feb 15, 2024

Choose a reason for hiding this comment

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

why not the boolean one? is there any special handling? looks pretty much the same as the others.

@davewwww
Copy link
Contributor Author

davewwww commented Feb 14, 2024

Hi @davewwww,

I discussed with the team. We very much like leveraging the cells mechanism and using it similar to the React Vanilla approach. If this PR is properly finished, then we don't even need the ControlWrapper customization mechanism anymore. Instead one can simply override the InputControlRenderer with the same end result. As this is the cleaner approach, we would prefer that.

Would you be willing to finish this contribution, i.e. removing most of the current control renderers which we have, replacing them with a cell variant?

That is of course an interesting thought. So far I use the ControlWrapper in each of my custom renderers.
But perhaps it would still be a good idea to keep the ControlWrapper in place if a customer don't want to go with this cells but want to stick with your "old" custom renderer. Topic backwards compatibility

And yes, if you give the GO, then I would continue to work on it.

@sdirix
Copy link
Member

sdirix commented Feb 14, 2024

Hi @davewwww,
I discussed with the team. We very much like leveraging the cells mechanism and using it similar to the React Vanilla approach. If this PR is properly finished, then we don't even need the ControlWrapper customization mechanism anymore. Instead one can simply override the InputControlRenderer with the same end result. As this is the cleaner approach, we would prefer that.
Would you be willing to finish this contribution, i.e. removing most of the current control renderers which we have, replacing them with a cell variant?

That is of course an interesting thought. So far I use the ControlWrapper in each of my custom renderers. But perhaps it would still be a good idea to keep the ControlWrapper in place if a customer don't want to go with this cells but want to stick with your "old" custom renderer. Topic backwards compatibility

  • Refactoring the existing renderers should be backward compatible without any effect for existing users (besides having to hand over the cells too) as we don't expect anyone importing them manually.
  • We can keep the ControlWrapper for the InputControlRenderer so that anyone who imported the ControlWrapper can still use it
  • If users have existing custom renderers, they will continue to work without issues, even if not using the cell approach.

I would just avoid introducing the new control-wrapper injection mechanism as a new additional way of customizing as it's no longer needed. If you have existing custom renderers using the control-wrapper and you would like to use your own customized one, then you can simply use your own implementation of control-wrapper for them. Then you register an additional custom InputControlWrapper using your customized control-wrapper for all the off-the-shelf use cases you didn't customize before.

And yes, if you give the GO, then I would continue to work on it.

Please go ahead, we're looking forward to this feature 👍 Let us know if you need any support or have questions.

@davewwww davewwww marked this pull request as draft February 15, 2024 09:25
@sdirix
Copy link
Member

sdirix commented Feb 19, 2024

@davewwww Let me know once I shall take a look again 👍

@davewwww
Copy link
Contributor Author

davewwww commented Feb 19, 2024

there is currently a error at the building that i wanted to investigate. but i don't really understand it, maybe you have an idea.

Error: [@vue/compiler-sfc] No fs option provided to `compileScript` in non-Node environment. File system access is required for resolving imported types.

Besides that, all cells are converted and you can have a look at it. especially the time & datetime cells.

@davewwww
Copy link
Contributor Author

davewwww commented Mar 6, 2024

@sdirix What do you think about my proposal? I would like to contribute more cells & renderers for vue vanilla .

@sdirix
Copy link
Member

sdirix commented Mar 6, 2024

Hi @davewwww, we had less resources than usual in the last weeks which is why I did not have time yet to look at the PR again. I will do so as soon as possible, probably within a week.

If possible it would be great if you could make sure that the build is green. Then if the code is fine, we can immediately merge. Edit: Just saw that you mentioned the error already above. I will take a look when I review the PR 👍

Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

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

I had a look through the sources and commented what stuck out to me. Generally speaking this is good work and I love to see this merged in the near future ;)

packages/vue-vanilla/dev/components/App.vue Outdated Show resolved Hide resolved
packages/vue-vanilla/src/cells/BooleanCell.vue Outdated Show resolved Hide resolved
packages/vue-vanilla/src/cells/DateTimeCell.vue Outdated Show resolved Hide resolved
packages/vue-vanilla/src/controls/InputControlRenderer.vue Outdated Show resolved Hide resolved
@sdirix
Copy link
Member

sdirix commented Mar 11, 2024

there is currently a error at the building that i wanted to investigate. but i don't really understand it, maybe you have an idea.

Error: [@vue/compiler-sfc] No fs option provided to `compileScript` in non-Node environment. File system access is required for resolving imported types.

Besides that, all cells are converted and you can have a look at it. especially the time & datetime cells.

This error likely comes from the type-based defineProps generation you are trying to use (i.e. const props = defineProps<CellProps>();). It seems it's not so stable of a feature yet as I found multiple unresolved error reports of people running into problems with that. My suggestion would be to go back to the regular prop definitions, as we use them the other Vue components, like here.

@sdirix
Copy link
Member

sdirix commented Apr 15, 2024

Update: I will re-review this PR again this week

@sdirix
Copy link
Member

sdirix commented Apr 22, 2024

I like the cells but we need to fix the build errors. I started refactoring the cells but did run out of time. I think we could try not using the setup script but declaring them like we do the regular components. Then I would remove the tester from each .vue file and declare them in a separate file. The combined tester in the .vue files lead to all kind of errors in the past anyway with Vite.

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.

2 participants