picasso.js
Advanced tools
Comparing version 0.18.1 to 0.18.2
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.18.2](https://github.com/qlik-oss/picasso.js/compare/v0.18.1...v0.18.2) (2018-12-10) | ||
### Reverts | ||
* "fix(dock-layout): remove components that are docked at hidden components ([#261](https://github.com/qlik-oss/picasso.js/issues/261))" ([d923123](https://github.com/qlik-oss/picasso.js/commit/d923123)) | ||
## [0.18.1](https://github.com/qlik-oss/picasso.js/compare/v0.18.0...v0.18.1) (2018-12-04) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "picasso.js", | ||
"version": "0.18.1", | ||
"version": "0.18.2", | ||
"description": "A charting library streamlined for building visualizations for the Qlik Sense Analytics platform.", | ||
@@ -49,6 +49,6 @@ "license": "MIT", | ||
"path2d-polyfill": "0.3.1", | ||
"preact": "^8.3.1", | ||
"test-utils": "^0.18.1" | ||
"preact": "^8.4.2", | ||
"test-utils": "^0.18.2" | ||
}, | ||
"gitHead": "889b8271e8f83c6c2ab06c8555f5c1bef5032ead" | ||
"gitHead": "555e5ece01982a153e30e5785f0c0094217df3b9" | ||
} |
@@ -1,1 +0,1 @@ | ||
export default { version: '0.18.1' }; | ||
export default { version: '0.18.2' }; |
@@ -12,4 +12,3 @@ import dockLayout from '../dock-layout'; | ||
minimumLayoutMode, | ||
show = true, | ||
ctx = {} | ||
show = true | ||
} = {}) { | ||
@@ -47,4 +46,2 @@ let outerRect = { | ||
dummy.ctx = ctx; | ||
return dummy; | ||
@@ -176,63 +173,2 @@ }; | ||
it('should remove component that are docked to another component which does not fit', () => { | ||
const leftComp = componentMock({ dock: 'left', size: 0.30 }); | ||
const leftComp2 = componentMock({ dock: 'left', size: 0.30, ctx: { key: 'notFit' } }); | ||
const leftComp3 = componentMock({ dock: '@notFit', size: 0.30 }); | ||
const mainComp = componentMock(); | ||
const rect = { | ||
x: 0, y: 0, width: 1000, height: 1000 | ||
}; | ||
const dl = dockLayout(); | ||
dl.addComponent(leftComp); | ||
dl.addComponent(leftComp2); | ||
dl.addComponent(leftComp3); | ||
dl.addComponent(mainComp); | ||
dl.layout(rect); | ||
expect(leftComp.resize().innerRect, 'leftComp innerRect had incorrect calculated size').to.deep.include({ | ||
x: 0, y: 0, width: 300, height: 1000 | ||
}); | ||
expect(leftComp2.resize().innerRect, 'leftComp2 innerRect had incorrect calculated size').to.deep.include({ | ||
x: 0, y: 0, width: 0, height: 0 | ||
}); | ||
expect(leftComp3.resize().innerRect, 'leftComp3 innerRect had incorrect calculated size').to.deep.include({ | ||
x: 0, y: 0, width: 0, height: 0 | ||
}); | ||
expect(mainComp.resize().innerRect, 'Main innerRect had incorrect calculated size').to.deep.include({ | ||
x: 300, y: 0, width: 700, height: 1000 | ||
}); | ||
}); | ||
it('should keep component because one of the referenced components are shown', () => { | ||
const leftComp = componentMock({ dock: 'left', size: 0.30, ctx: { key: 'fit' } }); | ||
const leftComp2 = componentMock({ dock: 'left', size: 0.30, ctx: { key: 'notFit' } }); | ||
const leftComp3 = componentMock({ dock: '@fit, @notFit', size: 0.30 }); | ||
const mainComp = componentMock(); | ||
const rect = { | ||
x: 0, y: 0, width: 1000, height: 1000 | ||
}; | ||
const dl = dockLayout(); | ||
dl.addComponent(leftComp, 'fit'); | ||
dl.addComponent(leftComp2); | ||
dl.addComponent(leftComp3); | ||
dl.addComponent(mainComp); | ||
dl.layout(rect); | ||
// leftComp3 should be docked on top of leftComp | ||
expect(leftComp.resize().innerRect, 'leftComp innerRect had incorrect calculated size').to.deep.include({ | ||
x: 0, y: 0, width: 300, height: 1000 | ||
}); | ||
expect(leftComp2.resize().innerRect, 'leftComp2 innerRect had incorrect calculated size').to.deep.include({ | ||
x: 0, y: 0, width: 0, height: 0 | ||
}); | ||
expect(leftComp3.resize().innerRect, 'leftComp3 innerRect had incorrect calculated size').to.deep.include({ | ||
x: 0, y: 0, width: 300, height: 1000 | ||
}); | ||
expect(mainComp.resize().innerRect, 'Main innerRect had incorrect calculated size').to.deep.include({ | ||
x: 300, y: 0, width: 700, height: 1000 | ||
}); | ||
}); | ||
describe('Settings', () => { | ||
@@ -239,0 +175,0 @@ let settings; |
@@ -98,50 +98,2 @@ import extend from 'extend'; | ||
/** | ||
* Updates the visible and hidden components based on components that are docked to other components. | ||
* For example, assume a component called myRect: | ||
* { | ||
* key: 'myRect', | ||
* type: 'rect', | ||
* dock: 'bottom' | ||
* } | ||
* and a component called myLine: | ||
* { | ||
* key: 'myLine', | ||
* type: 'line', | ||
* dock: '@myRect' | ||
* } | ||
* if the layout engine decides to hide myRect, then myLine should be hidden as well. | ||
* @param {Array} components - Components to be decided if they should be hidden or not. | ||
* @param {Array} hiddenComponents - Components that are already hidden. | ||
* @returns {Object} containing the new visible components and additional components to be hidden. | ||
* @ignore | ||
*/ | ||
function updateForComponentsDockedAtRemovedComponents(components, hiddenComponents) { | ||
if (hiddenComponents.length === 0) { | ||
return { visibleComponents: components, dockedAtRemovedComponents: [] }; | ||
} | ||
const dockedAtRemovedComponents = []; | ||
const visibleComponents = components.filter((comp) => { | ||
if (comp.referencedDocks.length === 0) { | ||
return true; | ||
} | ||
const isAllHidden = comp.referencedDocks.every(refDock => hiddenComponents.some((hiddenComp) => { | ||
const key = hiddenComp.ctx && hiddenComp.ctx.key; | ||
return refDock === key; | ||
})); | ||
if (isAllHidden) { | ||
dockedAtRemovedComponents.push(comp.instance); | ||
} | ||
return !isAllHidden; | ||
}); | ||
return { visibleComponents, dockedAtRemovedComponents }; | ||
} | ||
function reduceLayoutRect(logicalContainerRect, components, hiddenComponents, settings) { | ||
@@ -172,6 +124,3 @@ const reducedRect = { | ||
const { visibleComponents, dockedAtRemovedComponents } = updateForComponentsDockedAtRemovedComponents(sortedComponents, hiddenComponents); | ||
hiddenComponents.push(...dockedAtRemovedComponents); | ||
const filteredUnsortedComps = components.filter(c => visibleComponents.indexOf(c) !== -1); | ||
const filteredUnsortedComps = components.filter(c => sortedComponents.indexOf(c) !== -1); | ||
components.length = 0; | ||
@@ -229,6 +178,6 @@ components.push(...filteredUnsortedComps); | ||
components.sort((a, b) => { | ||
if (b.referencedDocks.length > 0) { | ||
if (/^@/.test(b.config.dock())) { | ||
return -1; | ||
} | ||
if (a.referencedDocks.length > 0) { | ||
if (/^@/.test(a.config.dock())) { | ||
return 1; | ||
@@ -294,4 +243,4 @@ } | ||
} | ||
if (c.referencedDocks.length > 0) { | ||
const refs = c.referencedDocks.map(r => referencedComponents[r]).filter(r => !!r); | ||
if (/^@/.test(d)) { | ||
const refs = d.split(',').map(r => referencedComponents[r.replace('@', '')]).filter(r => !!r); | ||
if (refs.length > 0) { | ||
@@ -366,9 +315,6 @@ outerRect = boundingBox(refs.map(r => r.outerRect)); | ||
const dock = component.dockConfig().dock(); | ||
components.push({ | ||
instance: component, | ||
key, | ||
config: component.dockConfig(), | ||
referencedDocks: /^@/.test(dock) ? dock.split(',').map(s => s.replace(/^\s*@/, '')) : [] | ||
config: component.dockConfig() | ||
}); | ||
@@ -375,0 +321,0 @@ }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
5979290
79582