diff --git a/app/src/frontend/building-edit.js b/app/src/frontend/building-edit.js index 10b47c34..8d8a7838 100644 --- a/app/src/frontend/building-edit.js +++ b/app/src/frontend/building-edit.js @@ -11,7 +11,7 @@ class BuildingEdit extends Component { const user = props.user || {}; this.state = { error: undefined, - id: props.id, + building_id: props.building_id, geometry_id: props.geometry_id, location_name: props.location_name, location_number: props.location_number, @@ -22,12 +22,15 @@ class BuildingEdit extends Component { date_lower: props.date_lower, date_upper: props.date_upper, date_source: props.date_source, - date_facade: props.date_facade, + facade_year: props.facade_year, + facade_upper: props.facade_upper, + facade_lower: props.facade_lower, + facade_source: props.facade_source, size_attic: props.size_attic, size_core: props.size_core, size_basement: props.size_basement, - likes: props.likes || [], - liked: this.user_likes(user.id, props.likes) + likes_total: props.likes_total, + liked: props.liked }; this.handleChange = this.handleChange.bind(this); @@ -35,10 +38,6 @@ class BuildingEdit extends Component { this.handleSubmit = this.handleSubmit.bind(this); } - user_likes(user_id, likes) { - return likes && likes.indexOf(user_id) !== -1; - } - handleChange(event) { const target = event.target; const value = target.value; @@ -69,7 +68,7 @@ class BuildingEdit extends Component { event.preventDefault(); this.setState({error: undefined}) - fetch(`/building/${this.props.id}.json`, { + fetch(`/building/${this.props.building_id}.json`, { method: 'POST', body: JSON.stringify(this.state), headers:{ @@ -83,7 +82,7 @@ class BuildingEdit extends Component { this.setState({error: res.error}) } else { this.props.selectBuilding(this.state); // could use server response? - this.props.history.push(`/building/${this.state.id}.html`); + this.props.history.push(`/building/${this.props.building_id}.html`); } }.bind(this)).catch( (err) => this.setState({error: err}) @@ -94,7 +93,7 @@ class BuildingEdit extends Component { if (!this.props.user){ return } - if (!this.props.id){ + if (!this.props.building_id){ return ( @@ -105,7 +104,7 @@ class BuildingEdit extends Component { ); } return ( - +
@@ -238,7 +237,7 @@ class BuildingEdit extends Component {
- Cancel + Cancel
diff --git a/app/src/frontend/building-view.js b/app/src/frontend/building-view.js index 5e12c003..10ce5bba 100644 --- a/app/src/frontend/building-view.js +++ b/app/src/frontend/building-view.js @@ -6,7 +6,7 @@ import Tooltip from './tooltip'; import InfoBox from './info-box'; const BuildingView = function(props){ - if (!props.id){ + if (!props.building_id){ return ( @@ -17,7 +17,7 @@ const BuildingView = function(props){ ); } return ( - +

Location

@@ -80,7 +80,7 @@ const BuildingView = function(props){

Back to maps - Edit data + Edit data
); diff --git a/app/src/frontend/map.js b/app/src/frontend/map.js index c81f618b..8e3b6f7e 100644 --- a/app/src/frontend/map.js +++ b/app/src/frontend/map.js @@ -32,9 +32,10 @@ class ColouringMap extends Component { ).then( (res) => res.json() ).then(function(data){ - if (data.geometry_id && data.id){ - this.props.selectBuilding(data); - this.props.history.push(`/building/${data.id}.html`); + if (data && data.length){ + const building = data[0]; + this.props.selectBuilding(building); + this.props.history.push(`/building/${building.building_id}.html`); } else { // should deselect but keep/return to expected colour theme // this.props.selectBuilding(undefined); @@ -77,8 +78,8 @@ class ColouringMap extends Component { // highlight const geometry_id = (this.props.building) ? this.props.building.geometry_id : undefined; const highlight = `/tiles/highlight/{z}/{x}/{y}.png?highlight=${geometry_id}` - const highlightLayer = is_building ? ( - + const highlightLayer = (is_building && this.props.building) ? ( + ) : null; return (