Try remove layer

This commit is contained in:
lukasmartinelli 2016-09-09 19:23:18 +02:00
parent 2978210a4d
commit 416cf7e0af

View file

@ -79,7 +79,8 @@ export class NoLayer extends React.Component {
export class LayerPanel extends React.Component { export class LayerPanel extends React.Component {
static propTypes = { static propTypes = {
layer: React.PropTypes.object.isRequired, layer: React.PropTypes.object.isRequired,
styleManager: React.PropTypes.object.isRequired styleManager: React.PropTypes.object.isRequired,
destroyLayer: React.PropTypes.func.isRequired,
} }
static childContextTypes = { static childContextTypes = {
@ -184,7 +185,7 @@ export class LayerPanel extends React.Component {
<NavItem onClick={this.toggleVisibility.bind(this)}> <NavItem onClick={this.toggleVisibility.bind(this)}>
{visibleIcon} {visibleIcon}
</NavItem> </NavItem>
<NavItem> <NavItem onClick={(e) => this.props.destroyLayer(this.state.layer.id)}>
<MdDelete /> <MdDelete />
</NavItem> </NavItem>
</Toolbar> </Toolbar>
@ -202,10 +203,22 @@ export class LayerEditor extends React.Component {
styleManager: React.PropTypes.object.isRequired styleManager: React.PropTypes.object.isRequired
} }
destroyLayer(layerId) {
this.props.styleManager.changeStyle({
command: 'removeLayer',
args: [layerId]
})
}
render() { render() {
const layers = this.props.styleManager.layers() const layers = this.props.styleManager.layers()
const layerPanels = layers.map(layer => { const layerPanels = layers.map(layer => {
return <LayerPanel key={layer.id} layer={layer} styleManager={this.props.styleManager} /> return <LayerPanel
key={layer.id}
layer={layer}
destroyLayer={this.destroyLayer.bind(this)}
styleManager={this.props.styleManager}
/>
}); });
return <div> return <div>
@ -214,10 +227,6 @@ export class LayerEditor extends React.Component {
<Heading>Layers</Heading> <Heading>Layers</Heading>
</NavItem> </NavItem>
<Space auto x={1} /> <Space auto x={1} />
<Button>
<MdAddToPhotos />
Add Layer
</Button>
</Toolbar> </Toolbar>
<div className={scrollbars.darkScrollbar} style={{ <div className={scrollbars.darkScrollbar} style={{