I’m trying to create some logic in one of our Smart Views. For context this is an Ember.js smart view that uses Leaflet to draw out multi polygons on a map via JSON data. The polygons are drawn just fine, I simply want to update the JSON data that stores the coordinates on a marker drag event. I looked through the documentation here:
I found ways of fetching, creating and deleting records but not a way to update a record within the component and save. How do we go about doing that?
I had marked this topic solved but I ran into a problem with the same topic again.I am having trouble saving changes to a JSON column through an Ember action. Basically we are displaying multipolygons for country areas and we want to add new vertices through a button. However when I push to this JSON array and save it doesn’t seem to stick. (Please ignore the random variables it’s just a test ). Here’s the code:
And here is the console output showing the array’s length that I push into. You can see that it doesn’t save properly:
I was able to use the same logic to update and successfully save other fields but not this one.
I don’t know if it is the cause of your issue, but there are several problems with your code:
You are creating a promise with Promise.all waits for all promises created in map, but if you take a look at the callback of the map function, they don’t return the promise returned by save and they don’t even wait for their completion
You passed the result of console.log to then instead of a callback that will execute a console.log
Thank you. I fixed the problems you mentioned but unfortunately the error persists. The array doesn’t get saved and will print out the same length after await record.save(). Any idea why this might be the case?
Yes indeed the json field type is the only one I have an issue saving with. For now I managed to implement a workaround by async marker events with Leaflet. Thank you for this workaround as well. It was definitely driving me crazy.