Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development' into development
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/components/App.jsx
#	src/components/SidebarBuildingDetail.jsx
#	src/stores/BuildingStore.js
  • Loading branch information
HennecartLisa committed Jul 23, 2018
2 parents 7018e89 + d68b741 commit 5df5854
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 24 deletions.
72 changes: 67 additions & 5 deletions src/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,30 @@ export default class App extends React.Component {
return objects;
};

getBuilding = function(id){
let building = null;
for(let b in buildings){
if(buildings[b].props.id === id){
building = buildings[b];
}
}
return building;
}

getBuildingIndex = function(id){
let index = null;
for(let b in buildings){
if(buildings[b].props.id === id){
index = b;
}
}
return index;
}

checkIfBuildingExists = function (id){
return (this.getBuilding(id) !== null);
}

/**
* Get information of a public services based on the url
*/
Expand All @@ -54,7 +78,35 @@ export default class App extends React.Component {
for(let subject in objects){
let entity = objects[subject];
if(entity["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"] === "http://purl.org/vocab/cpsv#PublicService"){
// console.log(entity);
let idBuildingAdres = entity["http://www.w3.org/ns/locn#location"];
idBuildingAdres = "http://data.vlaanderen.be/id/adres/3743516";
let name = entity["http://schema.org/name"];
let desc = entity["http://schema.org/description"];

let accessInfo =objects[objects[entity["toevla:accessibilityMeasurement"]]["toevla:accessibilityMeasurement_for"]]; // not relevant for user
let accessObj = {description: "", width: 0};
accessObj.description = accessInfo["dcterms:description"];
accessObj.width = accessInfo["toevla:elevatorDoorWidth"];

let serviceObj = {
"name": name,
"desc": desc,
"accessinfo": accessObj
}

if(this.checkIfBuildingExists(idBuildingAdres)){
let b = this.getBuilding(idBuildingAdres);
let index = this.getBuildingIndex(idBuildingAdres);
let serviceArr = b.props.service;
serviceArr.push(serviceObj);
let comp = <Building id={idBuildingAdres} title={b.props.title} src={b.props.src} description={b.props.description}
lat={b.props.lat} long={b.props.long} service={serviceArr}/>;

buildings[index] = comp;
}else{
let comp = <Building id={idBuildingAdres} title={"Public Service"} src={""} description={"Not linked to a known building"} lat={0} long={0} service={[serviceObj]}/>;
buildings.push(comp);
}
}
}
}catch(e){
Expand Down Expand Up @@ -93,21 +145,31 @@ export default class App extends React.Component {
for(let subject in objects){
let entity = objects[subject];
if(entity["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"] === "http://data.vlaanderen.be/ns/gebouw#Gebouw"){
let idBuildingAdres = entity["http://data.vlaanderen.be/ns/gebouw#Gebouw.adres"];
let descr = this.getDescription(entity);
let location = this.getLocation(objects, entity);
let title = "Gebouw";
let src = "http://placekitten.com/200/300";

// Accessibility stuff
let door={description: "", width:0}
// let door={description: "", width:0}
// door.description = objects[objects[entity["http://semweb.mmlab.be/ns/wa#accessibilityMeasurement"]]["http://semweb.mmlab.be/ns/wa#accessibilityMeasurement_for"]]["http://purl.org/dc/terms/description"];
// door.width = objects[objects[entity["http://semweb.mmlab.be/ns/wa#accessibilityMeasurement"]]["http://semweb.mmlab.be/ns/wa#accessibilityMeasurement_for"]]["http://semweb.mmlab.be/ns/wa#entranceDoorWidth"];

let comp = <Building id={subject} title={title} src={src} description={descr} lat={parseFloat(location.lat)} long={parseFloat(location.long)} door={door}/>
buildings.push(comp);

if(this.checkIfBuildingExists(idBuildingAdres)){
let b = this.getBuilding(idBuildingAdres);
let index = this.getBuildingIndex(idBuildingAdres);
let comp = <Building id={idBuildingAdres} title={title} src={src} description={descr} lat={parseFloat(location.lat)} long={parseFloat(location.long)}
service={b.props.service}/>; // DO NOT FORGET TO ADD DOOR INFORMATION AGAIN
buildings[index] = comp;
}else{
let comp = <Building id={idBuildingAdres} title={title} src={src} description={descr} lat={parseFloat(location.lat)} long={parseFloat(location.long)}/>;
buildings.push(comp);
}
}
}
}catch(e){
console.log(e);
return;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Building.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ Building.propTypes = {
description: PropTypes.string,
lat: PropTypes.number,
long: PropTypes.number,
door: PropTypes.object
door: PropTypes.object,
service: PropTypes.array
}
8 changes: 2 additions & 6 deletions src/components/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,9 @@ export default class OpenStreetMap extends Component {
};

onClick = (e) => {
let building;
this.BuildingStore.getBuildings.forEach(element => {
if (element.props.lat === e.latlng.lat && element.props.long === e.latlng.lng) {
building = element;
}
});
let building = this.BuildingStore.getBuildings.find(b => b.props.lat === e.latlng.lat && b.props.long === e.latlng.lng);
this.BuildingStore.setBuilding(building);
this.BuildingStore.setIsInDetailState(false);
this.BuildingStore.setIsInDetailState(true);
}

Expand Down
47 changes: 43 additions & 4 deletions src/components/SidebarBuildingDetail.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {Component} from 'react'
import {Col, Row} from "react-materialize";
import {Col, Row, Collapsible, CollapsibleItem} from "react-materialize";
import {inject, observer} from 'mobx-react';


Expand All @@ -18,6 +18,43 @@ export default class SidebarBuildingDetail extends Component {
this.BuildingStore.setIsInDetailState(false);
}

showAccessibilityInformation = () => {
try{
let ar = [];
ar.push(<h4>Details</h4>);
ar.push(
<div>
<p><i className="material-icons">wheelchair</i> {this.Building.door.description}: {this.Building.door.width} cm</p>
<i className="material-icons">hearing</i>
<i className="material-icons">accessibility</i>
</div>)
return ar;
}catch(e){
return (<div><h4>Details</h4><p>No accessibility information available</p></div>);
}
}

showServices = () => {
try{
let ar = [];
ar.push(<h4>Services</h4>);
for(let index in this.Building.service){
ar.push(
<Collapsible>
<CollapsibleItem header={this.Building.service[index].name} icon='toc'>
<p>{this.Building.service[index].desc}</p>
<p>{this.Building.service[index].accessinfo.description+" is "+this.Building.service[index].accessinfo.width+" cm"}</p>
</CollapsibleItem>
</Collapsible>
)
}
return ar;

}catch(e){
return (<div><h4>Services</h4><p>This building does not contain public services</p></div>);
}
}

render() {
return (
<Row>
Expand All @@ -27,9 +64,11 @@ export default class SidebarBuildingDetail extends Component {
<Col>
<p>{this.Building.description}</p>
</Col>
<Col className="m12 s12 left">
<h4>Details:</h4>
<p>{this.Building.door.description}: {this.Building.door.width} cm</p>
<Col s={12}>
{this.showAccessibilityInformation()}
</Col>
<Col s={12}>
{this.showServices()}
</Col>
<a href='#' className="col m12 s12 center" onClick={this.handleClick}>Return to search results</a>
</Row>
Expand Down
22 changes: 16 additions & 6 deletions src/components/SidebarSearchResult.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,25 @@ export default class SidebarSearchResult extends React.Component {

handleClick(e){
e.preventDefault();
let id = this.props.buildings.id;
let building = this.BuildingStore.getBuildings.find(b => b.id === id);
let id = this.Building.id;
let building = this.BuildingStore.getBuildings.find(b => b.props.id === id);

this.BuildingStore.setBuilding(building);
this.BuildingStore.setIsInDetailState(true);
}

showAccessibilityInformation = () => {
try{
<div>
<p><i className="material-icons">wheelchair</i> {this.Building.door.description}: {this.Building.door.width} cm</p>
<i className="material-icons">hearing</i>
<i className="material-icons">accessibility</i>
</div>
}catch(e){
console.log(e);
}
}

render() {
return (
<Row>
Expand All @@ -36,9 +48,7 @@ export default class SidebarSearchResult extends React.Component {
<span className="sidebar__searchresult__description"><p>{this.Building.description}</p></span>
</Col>
<Col m={9} s={12}>
<p>{this.Building.door.description}: {this.Building.door.width} cm</p>
<i className="material-icons">hearing</i>
<i className="material-icons">accessibility</i>
{/* {this.showAccessibilityInformation()} */}
</Col>
<a className="col m12 s12 center" href="#" onClick={this.handleClick} id={this.Building.id}>Meer details...</a>
</Row>
Expand Down
8 changes: 6 additions & 2 deletions src/stores/BuildingStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ class BuildingStore {

filterBuildings() {
let arr = [];
let widthOfTheDoor = 0;
let widthOfTheChair = -1;
for (let i = 0; i < this.buildings.length; i++) {
let desc = this.buildings[i].props.description.toLowerCase();
let widthOfTheDoor = parseInt(this.buildings[i].props.door.width,10);
let widthOfTheChair = parseInt(this.filters.wheelchairWidth,10);
if(this.buildings[i].props.door === 'undefined'){
widthOfTheDoor = parseInt(this.buildings[i].props.door.width,10);
widthOfTheChair = parseInt(this.filters.wheelchairWidth,10);
}

if (this.searchKey !== "" && desc.search(this.searchKey) < 0) {
continue;
Expand Down

0 comments on commit 5df5854

Please sign in to comment.