angular.module('starter.filters', [])

.filter('showMine', function() {

    return function(input, customer) {
        var out = [];
        angular.forEach(input, function(item) {

            if (item.description && item.customerId === customer.id) {

                out.push(item)
            }

        });

        return out;
    }

})


.filter('samplesOnly', function() {

    return function(customers, samples) {

        var out = [];
        var samplelist = [];

        angular.forEach(samples, function(sample) {

            if (sample) {
                if (samplelist.indexOf(sample.customerId) === -1) {
                    samplelist.push(sample.customerId);
                }
            }

        });

        angular.forEach(customers, function(customer) {

            if (customer.name && samples) {

                if (samplelist.indexOf(customer.$id) === -1) {
                    //do not list
                } else {

                    out.push(customer)
                }
            }
        });

        return out;
    }

});