mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 01:35:25 +01:00
Allow deleting active source
This commit is contained in:
parent
c7ac90ba15
commit
ba271e1fc6
1 changed files with 15 additions and 3 deletions
|
@ -64,7 +64,7 @@ function editorMode(source) {
|
||||||
return 'tilejson'
|
return 'tilejson'
|
||||||
}
|
}
|
||||||
|
|
||||||
class SourceEditorLayout extends React.Component {
|
class ActiveSourceTypeEditor extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
sourceId: React.PropTypes.string.isRequired,
|
sourceId: React.PropTypes.string.isRequired,
|
||||||
source: React.PropTypes.object.isRequired,
|
source: React.PropTypes.object.isRequired,
|
||||||
|
@ -87,7 +87,7 @@ class SourceEditorLayout extends React.Component {
|
||||||
<span style={{fontWeight: 700, fontSize: fontSizes[4], lineHeight: 2}}>#{this.props.sourceId}</span>
|
<span style={{fontWeight: 700, fontSize: fontSizes[4], lineHeight: 2}}>#{this.props.sourceId}</span>
|
||||||
<span style={{flexGrow: 1}} />
|
<span style={{flexGrow: 1}} />
|
||||||
<Button
|
<Button
|
||||||
onClick={this.props.onSourceDelete}
|
onClick={()=> this.props.onSourceDelete(this.props.sourceId)}
|
||||||
style={{backgroundColor: 'transparent'}}
|
style={{backgroundColor: 'transparent'}}
|
||||||
>
|
>
|
||||||
<DeleteIcon />
|
<DeleteIcon />
|
||||||
|
@ -192,13 +192,25 @@ class SourcesModal extends React.Component {
|
||||||
this.props.onStyleChanged(changedStyle)
|
this.props.onStyleChanged(changedStyle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteSource(sourceId) {
|
||||||
|
const remainingSources = { ...this.props.mapStyle.sources}
|
||||||
|
delete remainingSources[sourceId]
|
||||||
|
|
||||||
|
const changedStyle = {
|
||||||
|
...this.props.mapStyle,
|
||||||
|
sources: remainingSources
|
||||||
|
}
|
||||||
|
this.props.onStyleChanged(changedStyle)
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const activeSources = Object.keys(this.props.mapStyle.sources).map(sourceId => {
|
const activeSources = Object.keys(this.props.mapStyle.sources).map(sourceId => {
|
||||||
const source = this.props.mapStyle.sources[sourceId]
|
const source = this.props.mapStyle.sources[sourceId]
|
||||||
return <SourceEditorLayout
|
return <ActiveSourceTypeEditor
|
||||||
key={sourceId}
|
key={sourceId}
|
||||||
sourceId={sourceId}
|
sourceId={sourceId}
|
||||||
source={source}
|
source={source}
|
||||||
|
onSourceDelete={this.deleteSource.bind(this)}
|
||||||
/>
|
/>
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue