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

[Discussion]Utility method to create json diff commands #51

Closed
vhemery opened this issue Jun 10, 2021 · 5 comments
Closed

[Discussion]Utility method to create json diff commands #51

vhemery opened this issue Jun 10, 2021 · 5 comments
Labels
question Further information is requested

Comments

@vhemery
Copy link
Contributor

vhemery commented Jun 10, 2021

In my application, I ended up with some code quite similar to
https://github.com/eclipse-emfcloud/coffee-editor/blob/573830104d9ad541568e6b46f8b3359e8dd0948d/web/coffee-editor-extension/src/browser/coffee-tree/coffee-tree-editor-widget.tsx#L232
(except I use the newer command API, have more comments and minor differences)

I guess any implementation using json forms will have to, at some point, implement such a method to align the modified json with the original by building and executing commands.
Which makes me wonder : shouldn't we provide a utility method wich builds on its own all the commands, rather than letting each user re-implement this ?

I'm not 100% sure all the possible cases are correctly handled here... so maybe there is extra work to perform to make such a utility method. Also, it would probably nice to have an extra configuration attribute to either build the commands for modifications directly on the concerned element or to deep-check for differences in element's children.

Does anyone have extra considerations to bring on this matter ?

@vhemery
Copy link
Contributor Author

vhemery commented Jun 10, 2021

Or should we consider instead a special json diff command wich aligns everything directly on the server side ?

@eneufeld
Copy link
Contributor

Hi @vhemery ,
If I understand the reason for your question correctly, you have a usecase of jsonforms without the tree editor that currently has the transformation code to create a command from the change.
For this case it makes sense as you suggest to extract the code (and of course enhance it).
I don't think that this should be handled on the server.
So I'm for a utility function on the client.
@planger @ndoschek any thoughts?

@planger
Copy link
Contributor

planger commented Jun 15, 2021

Right, I agree that a client-side utility/library for simplifying the mapping from form updates to model server commands would be great -- otherwise this code will get replicated over and over again. However, I think this utility needs to support custom commands too, as this tends to get a popular use case. So clients should be able to specify custom commands for particular changes.
Anyway, I think we should also wait for the opinion of @ndoschek (she'll hopefully be able to get back to that next week).

@ndoschek
Copy link
Contributor

Thanks for bringing that up @vhemery !
Yes, I also agree that a client-side library for such use cases is be the best option here.
Also I think it would be great to extract a dedicated modelserver-theia-tree-editor package.
I opened a separate issue in the theia-tree-editor repository for that: eclipse-emfcloud/theia-tree-editor#34

@martin-fleck-at
Copy link
Contributor

I will close this issue as this should be part of the new package that is to be created specifically for the theia tree editor. Maybe any more concerns or comments can be discussed there: eclipse-emfcloud/theia-tree-editor#34

@martin-fleck-at martin-fleck-at added the question Further information is requested label Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants