hhff/spree-ember

View on GitHub
packages/core/app/models/taxonomy.js

Summary

Maintainability
A
0 mins
Test Coverage
import DS from 'ember-data';

export default DS.Model.extend({
  name: DS.attr('string'),
  permalink: DS.attr('string'),
  prettyName: DS.attr('string'),
  taxons: DS.hasMany('taxon'),

  root: function() {
    return this.get('taxons').findBy('parentId', undefined);
  }.property('taxons'),

  taxonsExcludingRoot: function() {
    return this.get('taxons').filterBy('parentId');
  }.property('taxons')
});