-
-
Notifications
You must be signed in to change notification settings - Fork 114
Remove key and keysrc when no dataSources #458
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
Conversation
|
Perhaps we should lift the dereference function from editor and add it to a utility in streambed then we can extend it with impunity to fit the streambed use cases? When will dataSources be an empty object? What happens in the case below? dataSources = {
a: [1,2,3]
}
data = [{xsrc: 'b', x: [1,1,1], ysrc: 'a', y: [2,2,2]}]
dereference(data, dataSources) |
|
In streambed, dataSources are an empty object when none of the grids have a used column (all columns are empty). Yeah I think that instead of looking for an empty dataSources object, I should be looking if data is defined, if it isn't, then delete the keys. maybe even just: Would there be a situation where data is not an array but we don't want to delete the key from the parent? |
Not 100% sure. I don't think we should be too prescriptive here. What about checking for key existence instead of the data type of the dataSource value? Hmmm if we delete the Also if we put deletion into dereference we can't pass in partial dataSources. I remember relying on that behaviour before. We could put this deletion behind an option flag or make a new function like |
yeah, that is better. We've spoken briefly with Nic about the possibility of loading in json templates of a figure, with srcs instead of values, and I think its a good idea, so true, removing srcs is maybe not what we'd like to do.
I think that's reasonable, I'm going to do that. Thanks! |
|
ok @bpostlethwaite I adjusted it |
src/lib/dereference.js
Outdated
| const SRC_ATTR_PATTERN = /src$/; | ||
|
|
||
| export default function dereference(container, dataSources) { | ||
| export default function dereference(container, dataSources, deleteKeys) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer this to be a config field so we can add arbitrary functionality later on without needing to mess with positional parameters
dereference(container, dataSources, config = {})
bpostlethwaite
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok looks good! 💃
c7b3cfd to
e5886e2
Compare
@bpostlethwaite would you 💃 ?
This adjusts the dereferencing function so as to remove the parent[key] and parent[keysrc] from dereferenced object, if dataSources is an empty object.
It fixes the case in streambed where the plot keeps its data, even if the column referenced in it has been removed.