Skip to content

Commit

Permalink
Update: Tree picker node component to support child nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
pphminions committed Nov 21, 2016
1 parent 09d9e7e commit 049b353
Show file tree
Hide file tree
Showing 8 changed files with 11,596 additions and 12,452 deletions.
23,975 changes: 11,550 additions & 12,425 deletions dist/adslot-ui-main-ugly.js

Large diffs are not rendered by default.

38 changes: 17 additions & 21 deletions dist/adslot-ui-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/adslot-ui.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class AppComponent extends React.Component {
treePickerPureSubtree: [],
selectedNodes: [
{ id: '2', label: 'Norfolk Island', path: [{ id: '11', label: 'AU' }], type: '', isSelectable: false },
{ id: '3', label: 'Queensland', path: [{ id: '12', label: 'AU' }], type: '' },
{ id: '3', label: 'Queensland', path: [{ id: '12', label: 'AU' }], type: '', isChildNode: true },
],
searchBarString: '',
};
Expand Down
8 changes: 7 additions & 1 deletion src/components/adslotUi/TreePickerNodeComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ const TreePickerNodeComponent = ({

return (
<div className={`${baseClass}`}>
<GridRow dts={`${_.kebabCase(itemType)}-${node.id}`}>
<GridRow dts={`${_.kebabCase(itemType)}-${node.id}`} >
{node.isChildNode ?
<GridCell>
<div className="child-node-indent-spacer" />
</GridCell>
: null
}
{selected ?
<GridCell classSuffixes={['button']} dts="button-remove">
<Button
Expand Down
1 change: 1 addition & 0 deletions src/helpers/propTypes/TreePickerPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default {
).isRequired,
type: PropTypes.string.isRequired,
value: PropTypes.number,
isChildNode: PropTypes.bool,
}),
breadCrumbNode: PropTypes.shape({
id: PropTypes.string.isRequired,
Expand Down
4 changes: 4 additions & 0 deletions src/styles/adslotUi/TreePickerNode.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@
width: $button-size;
}
}

.child-node-indent-spacer {
padding-left: 20px;
}
}
18 changes: 15 additions & 3 deletions test/components/adslotUi/TreePickerNodeComponentTest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('TreePickerNodeComponent', () => {
/>);

const rowElement = component.find({ dts: `${_.kebabCase(itemType)}-${cbrNode.id}` });
const valueCellElement = rowElement.prop('children')[3];
const valueCellElement = rowElement.prop('children')[4];
expect(valueCellElement.props.children).to.equal('€20');
});

Expand All @@ -138,11 +138,23 @@ describe('TreePickerNodeComponent', () => {
const component = shallow(<TreePickerNodeComponent {...props} />);

const rowElement = component.find({ dts: `${_.kebabCase(itemType)}-${cbrNode.id}` });
expect(rowElement.prop('children')).to.have.length(5);
const valueCellElement = rowElement.prop('children')[3];
expect(rowElement.prop('children')).to.have.length(6);
const valueCellElement = rowElement.prop('children')[4];
expect(valueCellElement).to.be.a('null');
});

it('should have the child node cell for child nodes', () => {
const node = _.clone(cbrNode);
node.isChildNode = true;
const props = { itemType, node };
const component = shallow(<TreePickerNodeComponent {...props} />);

const rowElement = component.find({ dts: `${_.kebabCase(itemType)}-${cbrNode.id}` });
const cellElements = rowElement.find(GridCell);
const childCellElement = cellElements.first();
expect(childCellElement.children().prop('className')).to.equal('child-node-indent-spacer');
});

it('should fire expandNode when clicking on the `expand` cell', () => {
const nodes = [];
const expandNode = (node) => nodes.push(node);
Expand Down

0 comments on commit 049b353

Please sign in to comment.