Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having to expose the content property of relationships with computed properties. #3911

Closed
arenoir opened this issue Nov 7, 2015 · 3 comments

Comments

@arenoir
Copy link
Contributor

arenoir commented Nov 7, 2015

All my computed properties that interact with relationships are broken in ember-2.1 - 2.2 with ember-data 2.0 - 2.2

For example:

//models/invoice.js
export default DS.Model({
  lines: DS.hasMany('invoice-line')
});
​
//models/invoice-line.js
export default DS.Model({
  amount: DS.attr('number')
});
​
//components/invoice.js
export default Ember.Component({
  total: computed('invoice.lines.@each.amount', function() {
    this.get('invoice.lines').reduce((value, item) => {
      return value += item.get('amount');
    }, 0);
  }),
});

That computed property total should work but does not. The workaround is to expose the content property of the invoice.lines relationship.

ie: 'invoice.lines.@each.amount' to 'invoice.lines.content.@each.amount'

I however do not want to do that as this is "obviously?" a bug.

I am unsure if this is a bug with ember-data's RecordArray Promise implementation or ember's bug observing arrays.

@jcope2013
Copy link
Contributor

related? emberjs/ember.js#12475

@stefanpenner
Copy link
Member

@jcope2013 I believe this is, at least partially, the source of at least some of the issues reported on emberjs/ember.js#12475

@arenoir
Copy link
Contributor Author

arenoir commented Feb 10, 2016

Fixed in ember 2.2.3 by emberjs/ember.js#12908

@arenoir arenoir closed this as completed Feb 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants