Add message for empty geodata

This commit is contained in:
Stanislav Romanov 2023-05-14 15:33:17 +03:00
parent 621f61d591
commit e2e1f8b338
2 changed files with 40 additions and 32 deletions

View file

@ -83,6 +83,10 @@ export default class AdminIndexesItemDocumentsIndexController extends Controller
return this.markers.getBounds();
}
get mapBoundsIsValid() {
return this.mapBounds.isValid();
}
get searchObject() {
return this.queryParams.reduce((properties, item) => {
properties[item] = this[item];

View file

@ -219,39 +219,43 @@
/>
{{/each}}
{{else if (eq this.dataView 'map')}}
<LeafletMap
@bounds={{this.mapBounds}}
@scrollWheelZoom={{false}}
class='h-80 mb-4'
as |layers|
>
<layers.tile
@url='https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png'
/>
{{#if this.mapBoundsIsValid}}
<LeafletMap
@bounds={{this.mapBounds}}
@scrollWheelZoom={{false}}
class='h-96 mb-4'
as |layers|
>
<layers.tile
@url='https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png'
/>
{{#each @model.data.hits as |data|}}
<layers.marker
@lat={{data._geo.lat}}
@lng={{data._geo.lng}}
as |marker|
>
<marker.popup>
{{#each-in data as |key value|}}
<div class='mb-2'>
<label for={{@for}} class='block mb-1'>
{{capitalize key}}
</label>
{{if
(eq (type-of value) 'object')
(json-stringify value)
value
}}
</div>
{{/each-in}}
</marker.popup>
</layers.marker>
{{/each}}
</LeafletMap>
{{#each @model.data.hits as |data|}}
<layers.marker
@lat={{data._geo.lat}}
@lng={{data._geo.lng}}
as |marker|
>
<marker.popup>
{{#each-in data as |key value|}}
<div class='mb-2'>
<label for={{@for}} class='block mb-1'>
{{capitalize key}}
</label>
{{if
(eq (type-of value) 'object')
(json-stringify value)
value
}}
</div>
{{/each-in}}
</marker.popup>
</layers.marker>
{{/each}}
</LeafletMap>
{{else}}
<div class='mb-4'>Geodate not found.</div>
{{/if}}
{{/if}}
<div class='flex items-center'>