ember-data-model-fragments icon indicating copy to clipboard operation
ember-data-model-fragments copied to clipboard

updating a fragment's attribute in a form doesn't set the fragment as dirty

Open Leooo opened this issue 5 years ago • 3 comments

Ember | 3.4.8 Ember Data | 3.5.2 jQuery | 2.1.4 Model Fragments | 4.0.0

//models/appointment.js
export default Model.extend({
  telephoneNumber: MF.fragment('phone-type')
});
//models/phone-type.js
export default MF.Fragment.extend({
  type: DS.attr('string'),
  number: DS.attr('string')
});

(existing appointment)

appointment.changedAttributes(); // {}
appointment.set('telephoneNumber.number', '07777777777');
appointment.changedAttributes(); // {}
appointment.telephoneNumber.changedAttributes(); // {number: Array(2)}

So appointment.changedAttributes() is not updated, which prevents the telephoneNumber to be serialized (at least when using ember-data-change-tracker, but I think it's an ember-data-model-fragments problem).

Anyone else seeing this? Can try to create a jsfiddle or test if needed.

Leooo avatar Oct 18 '19 11:10 Leooo

someone needs to add https://ember-twiddle.com/ on top of SEO for "Ember jsfiddle"

Leooo avatar Oct 18 '19 12:10 Leooo

so on https://ember-twiddle.com/499e21ed033ff8270dcd966904b02c4c?openFiles=routes.application.js%2C, things work.. Can't reproduce on ember-twiddle then :(

Leooo avatar Oct 18 '19 12:10 Leooo

Not ideal, but you can manually set it dirty:

send('becomeDirty');

hew avatar May 19 '23 22:05 hew