277 lines
8 KiB
Handlebars
277 lines
8 KiB
Handlebars
<div class='flex items-center mb-4'>
|
|
View:
|
|
<ButtonGroup class='mb-0 ml-2 mr-4'>
|
|
{{#each-in this.views as |key icon|}}
|
|
<Button
|
|
@icon={{icon}}
|
|
@onClick={{set this 'dataView'}}
|
|
@value={{key}}
|
|
title={{namelize key}}
|
|
class='w-auto rounded-none first:rounded-l last:rounded-r
|
|
{{if (eq this.dataView key) "text-primary"}}'
|
|
/>
|
|
{{/each-in}}
|
|
</ButtonGroup>
|
|
|
|
Filters:
|
|
<ButtonGroup class='mb-0 ml-2 mr-4'>
|
|
{{#each this.modes as |item|}}
|
|
<Button
|
|
class='rounded-none first:rounded-l last:rounded-r
|
|
{{if (eq this.mode item) "text-primary"}}'
|
|
@onClick={{fn (set this 'mode') item}}
|
|
>
|
|
{{namelize item}}
|
|
</Button>
|
|
{{/each}}
|
|
</ButtonGroup>
|
|
</div>
|
|
|
|
{{#if (eq this.mode 'advanced')}}
|
|
<div>
|
|
<Form::Element @errors={{this.errors}}>
|
|
<MonacoEditor
|
|
@value={{json-stringify this.searchObject}}
|
|
@language='json'
|
|
@uri={{@model.searchSchema.uri}}
|
|
@schema={{@model.searchSchema}}
|
|
@sendValue={{this.search}}
|
|
@invoker={{this.invoker}}
|
|
@onDidValidation={{set this 'errors'}}
|
|
/>
|
|
</Form::Element>
|
|
|
|
<Button
|
|
@text='Search'
|
|
@style='primary'
|
|
@onClick={{fn this.invoker.invoke 'invokeSendValue'}}
|
|
class='mb-4'
|
|
disabled={{this.errors.length}}
|
|
/>
|
|
</div>
|
|
{{else if (eq this.mode 'simple')}}
|
|
<div class='sm:flex sm:flex-nowrap'>
|
|
{{! q }}
|
|
<Form::Input
|
|
@placeholder='Search'
|
|
@prefixIcon={{this.Magnify}}
|
|
@value={{this.q}}
|
|
@onChange={{this.searchTextChanged}}
|
|
class='sm:grow'
|
|
/>
|
|
|
|
{{! sort }}
|
|
{{#if this.sortValues.length}}
|
|
<Form::Listbox
|
|
@prefixValue={{'Sort: '}}
|
|
@value={{nu-co this.sort 'none'}}
|
|
@values={{this.sortValues}}
|
|
@onChange={{this.setSort}}
|
|
@allowClear={{true}}
|
|
class='sm:ml-4 sm:flex-none'
|
|
/>
|
|
{{/if}}
|
|
|
|
{{! limit }}
|
|
<Form::Listbox
|
|
@prefixValue={{'Limit: '}}
|
|
@value={{nu-co this.limit 'none'}}
|
|
@values={{array 20 50 100 500}}
|
|
@onChange={{set this 'limit'}}
|
|
class='sm:ml-4 sm:flex-none'
|
|
/>
|
|
</div>
|
|
{{/if}}
|
|
|
|
{{#if (gt @model.data.estimatedTotalHits 0)}}
|
|
{{#if (eq this.dataView 'table')}}
|
|
<SimpleTable
|
|
@data={{@model.data.hits}}
|
|
@sortingProp={{this.sort}}
|
|
@onSort={{this.onSort}}
|
|
class='w-full'
|
|
as |Column data|
|
|
>
|
|
{{#let
|
|
(array @model.index.uid (get data @model.index.primaryKey))
|
|
as |models|
|
|
}}
|
|
{{#each this.attributes as |field|}}
|
|
{{#if (not (includes field this.hiddenFields))}}
|
|
<Column
|
|
@name={{capitalize field}}
|
|
@prop={{field}}
|
|
@sortable={{includes field @model.sortableAttributes}}
|
|
>
|
|
{{#let (get data field) as |value|}}
|
|
{{#if (eq @model.index.primaryKey field)}}
|
|
<LinkTo
|
|
@route='admin.indexes.item.documents.document'
|
|
@models={{models}}
|
|
>{{value}}</LinkTo>
|
|
{{else if (eq (type-of value) 'object')}}
|
|
{{json-stringify value}}
|
|
{{else}}
|
|
{{value}}
|
|
{{/if}}
|
|
{{/let}}
|
|
</Column>
|
|
{{/if}}
|
|
{{/each}}
|
|
<Column class='relative text-right'>
|
|
<:head>
|
|
<Form::TableSettings
|
|
@onChangeSort={{this.sortAttibutes}}
|
|
@items={{this.allAttributes}}
|
|
@isItemChecked={{this.isItemChecked}}
|
|
@onToggleItem={{this.toggleAttribute}}
|
|
/>
|
|
</:head>
|
|
<:default>
|
|
{{#let
|
|
'flex items-center px-4 py-2 text-inherit no-underline text-sm hover:bg-base-6 hover:text-base-1'
|
|
as |linkClasses|
|
|
}}
|
|
<Menu as |menu|>
|
|
<menu.Button class='inline-flex items-center'>
|
|
<Icons::DotsHorizontal />
|
|
</menu.Button>
|
|
<menu.Items
|
|
class='absolute z-dropdown right-0 w-28 mt-2 py-1 origin-top-right bg-base-7 border rounded shadow-sm outline-none'
|
|
>
|
|
<LinkTo
|
|
@route='admin.indexes.item.documents.document.index'
|
|
@models={{models}}
|
|
class={{linkClasses}}
|
|
>
|
|
<Icons::FileDocumentOutline @size={{18}} class='mr-1' />
|
|
View
|
|
</LinkTo>
|
|
<LinkTo
|
|
@route='admin.indexes.item.documents.document.edit'
|
|
@models={{models}}
|
|
class={{linkClasses}}
|
|
>
|
|
<Icons::PencilOutline @size={{18}} class='mr-1' />
|
|
Edit
|
|
</LinkTo>
|
|
<LinkTo
|
|
@route='admin.indexes.item.documents.document.delete'
|
|
@models={{models}}
|
|
class={{linkClasses}}
|
|
>
|
|
<Icons::TrashCanOutline @size={{18}} class='mr-1' />
|
|
Delete
|
|
</LinkTo>
|
|
</menu.Items>
|
|
</Menu>
|
|
{{/let}}
|
|
</:default>
|
|
</Column>
|
|
{{/let}}
|
|
</SimpleTable>
|
|
{{else if (eq this.dataView 'json')}}
|
|
{{#each @model.data.hits as |data|}}
|
|
<MonacoEditor
|
|
@value={{json-stringify data}}
|
|
@language='json'
|
|
@readOnly={{true}}
|
|
@minHeight={{0}}
|
|
@actions={{array
|
|
(hash
|
|
label='Go to View page'
|
|
id='go-to-view-page'
|
|
contextMenuGroupId='navigation'
|
|
contextMenuOrder=1
|
|
run=(fn
|
|
this.goToPage
|
|
'admin.indexes.item.documents.document.index'
|
|
@model.index
|
|
(get data @model.index.primaryKey)
|
|
)
|
|
)
|
|
(hash
|
|
label='Go to Edit page'
|
|
id='go-to-edit-page'
|
|
contextMenuGroupId='navigation'
|
|
contextMenuOrder=2
|
|
run=(fn
|
|
this.goToPage
|
|
'admin.indexes.item.documents.document.edit'
|
|
@model.index
|
|
(get data @model.index.primaryKey)
|
|
)
|
|
)
|
|
(hash
|
|
label='Go to Delete page'
|
|
id='go-to-delete-page'
|
|
contextMenuGroupId='navigation'
|
|
contextMenuOrder=3
|
|
run=(fn
|
|
this.goToPage
|
|
'admin.indexes.item.documents.document.delete'
|
|
@model.index
|
|
(get data @model.index.primaryKey)
|
|
)
|
|
)
|
|
}}
|
|
class='mb-4'
|
|
/>
|
|
{{/each}}
|
|
{{else if (eq this.dataView 'map')}}
|
|
{{#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>
|
|
{{else}}
|
|
<div class='mb-4'>Geodata not found.</div>
|
|
{{/if}}
|
|
{{/if}}
|
|
|
|
<div class='flex items-center'>
|
|
{{this.fromHits}}
|
|
—
|
|
{{this.toHits}}
|
|
of
|
|
{{@model.data.estimatedTotalHits}}
|
|
|
|
<Pagination
|
|
@total={{@model.data.estimatedTotalHits}}
|
|
@offset={{this.offset}}
|
|
@limit={{this.limit}}
|
|
class='ml-auto'
|
|
/>
|
|
</div>
|
|
{{else}}
|
|
No results found
|
|
{{/if}}
|