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

Array: reordering is buggy #9

Closed
huyl opened this issue Sep 13, 2012 · 4 comments
Closed

Array: reordering is buggy #9

huyl opened this issue Sep 13, 2012 · 4 comments
Labels

Comments

@huyl
Copy link

huyl commented Sep 13, 2012

In playground/?example=fields-array if you add a top-level element and then re-order, one item disappears.

Then if you add second-level elements and just keep playing around, you get top-level elements at the second level.

Etc.

tidoust pushed a commit that referenced this issue Sep 13, 2012
The commit fixes the reordering issues, but values in nested array
are still lost during reordering for the time being.
@huyl
Copy link
Author

huyl commented Sep 13, 2012

@tidoust Thanks a lot!

Any time estimate on fixing "values in nested array
are still lost during reordering for the time being"?
It's a showstopper for me right now.

Thanks!

@tidoust
Copy link
Contributor

tidoust commented Sep 18, 2012

@huyl, hopefully I'll be able to find some time this week to fix the remaining issue.

The main bug to fix lies in the getPreviousNumberOfItems function. It should also receive the current property that the code is interesting in on top of the path that leads to that property. Without that parameter, the function simply returns 0, causing all nested values to disappear.

@huyl
Copy link
Author

huyl commented Sep 18, 2012

I've been looking at AngularJS and I think it could be a great framework for implementing jsonform in such a way that the generated values JSON will always be kept in sync.

Check out this demo with sortable drag-n-drop elements in an arbitrarily deep tree:

http://jsfiddle.net/huyz/x8Y2F/3/

Note that the underlying JSON will be kept in sync at all times, which is something that I need for my application (because the generated JSON is actually a form specification which I need to preview in real-time to implement a sort of wysiwig UI)

tidoust added a commit that referenced this issue Sep 24, 2012
The "getPreviousNumberOfItems" function uses "truncateToArrayDepth"
to shorten the path to a key to the right depth level and then
compute the number of items at the level in previously submitted
values.

That second function did not return all the properties up to the
next array level, meaning the value checked in previously submitted
values could well be an object and not an array. For instance,
given a path:
 "foo.bar[].baz.stuff.blah[].thing"
the function used to return "foo.bar[]" for a depth of 1. It now
returns:
 "foo.bar[].baz.stuff.blah"

This should fix issue #9
@tidoust
Copy link
Contributor

tidoust commented Sep 24, 2012

@huyl, closing the issue as I fixed the buggy getPreviousNumberOfItems function in last commit. Nested arrays now seem to work well in the playground. I may have missed some corner case though, let me know if something's still not working as expected.

@tidoust tidoust closed this as completed Sep 24, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants