From 597a0e4482df089cb48da71422d87cc7097abcc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20K=C3=BCng?= Date: Wed, 27 Jun 2018 15:52:57 +0200 Subject: [PATCH 1/2] added checks for minibar option --- routes/option-availability.js | 73 ++++++++++++++++++++++------------- routes/rendering-info/web.js | 73 +++++++++++++++++++---------------- 2 files changed, 86 insertions(+), 60 deletions(-) diff --git a/routes/option-availability.js b/routes/option-availability.js index 9b2e25c4..558726ca 100644 --- a/routes/option-availability.js +++ b/routes/option-availability.js @@ -40,26 +40,38 @@ module.exports = { } if (request.params.optionName === "barColor") { - return { - available: + let isAvailable = false; + if ( + request.payload.options.minibar !== null && + request.payload.options.minibar !== undefined + ) { + isAvailable = request.payload.options.minibar.selectedColumn !== null && - request.payload.options.minibar.selectedColumn !== undefined + request.payload.options.minibar.selectedColumn !== undefined; + } + + return { + available: isAvailable }; } if (request.params.optionName === "barColorPositive") { let isAvailable = false; - if ( - request.payload.options.minibar.selectedColumn !== null && - request.payload.options.minibar.selectedColumn !== undefined + request.payload.options.minibar != null && + request.payload.options.minibar != undefined ) { - let type = prepareSelectedColumn( - request.payload.data, - request.payload.options.minibar.selectedColumn - ).type; + if ( + request.payload.options.minibar.selectedColumn !== null && + request.payload.options.minibar.selectedColumn !== undefined + ) { + let type = prepareSelectedColumn( + request.payload.data, + request.payload.options.minibar.selectedColumn + ).type; - isAvailable = type === "mixed" || type === "positive"; + isAvailable = type === "mixed" || type === "positive"; + } } return { available: isAvailable @@ -68,17 +80,21 @@ module.exports = { if (request.params.optionName === "barColorNegative") { let isAvailable = false; - if ( - request.payload.options.minibar.selectedColumn !== null && - request.payload.options.minibar.selectedColumn !== undefined + request.payload.options.minibar != null && + request.payload.options.minibar != undefined ) { - let type = prepareSelectedColumn( - request.payload.data, - request.payload.options.minibar.selectedColumn - ).type; + if ( + request.payload.options.minibar.selectedColumn !== null && + request.payload.options.minibar.selectedColumn !== undefined + ) { + let type = prepareSelectedColumn( + request.payload.data, + request.payload.options.minibar.selectedColumn + ).type; - isAvailable = type === "mixed" || type === "negative"; + isAvailable = type === "mixed" || type === "negative"; + } } return { available: isAvailable @@ -88,15 +104,20 @@ module.exports = { if (request.params.optionName === "invertColors") { let isAvailable = false; if ( - request.payload.options.minibar.selectedColumn !== null && - request.payload.options.minibar.selectedColumn !== undefined + request.payload.options.minibar != null && + request.payload.options.minibar != undefined ) { - let type = prepareSelectedColumn( - request.payload.data, - request.payload.options.minibar.selectedColumn - ).type; + if ( + request.payload.options.minibar.selectedColumn !== null && + request.payload.options.minibar.selectedColumn !== undefined + ) { + let type = prepareSelectedColumn( + request.payload.data, + request.payload.options.minibar.selectedColumn + ).type; - isAvailable = type === "mixed"; + isAvailable = type === "mixed"; + } } return { available: isAvailable diff --git a/routes/rendering-info/web.js b/routes/rendering-info/web.js index 2f3eb3a6..65723847 100644 --- a/routes/rendering-info/web.js +++ b/routes/rendering-info/web.js @@ -143,42 +143,44 @@ module.exports = { } // if minibars active - if ( - item.options.minibar.selectedColumn !== null && - item.options.minibar.selectedColumn !== undefined - ) { - context.minibar = data.getDataForMinibars( - itemDataCopy, - item.options.minibar.selectedColumn - ); - - if ( - item.options.minibar.barColor.positive.className === "" && - item.options.minibar.barColor.positive.colorCode === "" - ) { - item.options.minibar.barColor.positive.className = getPositiveColor( - context.minibar.type - ); - } else if (item.options.minibar.barColor.positive.className !== "") { - item.options.minibar.barColor.positive.colorCode = ""; - } - + if (item.options.minibar !== null && item.options.minibar !== undefined) { if ( - item.options.minibar.barColor.negative.className === "" && - item.options.minibar.barColor.negative.colorCode === "" + item.options.minibar.selectedColumn !== null && + item.options.minibar.selectedColumn !== undefined ) { - item.options.minibar.barColor.negative.className = getNegativeColor( - context.minibar.type + context.minibar = data.getDataForMinibars( + itemDataCopy, + item.options.minibar.selectedColumn ); - } else if (item.options.minibar.barColor.negative.className !== "") { - item.options.minibar.barColor.negative.colorCode = ""; - } - if (context.item.options.minibar.invertColors) { - let color = context.item.options.minibar.barColor.negative; - context.item.options.minibar.barColor.negative = - context.item.options.minibar.barColor.positive; - context.item.options.minibar.barColor.positive = color; + if ( + item.options.minibar.barColor.positive.className === "" && + item.options.minibar.barColor.positive.colorCode === "" + ) { + item.options.minibar.barColor.positive.className = getPositiveColor( + context.minibar.type + ); + } else if (item.options.minibar.barColor.positive.className !== "") { + item.options.minibar.barColor.positive.colorCode = ""; + } + + if ( + item.options.minibar.barColor.negative.className === "" && + item.options.minibar.barColor.negative.colorCode === "" + ) { + item.options.minibar.barColor.negative.className = getNegativeColor( + context.minibar.type + ); + } else if (item.options.minibar.barColor.negative.className !== "") { + item.options.minibar.barColor.negative.colorCode = ""; + } + + if (context.item.options.minibar.invertColors) { + let color = context.item.options.minibar.barColor.negative; + context.item.options.minibar.barColor.negative = + context.item.options.minibar.barColor.positive; + context.item.options.minibar.barColor.positive = color; + } } } @@ -223,7 +225,9 @@ module.exports = { (item.options.cardLayout === false && item.options.cardLayoutIfSmall === true) || possibleToHaveToHideRows || - item.options.minibar.selectedColumn !== null + (item.options.minibar !== undefined && + item.options.minibar !== null && + item.options.minibar.selectedColumn !== null) ) { renderingInfo.scripts.push({ content: renderingInfoScripts.getDefaultScript(context) @@ -248,7 +252,8 @@ module.exports = { } if ( - item.options.minibar.selectedColumn !== undefined && + item.options.minibar !== undefined && + item.options.minibar !== null && item.options.minibar.selectedColumn !== null ) { renderingInfo.scripts.push({ From d4b2fed9b7b2f0c86016d16278b233d161b4a5d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20K=C3=BCng?= Date: Wed, 27 Jun 2018 15:59:01 +0200 Subject: [PATCH 2/2] release-2.0.5 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 67ee1c8a..90189065 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "q-table", - "version": "2.0.4", + "version": "2.0.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index bc2d37e0..a42a0215 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "q-table", - "version": "2.0.4", + "version": "2.0.5", "description": "", "main": "index.js", "scripts": {