diff --git a/helper/labelGenerator.js b/helper/labelGenerator.js index ffc5bf3f..e772ceb9 100644 --- a/helper/labelGenerator.js +++ b/helper/labelGenerator.js @@ -1,35 +1,59 @@ var _ = require('lodash'), - check = require('check-types'), - schemas = require('./labelSchema.json'); + schemas = require('./labelSchema'); module.exports = function( record ){ + var schema = getSchema(record.country_a); - var labelParts = [ record.name.default ]; + var labelParts = getInitialLabel(record); + + for (var key in schema) { + var valueFunction = schema[key]; + + labelParts = valueFunction(record, labelParts); - var schema = schemas.default; - - if (record.country_a && record.country_a.length && schemas[record.country_a]) { - schema = schemas[record.country_a]; } - - var buildOutput = function(parts, schemaArr, record) { - for (var i=0; i