Compare commits

...

19 Commits

Author SHA1 Message Date
Purwa Shrivastava
2ab340f3f1 React rendering Errors for few apps. 2019-12-06 11:11:25 +01:00
Purwa Shrivastava
8ba826a0ea Corrected the react error when componentDidUpdate is called. So the error message is uniformly shown in both analysis and edit mode. 2019-12-06 10:12:07 +01:00
Purwa Shrivastava
d2446395e2 Merge pull request #77 from qlik-oss/QB-331/PivotPagination
Pivot Pagination Fix.
2019-12-05 13:41:29 +01:00
Purwa Shrivastava
f17a7b7714 Merge pull request #79 from qlik-oss/QB-493/wrongDataDisplay
Qb 493/wrong data display
2019-12-05 09:15:42 +01:00
Purwa Shrivastava
8aa86275f0 Changed the rendering of each data cell to check for the headers of each dimesnsion and measure where it shall be written. 2019-12-04 11:15:14 +01:00
Purwa Shrivastava
3ebc2b9e29 Adding Dim 2 to the rendering logic. 2019-11-29 16:17:49 +01:00
Purwa Shrivastava
ce81549011 Merge pull request #78 from qlik-oss/QB-498/disableConversion
Conversion led to different sort orders of data in different objects …
2019-11-28 13:40:45 +01:00
Purwa Shrivastava
e64af66dab Conversion led to different sort orders of data in different objects so disabling it. 2019-11-27 14:54:42 +01:00
Purwa Shrivastava
fd9e645fc1 Pivot Pagination Fix. 2019-11-21 10:59:28 +01:00
Philip Olsén
ca1b1a9b53 Merge pull request #75 from qlik-oss/pol/bd
Update black duck link
2019-09-20 15:33:56 +02:00
Philip Olsén
a65f843008 Update black duck link 2019-09-20 14:23:37 +02:00
Purwa Shrivastava
be9570e0aa Merge pull request #74 from qlik-oss/atq/about
Updated the About info for the smart pivot.
2019-07-12 12:40:29 +02:00
Purwa Shrivastava
41d3a7c9af Updated the About info for the smart pivot. 2019-07-11 11:01:42 +02:00
Albert Backenhof
1e0a7c1204 Merge pull request #72 from qlik-oss/DEB-211/ContextMenuExportExcel
Moved Excel export to context menu
2019-06-27 12:35:04 +02:00
Albert Backenhof
17b5df296c Moved Excel export to context menu
-Not showing context menu option for desktop
 users.

Issue: DEB-211
2019-06-26 13:41:07 +02:00
Albert Backenhof
64b778b1af Merge pull request #71 from qlik-oss/DEB-244/ExcelRow
Suppress missing values and use correct cube size
2019-06-17 13:37:05 +02:00
Albert Backenhof
be6718ccf4 Merge pull request #73 from qlik-oss/DEB-250/ImprovedSelection
Selecting with backendApi instead of Field
2019-06-17 09:30:27 +02:00
Albert Backenhof
28e6237a43 Selecting with backendApi instead of Field
-Makes it possible to select master fields with
 different names than the original field.

-Alternate state is no longer a problem when using
 this technique to select.

Issue: DEB-250
2019-06-14 08:30:57 +02:00
Albert Backenhof
4fab3b5933 Suppress missing values and use correct cube size
Issue: DEB-244
2019-05-29 15:17:17 +02:00
17 changed files with 345 additions and 301 deletions

View File

