all files / addon/helpers/ rating-class-helper.js

0% Statements 0/28
0% Branches 0/19
0% Functions 0/1
0% Lines 0/28
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49                                                                                                 
import Helper from '@ember/component/helper';
import { htmlSafe } from '@ember/template';
 
export default Helper.extend({
 
  compute(params) {
    let item              = params[0];
    let classes           = params[1];
    let style             = params[2];
    let disabled          = params[3];
    let color             = params[4];
    let lowThreshold      = params[5];
    let highThreshold     = params[6];
    let max               = params[7];
    let colors            = params[8];
    let currentValue      = params[9];
    let value             = params[10];
    let disabledVoidColor = params[11];
    // let color         = "rgb(247, 186, 42)";
 
    if (style) {
      if (colors.length === 3) {
        if (currentValue <= lowThreshold) {
          color = colors[0];
        } else if (currentValue <= highThreshold) {
          color = colors[1];
        } else {
          color = colors[2];
        }
        return htmlSafe(`color: ${color};`)
      }
      if (classes[item - 1] === "el-icon-star-on" && (!disabled || item < value)) {
        return htmlSafe(`color: ${color};`)
      } else if (item > value && disabled) {
         return htmlSafe(`color: ${disabledVoidColor};`)
      }
      return;
    }
 
    if (highThreshold - 1 === max) {
      return classes[item - 1] + ' hover';
    }else{
      return classes[item - 1];
    }
 
  }
});