mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-11-10 06:17:44 +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'
|
||||
}
|
||||
|
||||
class SourceEditorLayout extends React.Component {
|
||||
class ActiveSourceTypeEditor extends React.Component {
|
||||
static propTypes = {
|
||||
sourceId: React.PropTypes.string.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={{flexGrow: 1}} />
|
||||
<Button
|
||||
onClick={this.props.onSourceDelete}
|
||||
onClick={()=> this.props.onSourceDelete(this.props.sourceId)}
|
||||
style={{backgroundColor: 'transparent'}}
|
||||
>
|
||||
<DeleteIcon />
|
||||
|
@ -192,13 +192,25 @@ class SourcesModal extends React.Component {
|
|||
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() {
|
||||
const activeSources = Object.keys(this.props.mapStyle.sources).map(sourceId => {
|
||||
const source = this.props.mapStyle.sources[sourceId]
|
||||
return <SourceEditorLayout
|
||||
return <ActiveSourceTypeEditor
|
||||
key={sourceId}
|
||||
sourceId={sourceId}
|
||||
source={source}
|
||||
onSourceDelete={this.deleteSource.bind(this)}
|
||||
/>
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue