agregar funcion para validar null y undefined
This commit is contained in:
parent
1914edfe7a
commit
017b23d2c3
@ -212,12 +212,19 @@ function makeRenderer() {
|
|||||||
};
|
};
|
||||||
} : null;
|
} : null;
|
||||||
|
|
||||||
|
var isNotNullish = function isNotNullish(val) {
|
||||||
|
if (typeof val !== 'undefined' && val !== null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
var getFinalFormat = function getFinalFormat(objCol) {
|
var getFinalFormat = function getFinalFormat(objCol) {
|
||||||
if (objCol.type !== 'number' || objCol.format != null && objCol.format.includes('Q')) {
|
if (objCol.type !== 'number' || isNotNullish(objCol.format) && objCol.format.includes('Q')) {
|
||||||
return objCol.format;
|
return objCol.format;
|
||||||
}
|
}
|
||||||
if (objCol.format.includes('.')) {
|
if (objCol.format.includes('.')) {
|
||||||
if (objCol.number_decimals != null) {
|
if (isNotNullish(objCol.number_decimals)) {
|
||||||
var numberDecimals = parseInt(objCol.number_decimals);
|
var numberDecimals = parseInt(objCol.number_decimals);
|
||||||
var resultDecimals = '';
|
var resultDecimals = '';
|
||||||
if (numberDecimals && !isNaN(numberDecimals) && numberDecimals > 0) {
|
if (numberDecimals && !isNaN(numberDecimals) && numberDecimals > 0) {
|
||||||
@ -236,13 +243,13 @@ function makeRenderer() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var getLocaleConfig = function getLocaleConfig(objCol) {
|
var getLocaleConfig = function getLocaleConfig(objCol) {
|
||||||
if (objCol.type !== 'number' || objCol.format != null && objCol.format.includes('Q')) {
|
if (objCol.type !== 'number' || isNotNullish(objCol.format) && objCol.format.includes('Q')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
delimiters: {
|
delimiters: {
|
||||||
thousands: objCol.delimiter_thousands != null ? objCol.delimiter_thousands : ',',
|
thousands: isNotNullish(objCol.delimiter_thousands) ? objCol.delimiter_thousands : ',',
|
||||||
decimal: objCol.delimiter_decimal != null ? objCol.delimiter_decimal : '.'
|
decimal: isNotNullish(objCol.delimiter_decimal) ? objCol.delimiter_decimal : '.'
|
||||||
},
|
},
|
||||||
abbreviations: {
|
abbreviations: {
|
||||||
thousand: 'k',
|
thousand: 'k',
|
||||||
@ -251,7 +258,7 @@ function makeRenderer() {
|
|||||||
trillion: 't'
|
trillion: 't'
|
||||||
},
|
},
|
||||||
currency: {
|
currency: {
|
||||||
symbol: objCol.currency_symbol != null ? objCol.currency_symbol : '$'
|
symbol: isNotNullish(objCol.currency_symbol) ? objCol.currency_symbol : '$'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -261,17 +268,17 @@ function makeRenderer() {
|
|||||||
var valToFormat = aggregator.value();
|
var valToFormat = aggregator.value();
|
||||||
console.log('valToFormat', valToFormat);
|
console.log('valToFormat', valToFormat);
|
||||||
var resultValue = aggregator.format(valToFormat);
|
var resultValue = aggregator.format(valToFormat);
|
||||||
var keyColumnaCalculo = _this2.props.vals != null && _this2.props.vals.length ? _this2.props.vals[0] : null;
|
var keyColumnaCalculo = isNotNullish(_this2.props.vals) && _this2.props.vals.length ? _this2.props.vals[0] : null;
|
||||||
console.log('keyColumnaCalculo', keyColumnaCalculo);
|
console.log('keyColumnaCalculo', keyColumnaCalculo);
|
||||||
console.log('this.props.headersDefinitions', _this2.props.headersDefinitions);
|
console.log('this.props.headersDefinitions', _this2.props.headersDefinitions);
|
||||||
if (keyColumnaCalculo != null && _this2.props.headersDefinitions != null && _this2.props.headersDefinitions.length) {
|
if (isNotNullish(keyColumnaCalculo) && isNotNullish(_this2.props.headersDefinitions) && _this2.props.headersDefinitions.length) {
|
||||||
var _definition = _this2.props.headersDefinitions[keyColumnaCalculo];
|
var _definition = _this2.props.headersDefinitions[keyColumnaCalculo];
|
||||||
console.log('_definition', _definition);
|
console.log('_definition', _definition);
|
||||||
if (_definition != null && _definition.value != null) {
|
if (isNotNullish(_definition) && isNotNullish(_definition.value)) {
|
||||||
if (_definition.value.startsWith('count_') || _definition.value.startsWith('countd_')) {
|
if (_definition.value.startsWith('count_') || _definition.value.startsWith('countd_')) {
|
||||||
resultValue = _this2.props.functions != null ? _this2.props.functions.formatedValue(valToFormat, '0,0', 'number', true, '') : resultValue;
|
resultValue = isNotNullish(_this2.props.functions) ? _this2.props.functions.formatedValue(valToFormat, '0,0', 'number', true, '') : resultValue;
|
||||||
} else if (_definition.format != null && _definition.format !== '') {
|
} else if (isNotNullish(_definition.format) && _definition.format !== '') {
|
||||||
resultValue = _this2.props.chartFunctions != null ? _this2.props.chartFunctions.formatedValue(valToFormat, getFinalFormat(_definition), _definition.type, true, '', getLocaleConfig(_definition)) : resultValue;
|
resultValue = isNotNullish(_this2.props.chartFunctions) ? _this2.props.chartFunctions.formatedValue(valToFormat, getFinalFormat(_definition), _definition.type, true, '', getLocaleConfig(_definition)) : resultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "v-react-pivottable",
|
"name": "v-react-pivottable",
|
||||||
"version": "0.11.25",
|
"version": "0.11.26",
|
||||||
"description": "A React-based pivot table",
|
"description": "A React-based pivot table",
|
||||||
"main": "PivotTableUI.js",
|
"main": "PivotTableUI.js",
|
||||||
"files": [
|
"files": [
|
||||||
|
Loading…
Reference in New Issue
Block a user