vendredi 12 mai 2017

How to detect and save relation change in Ember 2.13.0?

I have documents list. Every document has client attribute defined by belongsTo.

When user change client in one of documents i want to show in the counter how many documents are changed. And when user decide he will press "publish" button which will save documents client changes to api.

DS.Model in ember 2.13 has parameters (http://ift.tt/2ptRHlH):

hasDirtyAttributes, dirtyType

Both of them does not react on belongsTo/HasMany changes by Ember design. I saw many answers to this topic, but I do not see any isDirty() method for model in 2.13 documentation, nor any .send("becomeDirty") method to manually set document model in dirty status ? I also saw several plugins/mixins for older Ember versions.

But my question is, how do Ember creators "advise/advice/best practice" to deal with this. Is there some basic way/manual solution that does not require any third party addon ? Like with maybe onchange observer for every relation in model?, or computed property with @each.dirtyType for child related models (or even set children will not be flagged as dirty itself?) ?

What is sandbox solution for this in Ember 2.13 ?




Aucun commentaire:

Enregistrer un commentaire