-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
Side effect of custom fields formatters in Identify #650
Comments
I see the issue, and the thought had crossed my mind earlier. I agree it could definitely be an undesirable side-effects. Off the top of my head, one solution I see is to build a default function getContentFormatter(args){
return function(attributes){
// getFormattedAttributes will return the attributes and apply any formatters
// it can also remove properties that have `include: false` or we could implement
formattedAttributes = getFormattedAttributes(lang.clone(attributes), args.fieldInfos);
//getTableHtml will iterate through the attributes and create table html
return getTableHtml(formattedAttributes);
}
} and then
|
I don't think there's really a great solution to this that doesn't result in a lot of redundancy. The solution I mentioned above wouldn't work well since we'd have to replicate the functionality of the popup parts when there is no content function (title, fieldInfos, attachments, etc...) Another solution would be to put the original cloned attributes in an extra property like Perhaps the best solution is to warn people, and if they need the original value, create instead a virtual field with a formatter and exclude the other field from the identify popup. |
@roemhildtg I agree. Using virtual fields with a formatter is how I work around this and it meets all my requirements so far. I think some info in the docs alerting folks to the potential pitfalls is the way to go. |
@roemhildtg I think we may want to reconsider the approach we worked on for #618. Changing the attributes of the original feature is liekly not a desirable outcome. For example, if you have code elsewhere that does this:
you get a result that you might not expect. What is returned will have modified attributes based on the formatters, not those of the original feature.
I ran into this in a current application. Capturing it here for review and discussion. No immediate solution comes to mind.
The text was updated successfully, but these errors were encountered: