diff --git a/src/dataset.js b/src/dataset.js index 07d2c89..aa8ee70 100644 --- a/src/dataset.js +++ b/src/dataset.js @@ -1,17 +1,12 @@ -import qlik from "qlik"; +import qlik from 'qlik'; -function createCube(definition, app) { - return new Promise((resolve) => { +function createCube (definition, app) { + return new Promise(resolve => { app.createCube(definition, resolve); }); } -async function buildDataCube( - originCubeDefinition, - originCube, - app, - requestPage -) { +async function buildDataCube (originCubeDefinition, originCube, app, requestPage) { const cubeDefinition = { ...originCubeDefinition, qInitialDataFetch: [ @@ -20,11 +15,11 @@ async function buildDataCube( qTop: requestPage === undefined ? 0 : requestPage[0].qTop, qLeft: 0, qHeight: 1000, - qWidth: originCube.qSize.qcx, - }, + qWidth: originCube.qSize.qcx + } ], qDimensions: [originCubeDefinition.qDimensions[0]], - qMeasures: originCubeDefinition.qMeasures, + qMeasures: originCubeDefinition.qMeasures }; if (originCube.qDimensionInfo.length === 2) { cubeDefinition.qDimensions.push(originCubeDefinition.qDimensions[1]); @@ -35,42 +30,37 @@ async function buildDataCube( return cubeMatrix; } -export async function initializeDataCube(component, layout) { +export async function initializeDataCube (component, layout) { + if (component.backendApi.isSnapshot) { return layout.snapshotData.dataCube; } 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 let hyperCubeDef = properties.qExtendsId - ? (await app.getObjectProperties(properties.qExtendsId)).properties - .qHyperCubeDef + ? (await app.getObjectProperties(properties.qExtendsId)).properties.qHyperCubeDef : properties.qHyperCubeDef; hyperCubeDef = JSON.parse(JSON.stringify(hyperCubeDef)); hyperCubeDef.qStateName = layout.qStateName; const pagedCube = {}; let lastRow = 0; - if (cellCount < maxLoops * 10000) { + 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 - }, + qWidth: 10 // should be # of columns + } ]; // eslint-disable-next-line no-await-in-loop - pagedCube[index] = await buildDataCube( - hyperCubeDef, - layout.qHyperCube, - app, - requestPage - ); + pagedCube[index] = await buildDataCube(hyperCubeDef, layout.qHyperCube, app, requestPage); lastRow = lastRow + 1000; } return pagedCube; @@ -78,7 +68,7 @@ export async function initializeDataCube(component, layout) { return null; } -export function initializeDesignList(component, layout) { +export function initializeDesignList (component, layout) { if (component.backendApi.isSnapshot) { return layout.snapshotData.designList; } @@ -87,11 +77,11 @@ export function initializeDesignList(component, layout) { return null; } - return new Promise((resolve) => { + return new Promise(resolve => { const app = qlik.currApp(component); const stylingField = app.field(layout.stylingfield); const listener = function () { - const data = stylingField.rows.map((row) => row.qText); + const data = stylingField.rows.map(row => row.qText); stylingField.OnData.unbind(listener); resolve(data); }; diff --git a/src/index.js b/src/index.js index 460141f..b6e7264 100644 --- a/src/index.js +++ b/src/index.js @@ -108,7 +108,7 @@ export default { async getContextMenu (obj, menu) { const app = qlik.currApp(this); const isPersonalResult = await app.global.isPersonalMode(); - // This check is done because the desktop wrapper blocks downloads. + // This check is done because the desktop wrapper blocks downloads. // It also blocks this feature in QCS currently as isPersonalMode returns true if ( !this.$scope.layout.allowexportxls ||