From e524765c13d70d9857f1c69250993ac28551c7f7 Mon Sep 17 00:00:00 2001 From: lukasmartinelli Date: Wed, 21 Sep 2016 22:47:17 +0200 Subject: [PATCH] Add support to change source TileJSON url --- src/sources/editor.jsx | 9 ++++++++- src/sources/list.jsx | 7 +++++++ src/workspace.jsx | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/sources/editor.jsx b/src/sources/editor.jsx index 7580ff8a..9cf2c705 100644 --- a/src/sources/editor.jsx +++ b/src/sources/editor.jsx @@ -21,6 +21,7 @@ class UnsupportedSource extends React.Component { class VectorSource extends React.Component { static propTypes = { source: React.PropTypes.instanceOf(Immutable.Map).isRequired, + onSourceChanged: React.PropTypes.func.isRequired, } constructor(props) { @@ -30,7 +31,11 @@ class VectorSource extends React.Component { render() { return
- + this.props.onSourceChanged(this.props.source.set('url', e.target.value))} + name="url" label="TileJSON url" + value={this.props.source.get("url")} + />
@@ -41,6 +46,7 @@ export class SourceEditor extends React.Component { static propTypes = { sourceId: React.PropTypes.string.isRequired, source: React.PropTypes.instanceOf(Immutable.Map).isRequired, + onSourceChanged: React.PropTypes.func.isRequired, } constructor(props) { @@ -58,6 +64,7 @@ export class SourceEditor extends React.Component { sourceFromType(type) { if (type === "vector") { return this.props.onSourceChanged(this.props.sourceId, s)} source={this.props.source} /> } diff --git a/src/sources/list.jsx b/src/sources/list.jsx index 061a3d71..19b67fdf 100644 --- a/src/sources/list.jsx +++ b/src/sources/list.jsx @@ -14,6 +14,7 @@ import PureRenderMixin from 'react-addons-pure-render-mixin'; export class SourceList extends React.Component { static propTypes = { sources: React.PropTypes.instanceOf(Immutable.Map).isRequired, + onSourcesChanged: React.PropTypes.func.isRequired, } constructor(props) { @@ -21,12 +22,18 @@ export class SourceList extends React.Component { this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this); } + onSourceChanged(sourceId, changedSource) { + const changedSources = this.props.sources.set(sourceId, changedSource) + this.props.onSourcesChanged(changedSources) + } + render() { const sourceEditors = this.props.sources.map((source, sourceId) => { return }).toIndexedSeq() diff --git a/src/workspace.jsx b/src/workspace.jsx index 63c6a89a..69f1ca73 100644 --- a/src/workspace.jsx +++ b/src/workspace.jsx @@ -22,11 +22,17 @@ export class WorkspaceDrawer extends React.Component { this.props.onStyleChanged(changedStyle) } + onSourcesChanged(changedSources) { + const changedStyle = this.props.mapStyle.set('sources', changedSources) + this.props.onStyleChanged(changedStyle) + } + render() { let workspaceContent = null if(this.props.workContext === "sources") { workspaceContent = }