Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

QMAPS-759 display POI image on top right if available #168

Merged
merged 13 commits into from
May 7, 2019
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ It will run chrome headless test suite with a mapbox-gl minimalist mock. The con

*note on mapbox-gl mock*: We include out mapbox-gl mock fork to emulate mapbox-gl behaviour with the advanced support of mocked event & poi.

**hint** : When you debug or add new tests, you may want to launch puppeteer in non headless mode and keep the browser open.
**hint** : When you debug or add new tests, you may want to launch puppeteer in non headless mode and keep the browser open by setting the environment variable `headless` to `false`.

### Benchmark

Expand Down
4 changes: 2 additions & 2 deletions config/constants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ pois:
closed:
msg: _('Closed')
color: '#8c0212'
- apiName: phone
panelName: phone
- apiName: website
panelName: website
- apiName: wikipedia
Expand Down Expand Up @@ -101,6 +99,8 @@ pois:
panelName: internet_access
- apiName: contact
panelName: contact
- apiName: images
panelName: images
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we remove this unused block for now ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't be unused for long so I'd be in favor to keep it for now.


# Map
map:
Expand Down
47 changes: 33 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions src/adapters/poi/idunn_poi.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,22 @@ export default class IdunnPoi extends Poi {
this.localName = rawPoi.local_name
this.address = IdunnPoi.getAddress(rawPoi)
this.bbox = rawPoi.geometry.bbox

if(this.blocks) {
let imagesBlock = this.blocks.find((b) => b.type === 'images')
if (imagesBlock && imagesBlock.images.length > 0){
this.topImageUrl = imagesBlock.images[0].url
}
this.phoneBlock = this.blocks.find((b) => b.type === 'phone')
}
}

getInputValue() {
switch (this.type) {
case 'address':
case 'street':
return this.alternativeName
default :
default:
return this.name
}
}
Expand All @@ -50,8 +58,7 @@ export default class IdunnPoi extends Poi {
} catch (err) {
if(err === 404) {
return
}
else {
} else {
Error.sendOnce(
'idunn_poi', 'poiApiLoad',
`unknown error getting idunn poi reaching ${url} with options ${JSON.stringify(requestParams)}`,
Expand Down
3 changes: 1 addition & 2 deletions src/adapters/poi/latlon_poi.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ export default class LatLonPoi extends Poi {
let latLng = {lat : parseFloat(lat), lng : parseFloat(lng)}
if(urlData[LABEL_POSITION]) {
return Promise.resolve(new LatLonPoi(latLng, ExtendedString.htmlEncode(urlData[LABEL_POSITION])))
} else {
return Promise.resolve(new LatLonPoi(latLng))
}
return Promise.resolve(new LatLonPoi(latLng))
}
} else {
let urlData = urlParam.match(/^(.*?)(@(.*))?$/)
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/poi/map_poi.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import Poi,{POI_TYPE} from "./poi";
export default class MapPoi extends Poi {
constructor(feature, lngLat) {
let id = feature.properties.global_id
super(id, feature.name, null, POI_TYPE, lngLat)
super(id, feature.name, null, POI_TYPE, lngLat)
}
}
10 changes: 10 additions & 0 deletions src/panel/poi_bloc/images_panel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import ImagesPanelView from '../../views/poi_bloc/images.dot'
import Panel from "../../libs/panel";

export default class ImagesPanel {
constructor(block){
this.panel = new Panel(this, ImagesPanelView)
this.name = block.name
this.block = block
}
}
9 changes: 0 additions & 9 deletions src/panel/poi_bloc/phone_panel.js

This file was deleted.

7 changes: 3 additions & 4 deletions src/panel/poi_bloc/poi_bloc_container.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ PoiBlocContainer.getBlock = function(name) {
return PoiBlocContainer.blockComponents[name]
}

PoiBlocContainer.setBock = function(block) {
PoiBlocContainer.setBlock = function(block) {
let blockComponent = PoiBlocContainer.blockComponents[block.type]
return new blockComponent.poiBlockConstructor.default(block, PoiBlocContainer.poi, blockComponent.options)
}

PoiBlocContainer.renderBlock = function (block) {
let blockComponent = getBlockComponent(block)
if(blockComponent) {
if (blockComponent) {
return blockComponent.render()
} else {
console.log(`info : component missing (${block.type})`)
Expand All @@ -46,9 +46,8 @@ PoiBlocContainer.toString = function (blocks) {
let blockComponent = getBlockComponent(block)
if(blockComponent) {
return blockComponent.toString()
} else {
return ''
}
return ''
}).join(' - ')
}

Expand Down
22 changes: 5 additions & 17 deletions src/panel/poi_panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@ function PoiPanel(sharePanel) {
if (this.poi) {
this.poi.stored = await isPoiFavorite(this.poi)
this.panel.update()
endLoad()
}
})

store.eventTarget.addEventListener('poi_added', async () => {
if (this.poi && !this.poi.stored) {
this.poi.stored = await isPoiFavorite(this.poi)
this.panel.update()
endLoad()
}
})
}
Expand Down Expand Up @@ -124,7 +122,6 @@ PoiPanel.prototype.setPoi = async function (poi, options = {}) {
this.sceneState.setPoiId(this.poi.id)
await this.panel.update()
await this.minimalHourPanel.set(this.poi)
endLoad()
}

PoiPanel.prototype.center = function() {
Expand Down Expand Up @@ -153,15 +150,18 @@ PoiPanel.prototype.restore = async function(urlShard) {
if (idSlugMatch && window.hotLoadPoi) {
let id = idSlugMatch[1]
await this.restorePoi(id)
endLoad()
}
}
}

PoiPanel.prototype.showDetail = function() {
this.card = false
this.panel.update()
endLoad()
}

PoiPanel.prototype.backToSmall = function() {
this.card = true
this.panel.update()
}

PoiPanel.prototype.backToFavorite = function() {
Expand All @@ -186,16 +186,4 @@ async function isPoiFavorite(poi) {
return false
}

/* loadable */

function endLoad() {
let loadingPanel = document.querySelector('#poi-loading-panel')
loadingPanel.style.animation = 'disappear 1s forwards'

setTimeout(() => {
let loadingPanel = document.querySelector('#poi-loading-panel')
loadingPanel.style.display = 'none'
}, 200)
}

export default PoiPanel
4 changes: 2 additions & 2 deletions src/scss/includes/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ BODY {

.favorite_poi_panel__container {
position: absolute;
bottom: 0;
max-height: calc(100vh - 150px);
height: 100%;
top: 75px;
}

.map_container .map_control__scale_attribute_container {
Expand Down
5 changes: 2 additions & 3 deletions src/scss/includes/osm_contribute.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.osm_contribute {
width: calc(100% - 2 * 28px);
width: 100%;
height: 55px;
margin: 16px 0 0 25px;
border: solid 1px $separator_color;
@include card_radius();
}
Expand Down Expand Up @@ -37,7 +36,7 @@

.osm_contribute__link:hover {
text-decoration: none;
border-bottom: 1px solid $secondary_text_clear;
color: $primary_text;
}

.osm_contribute__icon {
Expand Down
Loading