mirror of
https://github.com/qlik-oss/nebula.js.git
synced 2025-12-19 17:58:43 -05:00
fix(supernova): inject default values (#311)
This commit is contained in:
@@ -31,6 +31,17 @@ describe('hc-handler', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should add default values', () => {
|
||||||
|
expect(hc).to.eql({
|
||||||
|
qDimensions: [],
|
||||||
|
qMeasures: [],
|
||||||
|
qInterColumnSortOrder: [],
|
||||||
|
qInitialDataFetch: [],
|
||||||
|
qColumnOrder: [],
|
||||||
|
qExpansionState: [],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('add dimension', () => {
|
describe('add dimension', () => {
|
||||||
it('from string', () => {
|
it('from string', () => {
|
||||||
h.addDimension('A');
|
h.addDimension('A');
|
||||||
@@ -47,6 +58,9 @@ describe('hc-handler', () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
qAttributeDimensions: [],
|
||||||
|
qAttributeExpressions: [],
|
||||||
|
qOtherTotalSpec: {},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
@@ -59,8 +73,18 @@ describe('hc-handler', () => {
|
|||||||
{
|
{
|
||||||
qDef: {
|
qDef: {
|
||||||
cId: 'uid',
|
cId: 'uid',
|
||||||
|
qSortCriterias: [
|
||||||
|
{
|
||||||
|
qSortByLoadOrder: 1,
|
||||||
|
qSortByNumeric: 1,
|
||||||
|
qSortByAscii: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
qTotalLabel: 'total',
|
qTotalLabel: 'total',
|
||||||
|
qAttributeDimensions: [],
|
||||||
|
qAttributeExpressions: [],
|
||||||
|
qOtherTotalSpec: {},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
@@ -77,7 +101,19 @@ describe('hc-handler', () => {
|
|||||||
expect(def.dimensions.added).to.have.been.calledWithExactly(
|
expect(def.dimensions.added).to.have.been.calledWithExactly(
|
||||||
{
|
{
|
||||||
a: 'b',
|
a: 'b',
|
||||||
qDef: { cId: 'uid' },
|
qDef: {
|
||||||
|
cId: 'uid',
|
||||||
|
qSortCriterias: [
|
||||||
|
{
|
||||||
|
qSortByLoadOrder: 1,
|
||||||
|
qSortByNumeric: 1,
|
||||||
|
qSortByAscii: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
qAttributeDimensions: [],
|
||||||
|
qAttributeExpressions: [],
|
||||||
|
qOtherTotalSpec: {},
|
||||||
},
|
},
|
||||||
'props'
|
'props'
|
||||||
);
|
);
|
||||||
@@ -87,7 +123,24 @@ describe('hc-handler', () => {
|
|||||||
h.addDimension('A');
|
h.addDimension('A');
|
||||||
h.addDimension('B');
|
h.addDimension('B');
|
||||||
h.addDimension({ a: '=a' });
|
h.addDimension({ a: '=a' });
|
||||||
expect(hc.qLayoutExclude.qHyperCubeDef.qDimensions).to.eql([{ a: '=a', qDef: { cId: 'uid' } }]);
|
expect(hc.qLayoutExclude.qHyperCubeDef.qDimensions).to.eql([
|
||||||
|
{
|
||||||
|
a: '=a',
|
||||||
|
qDef: {
|
||||||
|
cId: 'uid',
|
||||||
|
qSortCriterias: [
|
||||||
|
{
|
||||||
|
qSortByLoadOrder: 1,
|
||||||
|
qSortByNumeric: 1,
|
||||||
|
qSortByAscii: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
qAttributeDimensions: [],
|
||||||
|
qAttributeExpressions: [],
|
||||||
|
qOtherTotalSpec: {},
|
||||||
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update qInterColumnSortOrder', () => {
|
it('should update qInterColumnSortOrder', () => {
|
||||||
@@ -132,6 +185,8 @@ describe('hc-handler', () => {
|
|||||||
qSortByLoadOrder: 1,
|
qSortByLoadOrder: 1,
|
||||||
qSortByNumeric: -1,
|
qSortByNumeric: -1,
|
||||||
},
|
},
|
||||||
|
qAttributeDimensions: [],
|
||||||
|
qAttributeExpressions: [],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
@@ -146,6 +201,12 @@ describe('hc-handler', () => {
|
|||||||
cId: 'uid',
|
cId: 'uid',
|
||||||
},
|
},
|
||||||
bla: 'meh',
|
bla: 'meh',
|
||||||
|
qSortBy: {
|
||||||
|
qSortByLoadOrder: 1,
|
||||||
|
qSortByNumeric: -1,
|
||||||
|
},
|
||||||
|
qAttributeDimensions: [],
|
||||||
|
qAttributeExpressions: [],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
@@ -164,6 +225,12 @@ describe('hc-handler', () => {
|
|||||||
{
|
{
|
||||||
a: 'b',
|
a: 'b',
|
||||||
qDef: { cId: 'uid' },
|
qDef: { cId: 'uid' },
|
||||||
|
qSortBy: {
|
||||||
|
qSortByLoadOrder: 1,
|
||||||
|
qSortByNumeric: -1,
|
||||||
|
},
|
||||||
|
qAttributeDimensions: [],
|
||||||
|
qAttributeExpressions: [],
|
||||||
},
|
},
|
||||||
'props'
|
'props'
|
||||||
);
|
);
|
||||||
@@ -174,7 +241,18 @@ describe('hc-handler', () => {
|
|||||||
h.addMeasure('B');
|
h.addMeasure('B');
|
||||||
h.addMeasure('C');
|
h.addMeasure('C');
|
||||||
h.addMeasure({ a: '=a' });
|
h.addMeasure({ a: '=a' });
|
||||||
expect(hc.qLayoutExclude.qHyperCubeDef.qMeasures).to.eql([{ a: '=a', qDef: { cId: 'uid' } }]);
|
expect(hc.qLayoutExclude.qHyperCubeDef.qMeasures).to.eql([
|
||||||
|
{
|
||||||
|
a: '=a',
|
||||||
|
qDef: { cId: 'uid' },
|
||||||
|
qSortBy: {
|
||||||
|
qSortByLoadOrder: 1,
|
||||||
|
qSortByNumeric: -1,
|
||||||
|
},
|
||||||
|
qAttributeDimensions: [],
|
||||||
|
qAttributeExpressions: [],
|
||||||
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update qInterColumnSortOrder', () => {
|
it('should update qInterColumnSortOrder', () => {
|
||||||
|
|||||||
@@ -26,13 +26,6 @@ function removeIndex(array, index) {
|
|||||||
const nxDimension = f => ({
|
const nxDimension = f => ({
|
||||||
qDef: {
|
qDef: {
|
||||||
qFieldDefs: [f],
|
qFieldDefs: [f],
|
||||||
qSortCriterias: [
|
|
||||||
{
|
|
||||||
qSortByLoadOrder: 1,
|
|
||||||
qSortByNumeric: 1,
|
|
||||||
qSortByAscii: 1,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -40,16 +33,15 @@ const nxMeasure = f => ({
|
|||||||
qDef: {
|
qDef: {
|
||||||
qDef: f,
|
qDef: f,
|
||||||
},
|
},
|
||||||
qSortBy: {
|
|
||||||
qSortByLoadOrder: 1,
|
|
||||||
qSortByNumeric: -1,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function hcHandler({ hc, def, properties }) {
|
export default function hcHandler({ hc, def, properties }) {
|
||||||
hc.qDimensions = hc.qDimensions || [];
|
hc.qDimensions = hc.qDimensions || [];
|
||||||
hc.qMeasures = hc.qMeasures || [];
|
hc.qMeasures = hc.qMeasures || [];
|
||||||
hc.qInterColumnSortOrder = hc.qInterColumnSortOrder || [];
|
hc.qInterColumnSortOrder = hc.qInterColumnSortOrder || [];
|
||||||
|
hc.qInitialDataFetch = hc.qInitialDataFetch || [];
|
||||||
|
hc.qColumnOrder = hc.qColumnOrder || [];
|
||||||
|
hc.qExpansionState = hc.qExpansionState || [];
|
||||||
|
|
||||||
const objectProperties = properties;
|
const objectProperties = properties;
|
||||||
|
|
||||||
@@ -69,12 +61,24 @@ export default function hcHandler({ hc, def, properties }) {
|
|||||||
qDef: d.qDef || {},
|
qDef: d.qDef || {},
|
||||||
};
|
};
|
||||||
dimension.qDef.cId = dimension.qDef.cId || uid();
|
dimension.qDef.cId = dimension.qDef.cId || uid();
|
||||||
if (!dimension.qDef.cId) {
|
|
||||||
dimension.qDef.cId = uid();
|
// ====== add default objects and arrays for NxDimension =====
|
||||||
}
|
|
||||||
|
// TODO - apply autosort properties based on tags
|
||||||
|
dimension.qDef.qSortCriterias = dimension.qDef.qSortCriterias || [
|
||||||
|
{
|
||||||
|
qSortByLoadOrder: 1,
|
||||||
|
qSortByNumeric: 1,
|
||||||
|
qSortByAscii: 1,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
dimension.qOtherTotalSpec = dimension.qOtherTotalSpec || {};
|
||||||
|
dimension.qAttributeExpressions = dimension.qAttributeExpressions || [];
|
||||||
|
dimension.qAttributeDimensions = dimension.qAttributeDimensions || [];
|
||||||
|
// ========= end defaults =============
|
||||||
|
|
||||||
if (hc.qDimensions.length < h.maxDimensions()) {
|
if (hc.qDimensions.length < h.maxDimensions()) {
|
||||||
// TODO - apply autosort properties based on tags
|
|
||||||
hc.qDimensions.push(dimension);
|
hc.qDimensions.push(dimension);
|
||||||
addIndex(hc.qInterColumnSortOrder, hc.qDimensions.length - 1);
|
addIndex(hc.qInterColumnSortOrder, hc.qDimensions.length - 1);
|
||||||
def.dimensions.added(dimension, objectProperties);
|
def.dimensions.added(dimension, objectProperties);
|
||||||
@@ -101,9 +105,15 @@ export default function hcHandler({ hc, def, properties }) {
|
|||||||
qDef: m.qDef || {},
|
qDef: m.qDef || {},
|
||||||
};
|
};
|
||||||
measure.qDef.cId = measure.qDef.cId || uid();
|
measure.qDef.cId = measure.qDef.cId || uid();
|
||||||
if (!measure.qDef.cId) {
|
|
||||||
measure.qDef.cId = uid();
|
// ====== add default objects and arrays for NxMeasure =====
|
||||||
}
|
measure.qSortBy = measure.qSortBy || {
|
||||||
|
qSortByLoadOrder: 1,
|
||||||
|
qSortByNumeric: -1,
|
||||||
|
};
|
||||||
|
|
||||||
|
measure.qAttributeDimensions = measure.qAttributeDimensions || [];
|
||||||
|
measure.qAttributeExpressions = measure.qAttributeExpressions || [];
|
||||||
|
|
||||||
if (hc.qMeasures.length < h.maxMeasures()) {
|
if (hc.qMeasures.length < h.maxMeasures()) {
|
||||||
hc.qMeasures.push(measure);
|
hc.qMeasures.push(measure);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ export default function HyperCube({ model, target, properties }) {
|
|||||||
hcHandler({
|
hcHandler({
|
||||||
def: target,
|
def: target,
|
||||||
hc: getValue(properties, target.propertyPath),
|
hc: getValue(properties, target.propertyPath),
|
||||||
|
properties,
|
||||||
}),
|
}),
|
||||||
[properties]
|
[properties]
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user