{"action":"created","issue":{"url":"https://api.github.com/repos/CartoDB/cartodb/issues/2924","labels_url":"https://api.github.com/repos/CartoDB/cartodb/issues/2924/labels{/name}","comments_url":"https://api.github.com/repos/CartoDB/cartodb/issues/2924/comments","events_url":"https://api.github.com/repos/CartoDB/cartodb/issues/2924/events","html_url":"https://github.com/CartoDB/cartodb/pull/2924","id":64520612,"number":2924,"title":"Fix image infowindows","user":{"login":"alonsogarciapablo","id":390398,"avatar_url":"https://avatars.githubusercontent.com/u/390398?v=3","gravatar_id":"","url":"https://api.github.com/users/alonsogarciapablo","html_url":"https://github.com/alonsogarciapablo","followers_url":"https://api.github.com/users/alonsogarciapablo/followers","following_url":"https://api.github.com/users/alonsogarciapablo/following{/other_user}","gists_url":"https://api.github.com/users/alonsogarciapablo/gists{/gist_id}","starred_url":"https://api.github.com/users/alonsogarciapablo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alonsogarciapablo/subscriptions","organizations_url":"https://api.github.com/users/alonsogarciapablo/orgs","repos_url":"https://api.github.com/users/alonsogarciapablo/repos","events_url":"https://api.github.com/users/alonsogarciapablo/events{/privacy}","received_events_url":"https://api.github.com/users/alonsogarciapablo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-03-26T12:57:32Z","updated_at":"2015-03-27T11:56:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/CartoDB/cartodb/pulls/2924","html_url":"https://github.com/CartoDB/cartodb/pull/2924","diff_url":"https://github.com/CartoDB/cartodb/pull/2924.diff","patch_url":"https://github.com/CartoDB/cartodb/pull/2924.patch"},"body":"(opened for discussion)\r\n\r\nThis PR fixes #1970. The way I have been able to reproduce the problem was:\r\n\r\n1. Open a visualization where you have some image field.\r\n2. Open the infowindow pane and disable all fields.\r\n3. Reorder some fields and make sure that the field with the image url is at the top.\r\n4. Select all fields using the \"All\" switch.\r\n\r\nThe Infowindow will say that the image url is invalid, even if you have a valid url and the field with the image is at the top. The reason is that we're getting the columns from the table and adding them as fields in the wrong order. More specifically, we're just iterating through the names of the columns, without considering the position they are currently in.\r\n\r\nI've introduced [this method](https://github.com/CartoDB/cartodb/compare/1970-image-infowindows?expand=1#diff-d643227951c49f2a9a5d811b3fed2f0fR173) that gets the column names from the view, which is the only place where the order is right. But **it doesn't feel right to ask the view for that**.\r\n\r\n@xavijam @javisantana @viddo @javierarce Any ideas on how to do it better? "},"comment":{"url":"https://api.github.com/repos/CartoDB/cartodb/issues/comments/86912806","html_url":"https://github.com/CartoDB/cartodb/pull/2924#issuecomment-86912806","issue_url":"https://api.github.com/repos/CartoDB/cartodb/issues/2924","id":86912806,"user":{"login":"alonsogarciapablo","id":390398,"avatar_url":"https://avatars.githubusercontent.com/u/390398?v=3","gravatar_id":"","url":"https://api.github.com/users/alonsogarciapablo","html_url":"https://github.com/alonsogarciapablo","followers_url":"https://api.github.com/users/alonsogarciapablo/followers","following_url":"https://api.github.com/users/alonsogarciapablo/following{/other_user}","gists_url":"https://api.github.com/users/alonsogarciapablo/gists{/gist_id}","starred_url":"https://api.github.com/users/alonsogarciapablo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alonsogarciapablo/subscriptions","organizations_url":"https://api.github.com/users/alonsogarciapablo/orgs","repos_url":"https://api.github.com/users/alonsogarciapablo/repos","events_url":"https://api.github.com/users/alonsogarciapablo/events{/privacy}","received_events_url":"https://api.github.com/users/alonsogarciapablo/received_events","type":"User","site_admin":false},"created_at":"2015-03-27T11:56:04Z","updated_at":"2015-03-27T11:56:04Z","body":"@xavijam @javisantana please take a look at [this commit](https://github.com/CartoDB/cartodb/commit/7cc4393c07c13dd66f2ef4e688dd5077a94c0f08). I'm now using an internal Backbone.Collection to keep track of how the fields are ordered in the view. When the panel is rendered, we store how things are ordered, and we update the order whenever there's a drag and drop. If this is not \"The Backbone Way\", I'm happy to change it again... thx"}}