ember-m3 icon indicating copy to clipboard operation
ember-m3 copied to clipboard

`changedAttributes()` on projection should filter out non-whitelisted properties

Open dnachev opened this issue 6 years ago • 0 comments

projectionA.set('property', value);
projectionB.changedProperties(); // is `property` white-listed?
// where projectionA and projectionB have common base model

For consistency, projectionB should observe the change from projectionA only if property is white-listed by the schema.

This is mostly easy to be done except in case of a nested model, which is not materialized yet. E.g.:

bookPreview.set('author.name', newAuthorName);
bookDetails.changedAttributes();
// cannot determine whether `name` property of the nested `author` model is white-listed or not,
// because the code hasn't called `bookDetails.get('author')` which would determine the correct
// type of `author` in the context of `bookDetails`

An overall approach to fixing the problem would be:

  • pass in a callback to changedAttributes(), which will be called for each nested model, e.g. function callback(key, childModelData)
  • in the callback, for each childModelData determine the exact projection to be used and correctly determine the list white-listed attributes

dnachev avatar May 09 '18 00:05 dnachev