import { computed } from '@ember/object';
import Component from '@ember/component';
import layout from '../templates/components/star-rating';

export default Component.extend({
  tagName: 'div',
  classNames: ['rating-panel'],

  layout: layout,

  rating:     0,
  maxRating:  5,
  item:       null,
  "on-click": null,

  fullClassNames: 'glyphicon glyphicon-star',
  emptyClassNames: 'glyphicon glyphicon-star-empty',

  stars: computed('rating', 'maxRating', function() {
    var rating = Math.round(this.get('rating'));
    var fullStars = this.starRange(1, rating, 'full');
    var emptyStars = this.starRange(rating + 1, this.get('maxRating'), 'empty');
    return fullStars.concat(emptyStars);
  }),

  starRange: function(start, end, type) {
    var starsData = [];
    for (var i = start; i <= end; i++) {
      starsData.push({ rating: i, full: type === 'full' });
    }
    return starsData;
  },

  actions: {
    setRating: function(newRating) {
      var actionType = typeof this.attrs['on-click'];
      if (actionType === 'function') {
        this.attrs['on-click']({
          item: this.get('item'),
          rating: newRating
        });
      } else {
        this.sendAction('on-click', {
          item: this.get('item'),
          rating: newRating
        });
      }
    }
  }
});

@@ -469,24 +469,26 @@
 ion() %7B%0A    
+  
 var rating =
@@ -492,19 +492,8 @@
 g = 
-Math.round(
 this
@@ -510,261 +510,77 @@
 ng')
-)
 ;%0A    
-var fullStars = this.starRange(1, rating, 'full');%0A    var emptyStars = this.starRange(rating + 1, this.get('maxRating'), 'empty');%0A    return fullStars.concat(emptyStars);%0A  %7D),%0A%0A  starRange: function(start, end, type) %7B%0A    var starsData
+  var end = this.get('maxRating')%0A      var starsArray
  = %5B%5D;%0A
+  
     
@@ -596,23 +596,19 @@
 i = 
-start
+0
 ; i %3C
-=
  end
+ 
 ; i+
@@ -618,25 +618,28 @@
 %7B%0A      
+ 
+ 
 stars
-Data
+Array
 .push(%7B 
@@ -651,16 +651,18 @@
 g: i
++1
 , full: 
 type
@@ -661,23 +661,18 @@
 ll: 
-type === 'full'
+i %3C rating
  %7D);
@@ -672,26 +672,30 @@
 ing %7D);%0A    
-%7D%0A
+  %7D%0A  
     return s
@@ -702,17 +702,21 @@
 tars
-Data
+Array
 ;%0A  
+ 
-%7D
+ %7D)
 ,%0A%0A 

Simplify the stars computed property