This page is part of a static HTML representation of TriTarget.org at https://tritarget.org

array-decorator.js

Sukima 3rd March 2021 at 8:41pm
// app/decorators/array.js
import Ember from 'ember';
import getDecorator from '../utils/get-decorator';
const { ArrayProxy } = Ember;

export default ArrayProxy.extend({
  decoratedContent: null,

  arrangedContent: computed('content.[]', {
    get() {
      let lookupName = this.get('itemDecorator');
      let Decorator = getDecorator(this, lookupName);
      let baseContent = this.get('content') || [];
      return baseContent.map((content, index) => {
        return Decorator.create({ content, index });
      });
    }
  })
});