Skip to content

Commit

Permalink
ordering by display name.
Browse files Browse the repository at this point in the history
related to #55
  • Loading branch information
sohilpandya committed Feb 1, 2018
1 parent b2fd654 commit 6c1107a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ type Building {
street_number: String,
street_name: String,
building_name: String,
display_name: String,
postcode: String,
ward: String,
conservation_area: String,
Expand Down
9 changes: 9 additions & 0 deletions helpers/createDataObj.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
const createDataObj = (data) => {
return data.map((item, i) => {

let display_name;
if (item['Lower Case Building Name']) {
display_name = item['Lower Case Building Name']
} else {
display_name = item['Lower Case Street Name'];
}

return {
id: ++i,
street_number: item['Street Number'],
street_name: item['Lower Case Street Name'],
building_name: item['Lower Case Building Name'],
display_name: display_name,
postcode: item['Post Code'],
ward: item['Ward'],
conservation_area: item['Conservation Area'],
Expand Down
2 changes: 1 addition & 1 deletion middleware/graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const grapqlSchema = buildSchema(
);

const getBuildings = async () => {
return await islington.find().sort({ id: 1 });
return await islington.find().sort({ display_name: 1 });
};

module.exports = graphqlHTTP({
Expand Down
1 change: 1 addition & 0 deletions models/islington.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const islingtonSchema = new Schema({
street_number: String,
street_name: String,
building_name: String,
display_name: String,
postcode: String,
ward: String,
conservation_area: String,
Expand Down
1 change: 1 addition & 0 deletions src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ const query = gql`
postcode
ward
building_name
display_name
conservation_area
date_built_actual
date_built_estimate
Expand Down
4 changes: 0 additions & 4 deletions src/components/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ class Map extends Component {

shouldComponentUpdate(nextProps, prevState) {
if (nextProps.building.significance && !prevState.selectedBuildingId) {
console.log(nextProps.building.id, 'building id nextprop')
console.log(nextProps.building.longitude, 'building longitude nextprop')
console.log(nextProps.building.latitude, 'building latitude nextprop')
this.selectedBuilding(nextProps.building.id);
let longitude = nextProps.building.longitude;
let latitude = nextProps.building.latitude;
Expand Down Expand Up @@ -76,7 +73,6 @@ class Map extends Component {
}

hoveringItem = (id) => {
console.log('hovering in hovering item')
this.setState({ hovering: !this.state.hovering, id } )
}

Expand Down

0 comments on commit 6c1107a

Please sign in to comment.