@@ -20,7 +20,7 @@ jobs:
command: npm install command: npm install
- run: - run:
name: BlackDuck scan name: BlackDuck scan
command: curl -s https://blackducksoftware.github.io/hub-detect/hub-detect.sh | bash -s -- \ command: curl -s https://detect.synopsys.com/detect.sh | bash -s -- \
--blackduck.url="https://qliktech.blackducksoftware.com" \ --blackduck.url="https://qliktech.blackducksoftware.com" \
--blackduck.trust.cert=true \ --blackduck.trust.cert=true \
--blackduck.username="svc-blackduck" \ --blackduck.username="svc-blackduck" \

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -1,4 +1,3 @@
import qlik from 'qlik';
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import Tooltip from '../tooltip/index.jsx'; import Tooltip from '../tooltip/index.jsx';
@@ -12,10 +11,8 @@ class DataCell extends React.PureComponent {
handleSelect () { handleSelect () {
const { const {
data: { data: {
headers,
meta: { meta: {
dimensionCount, dimensionCount
altState
} }
}, },
general: { general: {
@@ -30,13 +27,9 @@ class DataCell extends React.PureComponent {
return; return;
} }
const app = qlik.currApp(component); component.backendApi.selectValues(0, [measurement.parents.dimension1.elementNumber], false);
app.field(headers.dimension1[0].name, altState)
.select([measurement.parents.dimension1.elementNumber], false, false);
if (hasSecondDimension) { if (hasSecondDimension) {
app.field(headers.dimension2[0].name, altState) component.backendApi.selectValues(1, [measurement.parents.dimension2.elementNumber], false);
.select([measurement.parents.dimension2.elementNumber], false, false);
} }
} }
@@ -105,11 +98,9 @@ DataCell.propTypes = {
cellWidth: PropTypes.string.isRequired, cellWidth: PropTypes.string.isRequired,
data: PropTypes.shape({ data: PropTypes.shape({
headers: PropTypes.shape({ headers: PropTypes.shape({
dimension1: PropTypes.array.isRequired,
measurements: PropTypes.array.isRequired measurements: PropTypes.array.isRequired
}).isRequired, }).isRequired,
meta: PropTypes.shape({ meta: PropTypes.shape({
altState: PropTypes.string.isRequired,
dimensionCount: PropTypes.number.isRequired dimensionCount: PropTypes.number.isRequired
}).isRequired }).isRequired
}).isRequired, }).isRequired,
@@ -119,7 +110,16 @@ DataCell.propTypes = {
name: PropTypes.string, name: PropTypes.string,
value: PropTypes.any value: PropTypes.any
}).isRequired, }).isRequired,
component: PropTypes.shape({}).isRequired, component: PropTypes.shape({
backendApi: PropTypes.shape({
selectValues: function (props, propName) {
if (props.isSnapshot || typeof props[propName] === 'function') {
return null;
}
return new Error('Missing implementation of qlik.backendApi.selectValues.');
}
}).isRequired
}).isRequired,
styleBuilder: PropTypes.shape({ styleBuilder: PropTypes.shape({
hasComments: PropTypes.func.isRequired hasComments: PropTypes.func.isRequired
}).isRequired, }).isRequired,

View File

@@ -5,6 +5,7 @@ import DataCell from './data-cell.jsx';
import RowHeader from './row-header.jsx'; import RowHeader from './row-header.jsx';
import { injectSeparators } from '../utilities'; import { injectSeparators } from '../utilities';
// eslint-disable-next-line react/prefer-stateless-function
class DataTable extends React.PureComponent { class DataTable extends React.PureComponent {
render () { render () {
const { const {
@@ -20,6 +21,7 @@ class DataTable extends React.PureComponent {
const { const {
headers: { headers: {
dimension1, dimension1,
dimension2,
measurements measurements
}, },
matrix matrix
@@ -30,6 +32,36 @@ class DataTable extends React.PureComponent {
maxWidth: columnSeparatorWidth maxWidth: columnSeparatorWidth
}; };
const renderMeasurementData = (dimIndex, atEvery) => {
const injectSeparatorsArray = injectSeparators(
matrix[dimIndex],
columnSeparatorWidth,
atEvery
);
if (dimension2.length <= 0) {
return injectSeparatorsArray;
}
let measurementDataRow = [],
index = 0;
dimension2.forEach((dim2) => {
measurements.forEach((measure) => {
for (index = 0; index < injectSeparatorsArray.length; index++) {
if (injectSeparatorsArray[index].parents && dimension1[dimIndex].displayValue === injectSeparatorsArray[index].parents.dimension1.header) {
if (dim2.displayValue === injectSeparatorsArray[index].parents.dimension2.header) {
if (measure.name === injectSeparatorsArray[index].parents.measurement.header) {
measurementDataRow.push(injectSeparatorsArray[index]);
break;
}
}
}
}
});
});
return measurementDataRow;
};
return ( return (
<div className="row-wrapper"> <div className="row-wrapper">
<table> <table>
@@ -58,7 +90,6 @@ class DataTable extends React.PureComponent {
<tr key={dimensionEntry.displayValue}> <tr key={dimensionEntry.displayValue}>
{!renderData ? {!renderData ?
<RowHeader <RowHeader
altState={data.meta.altState}
component={component} component={component}
entry={dimensionEntry} entry={dimensionEntry}
rowStyle={rowStyle} rowStyle={rowStyle}
@@ -66,11 +97,7 @@ class DataTable extends React.PureComponent {
styling={styling} styling={styling}
/> : null /> : null
} }
{renderData && injectSeparators( {renderData && renderMeasurementData(dimensionIndex, { atEvery: measurements.length }).map((measurementData, index) => {
matrix[dimensionIndex],
columnSeparatorWidth,
{ atEvery: measurements.length }
).map((measurementData, index) => {
if (measurementData.isSeparator) { if (measurementData.isSeparator) {
return ( return (
<td <td
@@ -81,6 +108,7 @@ class DataTable extends React.PureComponent {
); );
} }
// eslint-disable-next-line no-shadow
const { dimension1: dimension1Info, dimension2, measurement } = measurementData.parents; const { dimension1: dimension1Info, dimension2, measurement } = measurementData.parents;
const id = `${dimension1Info.elementNumber}-${dimension2 && dimension2.elementNumber}-${measurement.header}-${measurement.index}`; const id = `${dimension1Info.elementNumber}-${dimension2 && dimension2.elementNumber}-${measurement.header}-${measurement.index}`;
return ( return (
@@ -113,6 +141,7 @@ DataTable.defaultProps = {
DataTable.propTypes = { DataTable.propTypes = {
cellWidth: PropTypes.string.isRequired, cellWidth: PropTypes.string.isRequired,
columnSeparatorWidth: PropTypes.string.isRequired, columnSeparatorWidth: PropTypes.string.isRequired,
component: PropTypes.shape({}).isRequired,
data: PropTypes.shape({ data: PropTypes.shape({
headers: PropTypes.shape({ headers: PropTypes.shape({
dimension1: PropTypes.array.isRequired dimension1: PropTypes.array.isRequired
@@ -120,7 +149,6 @@ DataTable.propTypes = {
matrix: PropTypes.arrayOf(PropTypes.array.isRequired).isRequired matrix: PropTypes.arrayOf(PropTypes.array.isRequired).isRequired
}).isRequired, }).isRequired,
general: PropTypes.shape({}).isRequired, general: PropTypes.shape({}).isRequired,
component: PropTypes.shape({}).isRequired,
renderData: PropTypes.bool, renderData: PropTypes.bool,
styling: PropTypes.shape({ styling: PropTypes.shape({
hasCustomFileStyle: PropTypes.bool.isRequired hasCustomFileStyle: PropTypes.bool.isRequired

View File

@@ -1,4 +1,3 @@
import qlik from 'qlik';
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import HeaderPadding from './header-padding.jsx'; import HeaderPadding from './header-padding.jsx';
@@ -12,9 +11,8 @@ class RowHeader extends React.PureComponent {
} }
handleSelect () { handleSelect () {
const { entry, altState, component } = this.props; const { component, entry } = this.props;
const app = qlik.currApp(component); component.backendApi.selectValues(0, [entry.elementNumber], false);
app.field(entry.name, altState).select([entry.elementNumber], false, false);
} }
render () { render () {
@@ -46,11 +44,18 @@ class RowHeader extends React.PureComponent {
RowHeader.propTypes = { RowHeader.propTypes = {
entry: PropTypes.shape({ entry: PropTypes.shape({
displayValue: PropTypes.string.isRequired, displayValue: PropTypes.string.isRequired,
elementNumber: PropTypes.number.isRequired, elementNumber: PropTypes.number.isRequired
name: PropTypes.string.isRequired }).isRequired,
component: PropTypes.shape({
backendApi: PropTypes.shape({
selectValues: function (props, propName) {
if (props.isSnapshot || typeof props[propName] === 'function') {
return null;
}
return new Error('Missing implementation of qlik.backendApi.selectValues.');
}
}).isRequired
}).isRequired, }).isRequired,
altState: PropTypes.string.isRequired,
component: PropTypes.shape({}).isRequired,
rowStyle: PropTypes.shape({}).isRequired, rowStyle: PropTypes.shape({}).isRequired,
styleBuilder: PropTypes.shape({}).isRequired, styleBuilder: PropTypes.shape({}).isRequired,
styling: PropTypes.shape({}).isRequired styling: PropTypes.shape({}).isRequired

View File

@@ -6,19 +6,22 @@ function createCube (definition, app) {
}); });
} }
async function buildDataCube (originCubeDefinition, hasTwoDimensions, app) { async function buildDataCube (originCubeDefinition, originCube, app, requestPage) {
const cubeDefinition = { const cubeDefinition = {
...originCubeDefinition, ...originCubeDefinition,
qInitialDataFetch: [ qInitialDataFetch: [
{ {
// eslint-disable-next-line no-undefined
qTop: requestPage === undefined ? 0 : requestPage[0].qTop,
qLeft: 0,
qHeight: 1000, qHeight: 1000,
qWidth: 10 qWidth: originCube.qSize.qcx
} }
], ],
qDimensions: [originCubeDefinition.qDimensions[0]], qDimensions: [originCubeDefinition.qDimensions[0]],
qMeasures: originCubeDefinition.qMeasures qMeasures: originCubeDefinition.qMeasures
}; };
if (hasTwoDimensions) { if (originCube.qDimensionInfo.length === 2) {
cubeDefinition.qDimensions.push(originCubeDefinition.qDimensions[1]); cubeDefinition.qDimensions.push(originCubeDefinition.qDimensions[1]);
} }
const cube = await createCube(cubeDefinition, app); const cube = await createCube(cubeDefinition, app);
@@ -28,20 +31,41 @@ async function buildDataCube (originCubeDefinition, hasTwoDimensions, app) {
} }
export async function initializeDataCube (component, layout) { export async function initializeDataCube (component, layout) {
if (component.backendApi.isSnapshot) { if (component.backendApi.isSnapshot) {
return layout.snapshotData.dataCube; return layout.snapshotData.dataCube;
} }
const app = qlik.currApp(component); const app = qlik.currApp(component);
const properties = (await component.backendApi.getProperties()); const properties = (await component.backendApi.getProperties());
const rowCount = component.backendApi.getRowCount();
const cellCount = rowCount * layout.qHyperCube.qSize.qcx;
const maxLoops = layout.maxloops;
// If this is a master object, fetch the hyperCubeDef of the original object // If this is a master object, fetch the hyperCubeDef of the original object
const hyperCubeDef = properties.qExtendsId let hyperCubeDef = properties.qExtendsId
? (await app.getObjectProperties(properties.qExtendsId)).properties.qHyperCubeDef ? (await app.getObjectProperties(properties.qExtendsId)).properties.qHyperCubeDef
: properties.qHyperCubeDef; : properties.qHyperCubeDef;
hyperCubeDef.qStateName = layout.qStateName || ""; hyperCubeDef = JSON.parse(JSON.stringify(hyperCubeDef));
hyperCubeDef.qStateName = layout.qStateName;
return buildDataCube(hyperCubeDef, layout.qHyperCube.qDimensionInfo.length === 2, app); const pagedCube = {};
let lastRow = 0;
if (cellCount < (maxLoops * 10000)) {
for (let index = 0; cellCount > lastRow; index += 1) {
const requestPage = [
{
qHeight: 1000,
qLeft: 0,
qTop: lastRow,
qWidth: 10 // should be # of columns
}
];
// eslint-disable-next-line no-await-in-loop
pagedCube[index] = await buildDataCube(hyperCubeDef, layout.qHyperCube, app, requestPage);
lastRow = lastRow + 1000;
}
return pagedCube;
}
return null;
} }
export function initializeDesignList (component, layout) { export function initializeDesignList (component, layout) {

View File

@@ -39,7 +39,7 @@ const definition = {
component: 'text' component: 'text'
}, },
paragraph1: { paragraph1: {
label: `P&L pivot is a Qlik Sense extension which allows you to display Profit & Loss label: `P&L pivot is a Qlik Sense chart which allows you to display Profit & Loss
reporting with color and font customizations.`, reporting with color and font customizations.`,
component: 'text' component: 'text'
}, },

View File

@@ -23,30 +23,6 @@ const pagination = {
{ {
value: 4, value: 4,
label: '40k cells' label: '40k cells'
},
{
value: 5,
label: '50k cells'
},
{
value: 6,
label: '60k cells'
},
{
value: 7,
label: '70k cells'
},
{
value: 8,
label: '80k cells'
},
{
value: 9,
label: '90k cells'
},
{
value: 10,
label: '100k cells'
} }
], ],
defaultValue: 2 defaultValue: 2
@@ -55,7 +31,8 @@ const pagination = {
ref: 'errormessage', ref: 'errormessage',
label: 'Default error message', label: 'Default error message',
type: 'string', type: 'string',
defaultValue: 'Unable to display all the data. Apply more filters to limit the amount of displayed data.' defaultValue: `Unable to display all the data.
Change the pagination size supported or apply more filters to limit the amount of displayed data.`
} }
} }
}; };

View File

@@ -1,42 +0,0 @@
import React from 'react';
import PropTypes from 'prop-types';
import { exportXLS } from './excel-export';
class ExportButton extends React.PureComponent {
constructor (props) {
super(props);
this.handleExport = this.handleExport.bind(this);
}
handleExport () {
const { component, excelExport, general } = this.props;
const { title, subtitle, footnote } = general;
if (excelExport) {
exportXLS(component.$element, title, subtitle, footnote);
}
}
render () {
const { excelExport } = this.props;
return excelExport === true && (
<input
className="icon-xls"
onClick={this.handleExport}
src="/Extensions/qlik-smart-pivot/Excel.png"
type="image"
/>
);
}
}
ExportButton.defaultProps = {
excelExport: false
};
ExportButton.propTypes = {
component: PropTypes.shape({}).isRequired,
excelExport: PropTypes.bool,
general: PropTypes.shape({}).isRequired
};
export default ExportButton;

View File

@@ -1,4 +1,3 @@
import qlik from 'qlik';
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { HEADER_FONT_SIZE } from '../initialize-transformed'; import { HEADER_FONT_SIZE } from '../initialize-transformed';
@@ -11,9 +10,8 @@ class ColumnHeader extends React.PureComponent {
} }
handleSelect () { handleSelect () {
const { entry, altState, component } = this.props; const { component, entry } = this.props;
const app = qlik.currApp(component); component.backendApi.selectValues(1, [entry.elementNumber], false);
app.field(entry.name, altState).select([entry.elementNumber], false, false);
} }
render () { render () {
@@ -57,13 +55,20 @@ ColumnHeader.propTypes = {
baseCSS: PropTypes.shape({}).isRequired, baseCSS: PropTypes.shape({}).isRequired,
cellWidth: PropTypes.string.isRequired, cellWidth: PropTypes.string.isRequired,
colSpan: PropTypes.number, colSpan: PropTypes.number,
component: PropTypes.shape({
backendApi: PropTypes.shape({
selectValues: function (props, propName) {
if (props.isSnapshot || typeof props[propName] === 'function') {
return null;
}
return new Error('Missing implementation of qlik.backendApi.selectValues.');
}
}).isRequired
}).isRequired,
entry: PropTypes.shape({ entry: PropTypes.shape({
displayValue: PropTypes.string.isRequired, displayValue: PropTypes.string.isRequired,
elementNumber: PropTypes.number.isRequired, elementNumber: PropTypes.number.isRequired
name: PropTypes.string.isRequired
}).isRequired, }).isRequired,
altState: PropTypes.string.isRequired,
component: PropTypes.shape({}).isRequired,
styling: PropTypes.shape({ styling: PropTypes.shape({
headerOptions: PropTypes.shape({ headerOptions: PropTypes.shape({
fontSizeAdjustment: PropTypes.number.isRequired fontSizeAdjustment: PropTypes.number.isRequired

View File

@@ -1,9 +1,10 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import ExportButton from '../export-button.jsx';
import { HEADER_FONT_SIZE } from '../initialize-transformed'; import { HEADER_FONT_SIZE } from '../initialize-transformed';
import Tooltip from '../tooltip/index.jsx';
const ExportColumnHeader = ({ component, baseCSS, general, title, allowExcelExport, hasSecondDimension, styling }) => { const Dim1Header = ({ component, baseCSS, title, hasSecondDimension, styling }) => {
const inEditState = component.inEditState();
const rowSpan = hasSecondDimension ? 2 : 1; const rowSpan = hasSecondDimension ? 2 : 1;
const isMediumFontSize = styling.headerOptions.fontSizeAdjustment === HEADER_FONT_SIZE.MEDIUM; const isMediumFontSize = styling.headerOptions.fontSizeAdjustment === HEADER_FONT_SIZE.MEDIUM;
const style = { const style = {
@@ -21,21 +22,20 @@ const ExportColumnHeader = ({ component, baseCSS, general, title, allowExcelExpo
rowSpan={rowSpan} rowSpan={rowSpan}
style={style} style={style}
> >
<ExportButton <Tooltip
component={component} isTooltipActive={!inEditState}
excelExport={allowExcelExport} styling={styling}
general={general} tooltipText={title}
/> >
{title} {title}
</Tooltip>
</th> </th>
); );
}; };
ExportColumnHeader.propTypes = { Dim1Header.propTypes = {
component: PropTypes.shape({}).isRequired,
allowExcelExport: PropTypes.bool.isRequired,
baseCSS: PropTypes.shape({}).isRequired, baseCSS: PropTypes.shape({}).isRequired,
general: PropTypes.shape({}).isRequired, component: PropTypes.shape({}).isRequired,
hasSecondDimension: PropTypes.bool.isRequired, hasSecondDimension: PropTypes.bool.isRequired,
styling: PropTypes.shape({ styling: PropTypes.shape({
headerOptions: PropTypes.shape({ headerOptions: PropTypes.shape({
@@ -45,4 +45,4 @@ ExportColumnHeader.propTypes = {
title: PropTypes.string.isRequired title: PropTypes.string.isRequired
}; };
export default ExportColumnHeader; export default Dim1Header;

View File

@@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import ExportColumnHeader from './export-column-header.jsx'; import Dim1Header from './dim1-header.jsx';
import ColumnHeader from './column-header.jsx'; import ColumnHeader from './column-header.jsx';
import MeasurementColumnHeader from './measurement-column-header.jsx'; import MeasurementColumnHeader from './measurement-column-header.jsx';
import { injectSeparators } from '../utilities'; import { injectSeparators } from '../utilities';
@@ -12,7 +12,6 @@ class HeadersTable extends React.PureComponent {
columnSeparatorWidth, columnSeparatorWidth,
component, component,
data, data,
general,
isKpi, isKpi,
styling styling
} = this.props; } = this.props;
@@ -43,11 +42,9 @@ class HeadersTable extends React.PureComponent {
<tbody> <tbody>
<tr> <tr>
{isKpi ? {isKpi ?
<ExportColumnHeader <Dim1Header
allowExcelExport={general.allowExcelExport}
baseCSS={baseCSS} baseCSS={baseCSS}
component={component} component={component}
general={general}
hasSecondDimension={hasSecondDimension} hasSecondDimension={hasSecondDimension}
styling={styling} styling={styling}
title={dimension1[0].name} title={dimension1[0].name}
@@ -75,7 +72,6 @@ class HeadersTable extends React.PureComponent {
} }
return ( return (
<ColumnHeader <ColumnHeader
altState={data.meta.altState}
baseCSS={baseCSS} baseCSS={baseCSS}
cellWidth={cellWidth} cellWidth={cellWidth}
colSpan={measurements.length} colSpan={measurements.length}
@@ -128,12 +124,8 @@ HeadersTable.propTypes = {
dimension1: PropTypes.array, dimension1: PropTypes.array,
dimension2: PropTypes.array, dimension2: PropTypes.array,
measurements: PropTypes.array measurements: PropTypes.array
}),
meta: PropTypes.shape({
altState: PropTypes.string.isRequired
}) })
}).isRequired, }).isRequired,
general: PropTypes.shape({}).isRequired,
component: PropTypes.shape({}).isRequired, component: PropTypes.shape({}).isRequired,
styling: PropTypes.shape({ styling: PropTypes.shape({
headerOptions: PropTypes.shape({}), headerOptions: PropTypes.shape({}),

View File

@@ -1,21 +1,19 @@
import definition from './definition'; import definition from "./definition";
import { initializeDataCube, initializeDesignList } from './dataset'; import { exportXLS } from "./excel-export";
import initializeStore from './store'; import { initializeDataCube, initializeDesignList } from "./dataset";
import React from 'react'; import initializeStore from "./store";
import ReactDOM from 'react-dom'; import qlik from "qlik";
import Root from './root.jsx'; import React from "react";
import './main.less'; import ReactDOM from "react-dom";
import Root from "./root.jsx";
import "./main.less";
if (!window._babelPolyfill) { // eslint-disable-line no-underscore-dangle if (!window._babelPolyfill) {
require('@babel/polyfill'); // eslint-disable-line global-require // eslint-disable-line no-underscore-dangle
require("@babel/polyfill"); // eslint-disable-line global-require
} }
export default { export default {
controller: [
'$scope',
'$timeout',
function controller () {}
],
design: { design: {
dimensions: { dimensions: {
max: 1, max: 1,
@@ -24,20 +22,23 @@ export default {
}, },
data: { data: {
dimensions: { dimensions: {
max: function (nMeasures) { max (nMeasures) {
return nMeasures < 9 ? 2 : 1; return nMeasures < 9 ? 2 : 1;
}, },
min: 1, min: 1,
uses: 'dimensions' uses: 'dimensions'
}, },
measures: { measures: {
max: function (nDims) { max (nDims) {
return nDims < 2 ? 9 : 8; return nDims < 2 ? 9 : 8;
}, },
min: 1, min: 1,
uses: 'measures' uses: 'measures'
} }
}, },
// Prevent conversion from and to this object
exportProperties: null,
importProperties: null,
definition, definition,
initialProperties: { initialProperties: {
version: 1.0, version: 1.0,
@@ -45,11 +46,14 @@ export default {
qDimensions: [], qDimensions: [],
qInitialDataFetch: [ qInitialDataFetch: [
{ {
qHeight: 1, qTop: 0,
qWidth: 10 qLeft: 0,
qWidth: 50,
qHeight: 50
} }
], ],
qMeasures: [] qMeasures: [],
qSuppressZero: false
} }
}, },
support: { support: {
@@ -57,23 +61,32 @@ export default {
exportData: true, exportData: true,
snapshot: true snapshot: true
}, },
paint: async function ($element, layout) { async paint ($element, layout, requestPage) {
const dataCube = await initializeDataCube(this, layout); const dataCube = await initializeDataCube(this, layout, requestPage);
const designList = await initializeDesignList(this, layout);
const state = await initializeStore({
$element,
component: this,
dataCube,
designList,
layout
});
const editmodeClass = this.inAnalysisState() ? '' : 'edit-mode'; const editmodeClass = this.inAnalysisState() ? '' : 'edit-mode';
let state, designList;
if (dataCube === null) {
state = {
$element,
component: this,
dataCube,
designList,
layout,
error: true
};
} else {
designList = await initializeDesignList(this, layout);
state = await initializeStore({
$element,
component: this,
dataCube,
designList,
layout,
error: false
});
}
const jsx = ( const jsx = (
<Root <Root editmodeClass={editmodeClass} component={this} state={state} />
editmodeClass={editmodeClass}
component={this}
state={state}
/>
); );
ReactDOM.render(jsx, $element[0]); ReactDOM.render(jsx, $element[0]);
@@ -81,10 +94,41 @@ export default {
snapshot: { snapshot: {
canTakeSnapshot: true canTakeSnapshot: true
}, },
setSnapshotData: async function (snapshotLayout) { async setSnapshotData (snapshotLayout) {
snapshotLayout.snapshotData.dataCube = await initializeDataCube(this, snapshotLayout); snapshotLayout.snapshotData.dataCube = await initializeDataCube(
snapshotLayout.snapshotData.designList = await initializeDesignList(this, snapshotLayout); this,
snapshotLayout
);
snapshotLayout.snapshotData.designList = await initializeDesignList(
this,
snapshotLayout
);
return snapshotLayout; return snapshotLayout;
}, },
async getContextMenu (obj, menu) {
const app = qlik.currApp(this);
const isPersonalResult = await app.global.isPersonalMode();
if (
!this.$scope.layout.allowexportxls ||
(isPersonalResult && isPersonalResult.qReturn)
) {
return menu;
}
menu.addItem({
translation: 'Export as XLS',
tid: 'export-excel',
icon: 'export',
select: () => {
exportXLS(
this.$element,
this.$scope.layout.title,
this.$scope.layout.subtitle,
this.$scope.layout.footnote
);
}
});
return menu;
},
version: 1.0 version: 1.0
}; };

View File

@@ -64,63 +64,64 @@ function generateMatrixCell ({ cell, dimension1Information, dimension2Informatio
if (dimension2Information) { if (dimension2Information) {
matrixCell.parents.dimension2 = { matrixCell.parents.dimension2 = {
elementNumber: dimension2Information.qElemNumber elementNumber: dimension2Information.qElemNumber,
header: dimension2Information.qText
}; };
} }
return matrixCell; return matrixCell;
} }
let lastRow = 0;
function generateDataSet (
component, dimensionsInformation, measurementsInformation, dataCube) {
function generateDataSet (component, dimensionsInformation, measurementsInformation, dataCube) {
const measurements = generateMeasurements(measurementsInformation); const measurements = generateMeasurements(measurementsInformation);
let dimension1 = []; let dimension1 = [];
let dimension2 = []; let dimension2 = [];
let matrix = []; let matrix = [];
const hasSecondDimension = dimensionsInformation.length > 1; const hasSecondDimension = dimensionsInformation.length > 1;
dataCube.forEach(row => { // eslint-disable-next-line no-undefined
lastRow += 1; for (let index = 0; dataCube[index] !== undefined; index++) {
const dimension1Entry = generateDimensionEntry(dimensionsInformation[0], row[0]); // eslint-disable-next-line no-loop-func
dimension1.push(dimension1Entry); dataCube[index].forEach(row => {
let dimension2Entry; const dimension1Entry = generateDimensionEntry(dimensionsInformation[0], row[0]);
let firstDataCell = 1; dimension1.push(dimension1Entry);
if (hasSecondDimension) { let dimension2Entry;
dimension2Entry = generateDimensionEntry(dimensionsInformation[1], row[1]); let firstDataCell = 1;
dimension2.push(dimension2Entry); if (hasSecondDimension) {
firstDataCell = 2; dimension2Entry = generateDimensionEntry(dimensionsInformation[1], row[1]);
} dimension2.push(dimension2Entry);
let matrixRow = row firstDataCell = 2;
.slice(firstDataCell, row.length) }
.map((cell, cellIndex) => { let matrixRow = row
const measurementInformation = measurements[cellIndex]; .slice(firstDataCell, row.length)
measurementInformation.index = cellIndex; .map((cell, cellIndex) => {
const dimension1Information = row[0]; // eslint-disable-line prefer-destructuring const measurementInformation = measurements[cellIndex];
const dimension2Information = hasSecondDimension ? row[1] : null; measurementInformation.index = cellIndex;
const generatedCell = generateMatrixCell({ const dimension1Information = row[0]; // eslint-disable-line prefer-destructuring
cell, const dimension2Information = hasSecondDimension ? row[1] : null;
dimension1Information, const generatedCell = generateMatrixCell({
dimension2Information, cell,
measurementInformation dimension1Information,
dimension2Information,
measurementInformation
});
return generatedCell;
}); });
return generatedCell; let appendToRowIndex = matrix.length;
}); if (hasSecondDimension) {
let appendToRowIndex = matrix.length;
if (hasSecondDimension) {
// See if there already is a row for the current dim1 // See if there already is a row for the current dim1
for (let i = 0; i < matrix.length; i++) { for (let i = 0; i < matrix.length; i++) {
if (matrix[i][0].parents.dimension1.header === matrixRow[0].parents.dimension1.header) { if (matrix[i][0].parents.dimension1.header === matrixRow[0].parents.dimension1.header) {
appendToRowIndex = i; appendToRowIndex = i;
matrixRow = matrix[i].concat(matrixRow); matrixRow = matrix[i].concat(matrixRow);
}
} }
} }
} matrix[appendToRowIndex] = matrixRow;
matrix[appendToRowIndex] = matrixRow; });
}); }
// filter header dimensions to only have distinct values // filter header dimensions to only have distinct values
dimension1 = distinctArray(dimension1); dimension1 = distinctArray(dimension1);
@@ -141,7 +142,7 @@ function generateDataSet (
let rowDataIndex = 0; let rowDataIndex = 0;
dimension2.forEach(dim => { dimension2.forEach(dim => {
rowDataIndex = appendMissingCells( rowDataIndex = appendMissingCells(
row, newRow, rowDataIndex, measurements, rowIndex, dim.elementNumber); row, newRow, rowDataIndex, measurements, rowIndex, dim, dimension1);
}); });
} else { } else {
appendMissingCells(row, newRow, 0, measurements, rowIndex); appendMissingCells(row, newRow, 0, measurements, rowIndex);
@@ -165,14 +166,11 @@ function generateDataSet (
* index of the dimension2 value being processed. * index of the dimension2 value being processed.
*/ */
function appendMissingCells ( function appendMissingCells (
sourceRow, destRow, sourceIndex, measurements, dim1ElementNumber, dim2ElementNumber = -1) { sourceRow, destRow, sourceIndex, measurements, matrixIndex, dim2, dim1) {
let index = sourceIndex; let index = sourceIndex;
measurements.forEach((measurement, measureIndex) => { measurements.forEach((measurement, measureIndex) => {
if (index < sourceRow.length if (index < sourceRow.length) {
&& (dim2ElementNumber === -1
|| sourceRow[index].parents.dimension2.elementNumber === dim2ElementNumber)
&& sourceRow[index].parents.measurement.header === measurement.name) {
// Source contains the expected cell // Source contains the expected cell
destRow.push(sourceRow[index]); destRow.push(sourceRow[index]);
index++; index++;
@@ -181,8 +179,14 @@ function appendMissingCells (
destRow.push({ destRow.push({
displayValue: '', displayValue: '',
parents: { parents: {
dimension1: { elementNumber: dim1ElementNumber }, dimension1: {
dimension2: { elementNumber: dim2ElementNumber }, elementNumber: dim1[matrixIndex].elementNumber,
header: dim1[matrixIndex].displayValue
},
dimension2: {
elementNumber: dim2.elementNumber,
header: dim2.displayValue
},
measurement: { measurement: {
header: measurement.name, header: measurement.name,
index: measureIndex index: measureIndex
@@ -194,12 +198,10 @@ function appendMissingCells (
return index; return index;
} }
function initializeTransformed ({ $element, component, dataCube, designList, layout }) { function initializeTransformed ({ component, dataCube, designList, layout }) {
const dimensionsInformation = component.backendApi.getDimensionInfos(); const dimensionsInformation = component.backendApi.getDimensionInfos();
const measurementsInformation = component.backendApi.getMeasureInfos(); const measurementsInformation = component.backendApi.getMeasureInfos();
const dimensionCount = layout.qHyperCube.qDimensionInfo.length; const dimensionCount = layout.qHyperCube.qDimensionInfo.length;
const rowCount = component.backendApi.getRowCount();
const maxLoops = layout.maxloops;
const { const {
dimension1, dimension1,
dimension2, dimension2,
@@ -250,8 +252,7 @@ function initializeTransformed ({ $element, component, dataCube, designList, lay
}, },
matrix, // 2d array of all rows/cells to render in body of datatable matrix, // 2d array of all rows/cells to render in body of datatable
meta: { meta: {
dimensionCount: dimensionsInformation.length, dimensionCount: dimensionsInformation.length
altState: layout.qStateName || ""
} }
}, },
general: { general: {
@@ -260,7 +261,6 @@ function initializeTransformed ({ $element, component, dataCube, designList, lay
cellWidth: cellWidth, cellWidth: cellWidth,
errorMessage: layout.errormessage, errorMessage: layout.errormessage,
footnote: layout.footnote, footnote: layout.footnote,
maxLoops,
subtitle: layout.subtitle, subtitle: layout.subtitle,
title: layout.title, title: layout.title,
useColumnSeparator: layout.separatorcols && dimensionCount > 1 useColumnSeparator: layout.separatorcols && dimensionCount > 1
@@ -321,20 +321,6 @@ function initializeTransformed ({ $element, component, dataCube, designList, lay
} }
}; };
if (rowCount > lastRow && rowCount <= (maxLoops * 1000)) {
const requestPage = [
{
qHeight: Math.min(1000, rowCount - lastRow),
qLeft: 0,
qTop: matrix.length,
qWidth: 10 // should be # of columns
}
];
component.backendApi.getData(requestPage).then(() => {
component.paint($element, layout);
});
}
return transformedProperties; return transformedProperties;
} }

View File

@@ -33,7 +33,7 @@ class LinkedScrollWrapper extends React.PureComponent {
unlinkComponent (component) { unlinkComponent (component) {
const componentIndex = this.scrollElements.map(element => element.component).indexOf(component); const componentIndex = this.scrollElements.map(element => element.component).indexOf(component);
if (componentIndex !== -1) { if (componentIndex !== -1) {
this.scrollElements.removeAt(componentIndex); this.scrollElements.splice(componentIndex, 1);
// eslint-disable-next-line react/no-find-dom-node // eslint-disable-next-line react/no-find-dom-node
const node = ReactDOM.findDOMNode(component); const node = ReactDOM.findDOMNode(component);
node.onscroll = null; node.onscroll = null;

View File

@@ -105,6 +105,20 @@
width: 100%; width: 100%;
} }
.error {
position: absolute; /*Define position */
width: 100%; /* Full width (cover the whole page) */
height: 100%; /* Full height (cover the whole page) */
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1000; /* Specify a stack order in case you're using a different order for other elements */
display: flex;
justify-content: center;
align-items: center;
}
.kpi-table .fdim-cells, .kpi-table .fdim-cells,
.data-table td { .data-table td {
line-height: 1em !important; line-height: 1em !important;

View File

@@ -1,8 +1,8 @@
import React from 'react'; import React from "react";
import PropTypes from 'prop-types'; import PropTypes from "prop-types";
import HeadersTable from './headers-table/index.jsx'; import HeadersTable from "./headers-table/index.jsx";
import DataTable from './data-table/index.jsx'; import DataTable from "./data-table/index.jsx";
import { LinkedScrollWrapper, LinkedScrollSection } from './linked-scroll'; import { LinkedScrollWrapper, LinkedScrollSection } from "./linked-scroll";
class Root extends React.PureComponent { class Root extends React.PureComponent {
constructor (props) { constructor (props) {
@@ -12,9 +12,12 @@ class Root extends React.PureComponent {
} }
componentDidUpdate () { componentDidUpdate () {
const tableWidth = this.dataTableRef.getBoundingClientRect().width; let tableWidth;
if (this.renderedTableWidth !== tableWidth) { if (this.dataTableRef) {
this.forceUpdate(); tableWidth = this.dataTableRef.getBoundingClientRect().width;
if (this.renderedTableWidth !== tableWidth) {
this.forceUpdate();
}
} }
} }
@@ -25,7 +28,7 @@ class Root extends React.PureComponent {
render () { render () {
const { editmodeClass, component, state } = this.props; const { editmodeClass, component, state } = this.props;
const { data, general, styling } = state; const { data, general, styling, error } = state;
// Determine cell- and column separator width // Determine cell- and column separator width
let cellWidth = '0px'; let cellWidth = '0px';
@@ -48,72 +51,80 @@ class Root extends React.PureComponent {
let separatorWidth = 0; let separatorWidth = 0;
if (general.useColumnSeparator) { if (general.useColumnSeparator) {
separatorCount = data.headers.dimension2.length - 1; separatorCount = data.headers.dimension2.length - 1;
separatorWidth = Math.min(Math.floor(tableWidth * 0.2 / separatorCount), 8); separatorWidth = Math.min(
Math.floor((tableWidth * 0.2) / separatorCount),
8
);
columnSeparatorWidth = `${separatorWidth}px`; columnSeparatorWidth = `${separatorWidth}px`;
} }
const separatorWidthSum = (separatorWidth + borderWidth) * separatorCount; const separatorWidthSum =
cellWidth = `${Math.floor((tableWidth - separatorWidthSum - headerMarginRight - borderWidth) (separatorWidth + borderWidth) * separatorCount;
/ rowCellCount) - borderWidth}px`; cellWidth = `${Math.floor(
(tableWidth - separatorWidthSum - headerMarginRight - borderWidth) /
rowCellCount) - borderWidth}px`;
} }
} }
return ( return (
<div className="root"> <div className="root">
<LinkedScrollWrapper> {error ? (
<div className={`kpi-table ${editmodeClass}`}> <div className={`error ${editmodeClass}`}>
<HeadersTable {state.layout.errormessage}
cellWidth={cellWidth}
columnSeparatorWidth={columnSeparatorWidth}
component={component}
data={data}
general={general}
isKpi
styling={styling}
/>
<LinkedScrollSection linkVertical>
<DataTable
cellWidth={cellWidth}
columnSeparatorWidth={columnSeparatorWidth}
component={component}
data={data}
general={general}
renderData={false}
styling={styling}
/>
</LinkedScrollSection>
</div> </div>
<div ) : (
className={`data-table ${editmodeClass}`} <LinkedScrollWrapper>
style={{ width: general.cellWidth ? 'auto' : '100%' }} <div className={`kpi-table ${editmodeClass}`}>
ref={this.onDataTableRefSet}
>
<LinkedScrollSection linkHorizontal>
<HeadersTable <HeadersTable
cellWidth={cellWidth} cellWidth={cellWidth}
columnSeparatorWidth={columnSeparatorWidth} columnSeparatorWidth={columnSeparatorWidth}
component={component} component={component}
data={data} data={data}
general={general} general={general}
isKpi={false} isKpi
styling={styling} styling={styling}
/> />
</LinkedScrollSection> <LinkedScrollSection linkVertical>
<LinkedScrollSection <DataTable
linkHorizontal cellWidth={cellWidth}
linkVertical columnSeparatorWidth={columnSeparatorWidth}
component={component}
data={data}
general={general}
renderData={false}
styling={styling}
/>
</LinkedScrollSection>
</div>
<div
className={`data-table ${editmodeClass}`}
style={{ width: general.cellWidth ? 'auto' : '100%' }}
ref={this.onDataTableRefSet}
> >
<DataTable <LinkedScrollSection linkHorizontal>
cellWidth={cellWidth} <HeadersTable
columnSeparatorWidth={columnSeparatorWidth} cellWidth={cellWidth}
component={component} columnSeparatorWidth={columnSeparatorWidth}
data={data} component={component}
general={general} data={data}
styling={styling} general={general}
/> isKpi={false}
</LinkedScrollSection> styling={styling}
</div> />
</LinkedScrollWrapper> </LinkedScrollSection>
<LinkedScrollSection linkHorizontal linkVertical>
<DataTable
cellWidth={cellWidth}
columnSeparatorWidth={columnSeparatorWidth}
component={component}
data={data}
general={general}
styling={styling}
/>
</LinkedScrollSection>
</div>
</LinkedScrollWrapper>
)}
</div> </div>
); );
} }
@@ -123,9 +134,9 @@ Root.propTypes = {
component: PropTypes.shape({}).isRequired, component: PropTypes.shape({}).isRequired,
editmodeClass: PropTypes.string.isRequired, editmodeClass: PropTypes.string.isRequired,
state: PropTypes.shape({ state: PropTypes.shape({
data: PropTypes.object.isRequired, data: PropTypes.object,
general: PropTypes.object.isRequired, general: PropTypes.object,
styling: PropTypes.object.isRequired styling: PropTypes.object
}).isRequired }).isRequired
}; };