cms/app-client/app/helpers/is-indeterminate.js
author Chloe Laisne <chloe.laisne@gmail.com>
Wed, 20 Jul 2016 21:08:31 +0200
changeset 245 c9dd78a43b07
parent 244 d7ab83ecf737
child 392 4fbe94af93e8
permissions -rw-r--r--
Transcript model and erializer Transcript component Update Ember-cli to 2.6.3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
244
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     1
import Ember from 'ember';
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     2
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     3
export function isIndeterminate(params) {
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     4
    var dates = params[0];
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     5
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     6
    var decade = [];
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     7
    var next = params[1] + 10;
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     8
    while(params[1] < next) {
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     9
        decade.push(params[1]);
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    10
        params[1] ++;
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    11
    }
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    12
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    13
    var filter = decade.filter(function(date){ return dates.indexOf(date) > -1; });
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    14
    if(filter.length !== decade.length && filter.length) {
245
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 244
diff changeset
    15
        return true;
244
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    16
    }
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    17
    return false;
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    18
}
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    19
d7ab83ecf737 Checked/indeterminate states with /langues endpoint checkboxes
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    20
export default Ember.Helper.helper(isIndeterminate);