# HG changeset patch # User ymh # Date 1481560674 -3600 # Node ID 8fe093d88efe96a2a501063d24d9ed8dc8d91ead # Parent 762fc0eb494689674bde51817f400dcba033374e correct min, max calculations when theme list change diff -r 762fc0eb4946 -r 8fe093d88efe cms/app-client/app/components/sorting-component.js --- a/cms/app-client/app/components/sorting-component.js Fri Dec 09 11:41:15 2016 +0100 +++ b/cms/app-client/app/components/sorting-component.js Mon Dec 12 17:37:54 2016 +0100 @@ -9,8 +9,8 @@ isAlphabetical: true, isPopularity: Ember.computed('isAlphabetical', function() { return !this.get('isAlphabetical'); }), - minimum: Ember.computed('themes', function() { return Math.min(...this.themes.mapBy('count')); }), - maximum: Ember.computed('themes', function() { return Math.max(...this.themes.mapBy('count')); }), + minimum: Ember.computed('themes.[]', function() { return Math.min(...this.get('themes').mapBy('count')); }), + maximum: Ember.computed('themes.[]', function() { return Math.max(...this.get('themes').mapBy('count')); }), more: true, diff -r 762fc0eb4946 -r 8fe093d88efe cms/app-client/app/helpers/popularity.js --- a/cms/app-client/app/helpers/popularity.js Fri Dec 09 11:41:15 2016 +0100 +++ b/cms/app-client/app/helpers/popularity.js Mon Dec 12 17:37:54 2016 +0100 @@ -2,12 +2,9 @@ export function popularity([target, minimum, maximum]) { var classname = ['not-popular', 'popular', 'very-popular']; - var interval = ( maximum - minimum ) / classname.length; + var interval = ( maximum + 1 - minimum ) / classname.length; - var i = 0; - while( target > minimum + ( interval * ( i + 1 ) ) ) { - i ++; - } + var i = Math.floor((target-minimum)/interval); return classname[i]; }