fenix-ui-converter
Advanced tools
Comparing version 1.0.0-beta.6 to 1.0.0-beta.7
@@ -1,2 +0,2 @@ | ||
define(["jquery","underscore","loglevel","handlebars"],function(e,t,r,o){return function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return e[o].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){var o,n;o=[r(2),r(3),r(4),r(5)],n=function(e,t,r,o){"use strict";function n(){return this}return n.prototype.toD3P=function(o,n){var i={},u=this;return t.each(n.values,function(t,n){var a=u.cleanArray(t),c=o[n]||{},s=c.format||{},l=s.items||n;a.length>0?i[l]=e.extend(!0,{},u.compileFilter(n,a,o)):r.warn(n+" column excluded from FENIX conversion because it has no values")}),i},n.prototype.toFilter=function(o,n){var i={},u=this;return t.each(n.values,function(t,n){var a=u.cleanArray(t),c=o[n]||{},s=c.format||{},l=s.metadataAttribute;return l?void(a.length>0?i[l]=e.extend(!0,{},u.compileFilter(n,a,o)):r.warn(n+" column excluded from FENIX filter because it has no values")):void r.warn(n+" impossible to find format.metadataAttribute configuration")}),i},n.prototype.compileFilter=function(e,t,o){var n=o[e]||{},i=n.format||{},u=i.template,a=i.output||"codes";if(u)return this.compileTemplate(e,t,n,u);var c,s=i.dimension||e;switch(a.toLocaleLowerCase()){case"freetext":return this.createFreeTextFilter(e,t,n,s);case"codes":return c='{ "codes":[{"uid": "{{{uid}}}", "version": "{{version}}", "codes": [{{{codes}}}] } ]}',this.compileTemplate(e,t,n,s,c);case"time":return this.createTimeFilter(e,t,n,confkey);case"enumeration":return this.createEnumerationFilter(e,t,n,s);default:return r.warn(e+" not included in the result set. Missing format configuration."),{}}},n.prototype.compileTemplate=function(n,i,u,a,c){var s=e.extend(!0,u.cl,u.format,{codes:'"'+i.join('","')+'"'});if(c||r.error("Impossible to find '"+n+"' process template. Check your '"+n+"'.filter.process configuration."),!s.uid)return void r.error("Impossible to find '"+n+"' code list configuration for FENIX output format export.");var l=o.compile(c),f=JSON.parse(l(s)),p=f.codes;return t.each(p,function(e){e.version||delete e.version}),f},n.prototype.createTimeFilter=function(r,o,n,i){var u,a=[],c="object"==typeof o[0];if(c){var s=t.findWhere(o,{parent:"from"})||{},l=t.findWhere(o,{parent:"to"})||{},f={from:null,to:null};f.from=s.value,f.to=l.value,a.push(e.extend({},f))}else u=o.map(function(e){return parseInt(e,10)}).sort(function(e,t){return e-t}),t.each(u,function(e){a.push({from:e,to:e})});return{time:a}},n.prototype.createEnumerationFilter=function(e,t,r,o){return{enumeration:t}},n.prototype.createFreeTextFilter=function(e,t,r,o){return{text:t[0]}},n.prototype.cleanArray=function(e){for(var t=[],r=0;r<e.length;r++)e[r]&&t.push(e[r]);return t},new n}.apply(t,o),!(void 0!==n&&(e.exports=n))},function(t,r){t.exports=e},function(e,r){e.exports=t},function(e,t){e.exports=r},function(e,t){e.exports=o}])}); | ||
define(["jquery","underscore","loglevel","handlebars"],function(e,t,r,o){return function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return e[o].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){var o,n;o=[r(2),r(3),r(4),r(5)],n=function(e,t,r,o){"use strict";function n(){return this}return n.prototype.toD3P=function(o,n){var i={},u=this;return t.each(n.values,function(t,n){var a=u.cleanArray(t),c=o[n]||{},s=c.format||{},l=s.items||n;a.length>0?i[l]=e.extend(!0,{},u.compileFilter(n,a,o)):r.warn(n+" column excluded from FENIX conversion because it has no values")}),i},n.prototype.toFilter=function(o,n){var i={},u=this;return t.each(n.values,function(t,n){var a=u.cleanArray(t),c=o[n]||{},s=c.format||{},l=s.metadataAttribute;return l?void(a.length>0?i[l]=e.extend(!0,{},u.compileFilter(n,a,o)):r.warn(n+" column excluded from FENIX filter because it has no values")):void r.warn(n+" impossible to find format.metadataAttribute configuration")}),i},n.prototype.compileFilter=function(e,t,o){var n=o[e]||{},i=n.format||{},u=i.template,a=i.output||"codes";if(u)return this.compileTemplate(e,t,n,u);var c,s=i.dimension||e;switch(a.toLocaleLowerCase()){case"freetext":return this.createFreeTextFilter(e,t,n,s);case"codes":return c='{ "codes":[{"uid": "{{{uid}}}", "version": "{{version}}", "codes": [{{{codes}}}] } ]}',this.compileTemplate(e,t,n,s,c);case"time":return this.createTimeFilter(e,t,n,s);case"enumeration":return this.createEnumerationFilter(e,t,n,s);default:return r.warn(e+" not included in the result set. Missing format configuration."),{}}},n.prototype.compileTemplate=function(n,i,u,a,c){var s=e.extend(!0,u.cl,u.format,{codes:'"'+i.join('","')+'"'});if(c||r.error("Impossible to find '"+n+"' process template. Check your '"+n+"'.filter.process configuration."),!s.uid)return void r.error("Impossible to find '"+n+"' code list configuration for FENIX output format export.");var l=o.compile(c),f=JSON.parse(l(s)),p=f.codes;return t.each(p,function(e){e.version||delete e.version}),f},n.prototype.createTimeFilter=function(r,o,n,i){var u,a=[],c="object"==typeof o[0];if(c){var s=t.findWhere(o,{parent:"from"})||{},l=t.findWhere(o,{parent:"to"})||{},f={from:null,to:null};f.from=s.value,f.to=l.value,a.push(e.extend({},f))}else u=o.map(function(e){return parseInt(e,10)}).sort(function(e,t){return e-t}),t.each(u,function(e){a.push({from:e,to:e})});return{time:a}},n.prototype.createEnumerationFilter=function(e,t,r,o){return{enumeration:t}},n.prototype.createFreeTextFilter=function(e,t,r,o){return{text:t[0]}},n.prototype.cleanArray=function(e){for(var t=[],r=0;r<e.length;r++)e[r]&&t.push(e[r]);return t},new n}.apply(t,o),!(void 0!==n&&(e.exports=n))},function(t,r){t.exports=e},function(e,r){e.exports=t},function(e,t){e.exports=r},function(e,t){e.exports=o}])}); | ||
//# sourceMappingURL=fenix-ui-converter.min.js.map |
{ | ||
"name": "fenix-ui-converter", | ||
"version": "1.0.0-beta.6", | ||
"version": "1.0.0-beta.7", | ||
"description": "FENIX ui converter", | ||
@@ -5,0 +5,0 @@ "main": "dist/fenix-ui-converter.min.js", |
@@ -99,3 +99,3 @@ if (typeof define !== 'function') { | ||
return this.createTimeFilter(id, values, config, confkey); | ||
return this.createTimeFilter(id, values, config, key); | ||
break; | ||
@@ -102,0 +102,0 @@ |
@@ -5,4 +5,4 @@ { | ||
"version": "1.13.2", | ||
"hash": "0494ffe7ae23e2710b3e", | ||
"time": 253, | ||
"hash": "2517350b18241f0c7d08", | ||
"time": 246, | ||
"publicPath": "", | ||
@@ -18,3 +18,3 @@ "assetsByChunkName": { | ||
"name": "fenix-ui-converter.min.js", | ||
"size": 2975, | ||
"size": 2969, | ||
"chunks": [ | ||
@@ -30,3 +30,3 @@ 0 | ||
"name": "fenix-ui-converter.min.js.map", | ||
"size": 20781, | ||
"size": 20759, | ||
"chunks": [ | ||
@@ -48,3 +48,3 @@ 0 | ||
"extraAsync": false, | ||
"size": 5589, | ||
"size": 5585, | ||
"names": [ | ||
@@ -57,3 +57,3 @@ "app" | ||
], | ||
"hash": "92237a5721bb746f6fdb", | ||
"hash": "6a4c76fc60cb4599ec0e", | ||
"parents": [], | ||
@@ -92,3 +92,3 @@ "modules": [ | ||
"index2": 4, | ||
"size": 5393, | ||
"size": 5389, | ||
"cacheable": true, | ||
@@ -104,4 +104,4 @@ "built": true, | ||
"profile": { | ||
"factory": 12, | ||
"building": 35 | ||
"factory": 13, | ||
"building": 34 | ||
}, | ||
@@ -121,3 +121,3 @@ "failed": false, | ||
], | ||
"source": "if (typeof define !== 'function') {\n var define = require('amdefine')(module);\n}\n\ndefine([\n 'jquery',\n 'underscore',\n 'loglevel',\n 'handlebars'\n], function ($, _, log, Handlebars) {\n\n 'use strict';\n\n function Converter() {\n return this;\n }\n\n Converter.prototype.toD3P = function (items, values) {\n\n var filter = {},\n self = this;\n\n _.each(values.values, function (val, id) {\n\n var v = self.cleanArray(val),\n config = items[id] || {},\n formatConfig = config.format || {};\n\n var key = formatConfig.items || id;\n\n if (v.length > 0) {\n filter[key] = $.extend(true, {}, self.compileFilter(id, v, items));\n } else {\n log.warn(id + \" column excluded from FENIX conversion because it has no values\");\n }\n\n });\n\n return filter;\n };\n\n Converter.prototype.toFilter = function (items, values) {\n\n var filter = {},\n self = this;\n\n _.each(values.values, function (val, id) {\n\n var v = self.cleanArray(val),\n config = items[id] || {},\n formatConfig = config.format || {};\n\n var key = formatConfig.metadataAttribute;\n\n if (!key) {\n log.warn(id + \" impossible to find format.metadataAttribute configuration\");\n return;\n }\n\n if (v.length > 0) {\n filter[key] = $.extend(true, {}, self.compileFilter(id, v, items));\n } else {\n log.warn(id + \" column excluded from FENIX filter because it has no values\");\n }\n\n });\n\n return filter;\n };\n\n Converter.prototype.compileFilter = function (id, values, items) {\n\n var config = items[id] || {},\n formatConfig = config.format || {},\n template = formatConfig.template,\n output = formatConfig.output || \"codes\";\n\n if (template) {\n return this.compileTemplate(id, values, config, template);\n }\n\n var key = formatConfig.dimension || id,\n tmpl;\n\n switch (output.toLocaleLowerCase()) {\n case \"freetext\" :\n\n return this.createFreeTextFilter(id, values, config, key);\n\n break;\n case \"codes\" :\n\n tmpl = '{ \"codes\":[{\"uid\": \"{{{uid}}}\", \"version\": \"{{version}}\", \"codes\": [{{{codes}}}] } ]}';\n return this.compileTemplate(id, values, config, key, tmpl);\n\n break;\n case \"time\" :\n\n return this.createTimeFilter(id, values, config, confkey);\n break;\n\n case \"enumeration\" :\n\n return this.createEnumerationFilter(id, values, config, key);\n break;\n default :\n log.warn(id + \" not included in the result set. Missing format configuration.\");\n return {};\n }\n\n };\n\n Converter.prototype.compileTemplate = function (id, values, config, key, template) {\n\n /*\n Priority\n - values\n - format configuration\n - code list configuration\n */\n\n var model = $.extend(true, config.cl, config.format, {codes: '\"' + values.join('\",\"') + '\"'});\n\n if (!template) {\n log.error(\"Impossible to find '\" + id + \"' process template. Check your '\" + id + \"'.filter.process configuration.\")\n }\n\n if (!model.uid) {\n log.error(\"Impossible to find '\" + id + \"' code list configuration for FENIX output format export.\");\n return;\n }\n\n var tmpl = Handlebars.compile(template),\n process = JSON.parse(tmpl(model)),\n codes = process.codes;\n\n //Remove empty version attributes\n _.each(codes, function (obj) {\n if (!obj.version) {\n delete obj.version;\n }\n });\n\n return process;\n\n };\n\n Converter.prototype.createTimeFilter = function (id, values, config, key) {\n\n var time = [],\n valuesAreObject = typeof values[0] === 'object',\n v;\n\n if (valuesAreObject) {\n\n var from = _.findWhere(values, {parent: \"from\"}) || {},\n to = _.findWhere(values, {parent: \"to\"}) || {},\n couple = {from: null, to: null};\n\n couple.from = from.value;\n couple.to = to.value;\n\n time.push($.extend({}, couple));\n\n } else {\n\n v = values.map(function (a) {\n return parseInt(a, 10);\n }).sort(function (a, b) {\n return a - b;\n });\n\n\n _.each(v, function (i) {\n time.push({from: i, to: i});\n });\n\n }\n\n return {time: time};\n };\n\n Converter.prototype.createEnumerationFilter = function (id, values, config, key) {\n\n return {enumeration: values};\n\n };\n\n Converter.prototype.createFreeTextFilter = function (id, values, config, key) {\n\n return {text: values[0]};\n };\n\n Converter.prototype.cleanArray = function (actual) {\n var newArray = [];\n for (var i = 0; i < actual.length; i++) {\n if (actual[i]) {\n newArray.push(actual[i]);\n }\n }\n return newArray;\n };\n\n return new Converter();\n\n});" | ||
"source": "if (typeof define !== 'function') {\n var define = require('amdefine')(module);\n}\n\ndefine([\n 'jquery',\n 'underscore',\n 'loglevel',\n 'handlebars'\n], function ($, _, log, Handlebars) {\n\n 'use strict';\n\n function Converter() {\n return this;\n }\n\n Converter.prototype.toD3P = function (items, values) {\n\n var filter = {},\n self = this;\n\n _.each(values.values, function (val, id) {\n\n var v = self.cleanArray(val),\n config = items[id] || {},\n formatConfig = config.format || {};\n\n var key = formatConfig.items || id;\n\n if (v.length > 0) {\n filter[key] = $.extend(true, {}, self.compileFilter(id, v, items));\n } else {\n log.warn(id + \" column excluded from FENIX conversion because it has no values\");\n }\n\n });\n\n return filter;\n };\n\n Converter.prototype.toFilter = function (items, values) {\n\n var filter = {},\n self = this;\n\n _.each(values.values, function (val, id) {\n\n var v = self.cleanArray(val),\n config = items[id] || {},\n formatConfig = config.format || {};\n\n var key = formatConfig.metadataAttribute;\n\n if (!key) {\n log.warn(id + \" impossible to find format.metadataAttribute configuration\");\n return;\n }\n\n if (v.length > 0) {\n filter[key] = $.extend(true, {}, self.compileFilter(id, v, items));\n } else {\n log.warn(id + \" column excluded from FENIX filter because it has no values\");\n }\n\n });\n\n return filter;\n };\n\n Converter.prototype.compileFilter = function (id, values, items) {\n\n var config = items[id] || {},\n formatConfig = config.format || {},\n template = formatConfig.template,\n output = formatConfig.output || \"codes\";\n\n if (template) {\n return this.compileTemplate(id, values, config, template);\n }\n\n var key = formatConfig.dimension || id,\n tmpl;\n\n switch (output.toLocaleLowerCase()) {\n case \"freetext\" :\n\n return this.createFreeTextFilter(id, values, config, key);\n\n break;\n case \"codes\" :\n\n tmpl = '{ \"codes\":[{\"uid\": \"{{{uid}}}\", \"version\": \"{{version}}\", \"codes\": [{{{codes}}}] } ]}';\n return this.compileTemplate(id, values, config, key, tmpl);\n\n break;\n case \"time\" :\n\n return this.createTimeFilter(id, values, config, key);\n break;\n\n case \"enumeration\" :\n\n return this.createEnumerationFilter(id, values, config, key);\n break;\n default :\n log.warn(id + \" not included in the result set. Missing format configuration.\");\n return {};\n }\n\n };\n\n Converter.prototype.compileTemplate = function (id, values, config, key, template) {\n\n /*\n Priority\n - values\n - format configuration\n - code list configuration\n */\n\n var model = $.extend(true, config.cl, config.format, {codes: '\"' + values.join('\",\"') + '\"'});\n\n if (!template) {\n log.error(\"Impossible to find '\" + id + \"' process template. Check your '\" + id + \"'.filter.process configuration.\")\n }\n\n if (!model.uid) {\n log.error(\"Impossible to find '\" + id + \"' code list configuration for FENIX output format export.\");\n return;\n }\n\n var tmpl = Handlebars.compile(template),\n process = JSON.parse(tmpl(model)),\n codes = process.codes;\n\n //Remove empty version attributes\n _.each(codes, function (obj) {\n if (!obj.version) {\n delete obj.version;\n }\n });\n\n return process;\n\n };\n\n Converter.prototype.createTimeFilter = function (id, values, config, key) {\n\n var time = [],\n valuesAreObject = typeof values[0] === 'object',\n v;\n\n if (valuesAreObject) {\n\n var from = _.findWhere(values, {parent: \"from\"}) || {},\n to = _.findWhere(values, {parent: \"to\"}) || {},\n couple = {from: null, to: null};\n\n couple.from = from.value;\n couple.to = to.value;\n\n time.push($.extend({}, couple));\n\n } else {\n\n v = values.map(function (a) {\n return parseInt(a, 10);\n }).sort(function (a, b) {\n return a - b;\n });\n\n\n _.each(v, function (i) {\n time.push({from: i, to: i});\n });\n\n }\n\n return {time: time};\n };\n\n Converter.prototype.createEnumerationFilter = function (id, values, config, key) {\n\n return {enumeration: values};\n\n };\n\n Converter.prototype.createFreeTextFilter = function (id, values, config, key) {\n\n return {text: values[0]};\n };\n\n Converter.prototype.cleanArray = function (actual) {\n var newArray = [];\n for (var i = 0; i < actual.length; i++) {\n if (actual[i]) {\n newArray.push(actual[i]);\n }\n }\n return newArray;\n };\n\n return new Converter();\n\n});" | ||
}, | ||
@@ -141,3 +141,3 @@ { | ||
"profile": { | ||
"factory": 0, | ||
"factory": 1, | ||
"building": 0 | ||
@@ -177,4 +177,4 @@ }, | ||
"profile": { | ||
"factory": 0, | ||
"building": 1 | ||
"factory": 1, | ||
"building": 0 | ||
}, | ||
@@ -313,3 +313,3 @@ "failed": false, | ||
"index2": 4, | ||
"size": 5393, | ||
"size": 5389, | ||
"cacheable": true, | ||
@@ -325,4 +325,4 @@ "built": true, | ||
"profile": { | ||
"factory": 12, | ||
"building": 35 | ||
"factory": 13, | ||
"building": 34 | ||
}, | ||
@@ -342,3 +342,3 @@ "failed": false, | ||
], | ||
"source": "if (typeof define !== 'function') {\n var define = require('amdefine')(module);\n}\n\ndefine([\n 'jquery',\n 'underscore',\n 'loglevel',\n 'handlebars'\n], function ($, _, log, Handlebars) {\n\n 'use strict';\n\n function Converter() {\n return this;\n }\n\n Converter.prototype.toD3P = function (items, values) {\n\n var filter = {},\n self = this;\n\n _.each(values.values, function (val, id) {\n\n var v = self.cleanArray(val),\n config = items[id] || {},\n formatConfig = config.format || {};\n\n var key = formatConfig.items || id;\n\n if (v.length > 0) {\n filter[key] = $.extend(true, {}, self.compileFilter(id, v, items));\n } else {\n log.warn(id + \" column excluded from FENIX conversion because it has no values\");\n }\n\n });\n\n return filter;\n };\n\n Converter.prototype.toFilter = function (items, values) {\n\n var filter = {},\n self = this;\n\n _.each(values.values, function (val, id) {\n\n var v = self.cleanArray(val),\n config = items[id] || {},\n formatConfig = config.format || {};\n\n var key = formatConfig.metadataAttribute;\n\n if (!key) {\n log.warn(id + \" impossible to find format.metadataAttribute configuration\");\n return;\n }\n\n if (v.length > 0) {\n filter[key] = $.extend(true, {}, self.compileFilter(id, v, items));\n } else {\n log.warn(id + \" column excluded from FENIX filter because it has no values\");\n }\n\n });\n\n return filter;\n };\n\n Converter.prototype.compileFilter = function (id, values, items) {\n\n var config = items[id] || {},\n formatConfig = config.format || {},\n template = formatConfig.template,\n output = formatConfig.output || \"codes\";\n\n if (template) {\n return this.compileTemplate(id, values, config, template);\n }\n\n var key = formatConfig.dimension || id,\n tmpl;\n\n switch (output.toLocaleLowerCase()) {\n case \"freetext\" :\n\n return this.createFreeTextFilter(id, values, config, key);\n\n break;\n case \"codes\" :\n\n tmpl = '{ \"codes\":[{\"uid\": \"{{{uid}}}\", \"version\": \"{{version}}\", \"codes\": [{{{codes}}}] } ]}';\n return this.compileTemplate(id, values, config, key, tmpl);\n\n break;\n case \"time\" :\n\n return this.createTimeFilter(id, values, config, confkey);\n break;\n\n case \"enumeration\" :\n\n return this.createEnumerationFilter(id, values, config, key);\n break;\n default :\n log.warn(id + \" not included in the result set. Missing format configuration.\");\n return {};\n }\n\n };\n\n Converter.prototype.compileTemplate = function (id, values, config, key, template) {\n\n /*\n Priority\n - values\n - format configuration\n - code list configuration\n */\n\n var model = $.extend(true, config.cl, config.format, {codes: '\"' + values.join('\",\"') + '\"'});\n\n if (!template) {\n log.error(\"Impossible to find '\" + id + \"' process template. Check your '\" + id + \"'.filter.process configuration.\")\n }\n\n if (!model.uid) {\n log.error(\"Impossible to find '\" + id + \"' code list configuration for FENIX output format export.\");\n return;\n }\n\n var tmpl = Handlebars.compile(template),\n process = JSON.parse(tmpl(model)),\n codes = process.codes;\n\n //Remove empty version attributes\n _.each(codes, function (obj) {\n if (!obj.version) {\n delete obj.version;\n }\n });\n\n return process;\n\n };\n\n Converter.prototype.createTimeFilter = function (id, values, config, key) {\n\n var time = [],\n valuesAreObject = typeof values[0] === 'object',\n v;\n\n if (valuesAreObject) {\n\n var from = _.findWhere(values, {parent: \"from\"}) || {},\n to = _.findWhere(values, {parent: \"to\"}) || {},\n couple = {from: null, to: null};\n\n couple.from = from.value;\n couple.to = to.value;\n\n time.push($.extend({}, couple));\n\n } else {\n\n v = values.map(function (a) {\n return parseInt(a, 10);\n }).sort(function (a, b) {\n return a - b;\n });\n\n\n _.each(v, function (i) {\n time.push({from: i, to: i});\n });\n\n }\n\n return {time: time};\n };\n\n Converter.prototype.createEnumerationFilter = function (id, values, config, key) {\n\n return {enumeration: values};\n\n };\n\n Converter.prototype.createFreeTextFilter = function (id, values, config, key) {\n\n return {text: values[0]};\n };\n\n Converter.prototype.cleanArray = function (actual) {\n var newArray = [];\n for (var i = 0; i < actual.length; i++) {\n if (actual[i]) {\n newArray.push(actual[i]);\n }\n }\n return newArray;\n };\n\n return new Converter();\n\n});" | ||
"source": "if (typeof define !== 'function') {\n var define = require('amdefine')(module);\n}\n\ndefine([\n 'jquery',\n 'underscore',\n 'loglevel',\n 'handlebars'\n], function ($, _, log, Handlebars) {\n\n 'use strict';\n\n function Converter() {\n return this;\n }\n\n Converter.prototype.toD3P = function (items, values) {\n\n var filter = {},\n self = this;\n\n _.each(values.values, function (val, id) {\n\n var v = self.cleanArray(val),\n config = items[id] || {},\n formatConfig = config.format || {};\n\n var key = formatConfig.items || id;\n\n if (v.length > 0) {\n filter[key] = $.extend(true, {}, self.compileFilter(id, v, items));\n } else {\n log.warn(id + \" column excluded from FENIX conversion because it has no values\");\n }\n\n });\n\n return filter;\n };\n\n Converter.prototype.toFilter = function (items, values) {\n\n var filter = {},\n self = this;\n\n _.each(values.values, function (val, id) {\n\n var v = self.cleanArray(val),\n config = items[id] || {},\n formatConfig = config.format || {};\n\n var key = formatConfig.metadataAttribute;\n\n if (!key) {\n log.warn(id + \" impossible to find format.metadataAttribute configuration\");\n return;\n }\n\n if (v.length > 0) {\n filter[key] = $.extend(true, {}, self.compileFilter(id, v, items));\n } else {\n log.warn(id + \" column excluded from FENIX filter because it has no values\");\n }\n\n });\n\n return filter;\n };\n\n Converter.prototype.compileFilter = function (id, values, items) {\n\n var config = items[id] || {},\n formatConfig = config.format || {},\n template = formatConfig.template,\n output = formatConfig.output || \"codes\";\n\n if (template) {\n return this.compileTemplate(id, values, config, template);\n }\n\n var key = formatConfig.dimension || id,\n tmpl;\n\n switch (output.toLocaleLowerCase()) {\n case \"freetext\" :\n\n return this.createFreeTextFilter(id, values, config, key);\n\n break;\n case \"codes\" :\n\n tmpl = '{ \"codes\":[{\"uid\": \"{{{uid}}}\", \"version\": \"{{version}}\", \"codes\": [{{{codes}}}] } ]}';\n return this.compileTemplate(id, values, config, key, tmpl);\n\n break;\n case \"time\" :\n\n return this.createTimeFilter(id, values, config, key);\n break;\n\n case \"enumeration\" :\n\n return this.createEnumerationFilter(id, values, config, key);\n break;\n default :\n log.warn(id + \" not included in the result set. Missing format configuration.\");\n return {};\n }\n\n };\n\n Converter.prototype.compileTemplate = function (id, values, config, key, template) {\n\n /*\n Priority\n - values\n - format configuration\n - code list configuration\n */\n\n var model = $.extend(true, config.cl, config.format, {codes: '\"' + values.join('\",\"') + '\"'});\n\n if (!template) {\n log.error(\"Impossible to find '\" + id + \"' process template. Check your '\" + id + \"'.filter.process configuration.\")\n }\n\n if (!model.uid) {\n log.error(\"Impossible to find '\" + id + \"' code list configuration for FENIX output format export.\");\n return;\n }\n\n var tmpl = Handlebars.compile(template),\n process = JSON.parse(tmpl(model)),\n codes = process.codes;\n\n //Remove empty version attributes\n _.each(codes, function (obj) {\n if (!obj.version) {\n delete obj.version;\n }\n });\n\n return process;\n\n };\n\n Converter.prototype.createTimeFilter = function (id, values, config, key) {\n\n var time = [],\n valuesAreObject = typeof values[0] === 'object',\n v;\n\n if (valuesAreObject) {\n\n var from = _.findWhere(values, {parent: \"from\"}) || {},\n to = _.findWhere(values, {parent: \"to\"}) || {},\n couple = {from: null, to: null};\n\n couple.from = from.value;\n couple.to = to.value;\n\n time.push($.extend({}, couple));\n\n } else {\n\n v = values.map(function (a) {\n return parseInt(a, 10);\n }).sort(function (a, b) {\n return a - b;\n });\n\n\n _.each(v, function (i) {\n time.push({from: i, to: i});\n });\n\n }\n\n return {time: time};\n };\n\n Converter.prototype.createEnumerationFilter = function (id, values, config, key) {\n\n return {enumeration: values};\n\n };\n\n Converter.prototype.createFreeTextFilter = function (id, values, config, key) {\n\n return {text: values[0]};\n };\n\n Converter.prototype.cleanArray = function (actual) {\n var newArray = [];\n for (var i = 0; i < actual.length; i++) {\n if (actual[i]) {\n newArray.push(actual[i]);\n }\n }\n return newArray;\n };\n\n return new Converter();\n\n});" | ||
}, | ||
@@ -362,3 +362,3 @@ { | ||
"profile": { | ||
"factory": 0, | ||
"factory": 1, | ||
"building": 0 | ||
@@ -398,4 +398,4 @@ }, | ||
"profile": { | ||
"factory": 0, | ||
"building": 1 | ||
"factory": 1, | ||
"building": 0 | ||
}, | ||
@@ -402,0 +402,0 @@ "failed": false, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
88208
1185