rodekruis / shelter-database

MIT License
9 stars 5 forks source link

Property API #3

Closed mjvanderveen closed 8 years ago

mjvanderveen commented 8 years ago

Hi @cedricbonhomme,

There seems to be in issue in the old code with adding a new property, and after that updating the value of that property. When a new property is added, the property_id is returned and is used to set the value-id in the edit.html. However, this is the wrong id. You can test is on shelter-database.org by creating a new shelter, and then first set the latitude and then afterwards change that same latitude field. The Value API will throw a not-found error.

cedricbonhomme commented 8 years ago

hello, yes I see what you are talking about. I just tested on your example (http://shelter-database.org/shelter/edit/124/General-Information). I can try to fix if you want. I'll keep you up to date.

cedricbonhomme commented 8 years ago

The problem is here: https://github.com/rodekruis/shelter-database/blob/master/src/web/static/js/edit-shelter.js#L41

As you said, this is not the good id. The id should be something like result.values[0].id. Since we want the id of the new value associated to this property. the bug is that the value of a property is then used to call the /api/value endpoint of the API.