Skip to content

feat: include nodePath as argument to template functions in TreeView nodes #48

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

Merged
merged 28 commits into from
Apr 21, 2021

Conversation

joaoassisb
Copy link
Contributor

No description provided.

@assisrafael
Copy link
Owner

@joaoassisb after analysing this PR I decided to revert your previous commit. I think you should work more in the proposal and describe what use cases this feature will enable.

João Vitor added 2 commits April 20, 2021 14:00
@joaoassisb
Copy link
Contributor Author

joaoassisb commented Apr 20, 2021

@joaoassisb after analysing this PR I decided to revert your previous commit. I think you should work more in the proposal and describe what use cases this feature will enable.

@assisrafael the use case is to simplify the usage of TreeViews with Forms. At the moment, the template function passes only the item,index and parentItem, making a lot harder to handle paths and possible changes.

I updated the TreeViewExample to illustrate better my use case.
image
Now I can use a FormInput using the relativePath in the name of the input, and the changes will automatically updates the initial nodes structure.

image

@assisrafael
Copy link
Owner

assisrafael commented Apr 21, 2021

@assisrafael the use case is to simplify the usage of TreeViews with Forms. At the moment, the template function passes only the item,index and parentItem, making a lot harder to handle paths and possible changes.

Your use case make sense.
Regarding the PR content, I think it would be better with the prop would be called nodePath instead of relativePath.

@@ -32,6 +32,7 @@ function TreeNodes({ childrenPath, depth, draggable, nodes, parentNode, template
childrenPath={childrenPath}
depth={depth}
draggable={draggable}
relativePath={relativePath ? `${relativePath}[${index}]` : `[${index}]`}
Copy link
Owner

Choose a reason for hiding this comment

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

Instead of using a ternary here you could set "" as the default value for the prop

@joaoassisb joaoassisb changed the title fix: corrects the relative path prop in the base nodes feat: include nodePath as argument to template functions in TreeView nodes Apr 21, 2021
@joaoassisb joaoassisb requested a review from assisrafael April 21, 2021 15:17
@assisrafael assisrafael merged commit 1beb583 into assisrafael:master Apr 21, 2021
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