Skip to content

Commit 6e0a78e

Browse files
committed
API landing page shows map of collections #14
1 parent 972392b commit 6e0a78e

File tree

4 files changed

+33
-14
lines changed

4 files changed

+33
-14
lines changed

src/components/Catalogs.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<header>
44
<h2 class="title mr-2">{{ title }}</h2>
55
<b-badge v-if="catalogCount !== null" pill variant="secondary" class="mr-4">{{ catalogCount }}</b-badge>
6-
<ViewButtons class="mr-2" v-model="view" />
7-
<SortButtons v-if="isComplete && catalogs.length > 1" v-model="sort" />
6+
<ViewButtons v-if="!simple" class="mr-2" v-model="view" />
7+
<SortButtons v-if="!simple && isComplete && catalogs.length > 1" v-model="sort" />
88
</header>
9-
<section v-if="isComplete && catalogs.length > 1" class="catalog-filter mb-2">
9+
<section v-if="!simple && isComplete && catalogs.length > 1" class="catalog-filter mb-2">
1010
<SearchBox v-model="searchTerm" :placeholder="filterPlaceholder" />
1111
<multiselect
1212
v-if="allKeywords.length > 0" v-model="selectedKeywords" multiple :options="allKeywords"
@@ -17,6 +17,7 @@
1717
:limitText="limitText"
1818
/>
1919
</section>
20+
<slot></slot>
2021
<Pagination v-if="showPagination" ref="topPagination" class="mb-3" :pagination="pagination" placement="top" @paginate="paginate" />
2122
<b-alert v-if="hasSearchCritera && catalogView.length === 0" variant="warning" class="mt-2" show>{{ $t('catalogs.noMatches') }}</b-alert>
2223
<section class="list">
@@ -79,7 +80,11 @@ export default {
7980
count: {
8081
type: Number,
8182
default: null
82-
}
83+
},
84+
simple: {
85+
type: Boolean,
86+
default: false
87+
},
8388
},
8489
data() {
8590
return {

src/components/Items.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<header>
44
<h2 class="title mr-2">{{ $tc('stacItem', items.length ) }}</h2>
55
<b-badge v-if="itemCount !== null" pill variant="secondary" class="mr-4">{{ itemCount }}</b-badge>
6-
<SortButtons v-if="!api && items.length > 1" v-model="sort" />
6+
<SortButtons v-if="!simple && !api && items.length > 1" v-model="sort" />
77
</header>
88

99
<Pagination
@@ -101,6 +101,10 @@ export default {
101101
count: {
102102
type: Number,
103103
default: null
104+
},
105+
simple: {
106+
type: Boolean,
107+
default: false
104108
}
105109
},
106110
data() {

src/components/Map.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
:target="selectedItems.target" container="#stac-browser"
1313
>
1414
<section class="popover-items">
15-
<Items :stac="stac" :items="selectedItems.items" />
15+
<Catalogs v-if="itemsAreCollections" :catalogs="selectedItems.items" collectionsOnly simple />
16+
<Items v-else :stac="stac" :items="selectedItems.items" simple />
1617
</section>
1718
<div class="text-center">
1819
<b-button target="_blank" variant="danger" @click="resetSelectedItems">{{ $t('mapping.close') }}</b-button>
@@ -41,6 +42,7 @@ export default {
4142
name: 'Map',
4243
components: {
4344
BPopover,
45+
Catalogs: () => import('../components/Catalogs.vue'),
4446
Items: () => import('../components/Items.vue'),
4547
LayerControl,
4648
TextControl
@@ -58,7 +60,7 @@ export default {
5860
default: null
5961
},
6062
items: {
61-
type: Object,
63+
type: [Object, Array], // Array = Collections, Object = Items
6264
default: null
6365
},
6466
noscroll: {
@@ -79,7 +81,10 @@ export default {
7981
};
8082
},
8183
computed: {
82-
...mapGetters(['getStac'])
84+
...mapGetters(['getStac']),
85+
itemsAreCollections() {
86+
return Array.isArray(this.items);
87+
},
8388
},
8489
watch: {
8590
async stac() {
@@ -218,7 +223,7 @@ export default {
218223
margin-right: -0.75rem;
219224
padding: 0.5rem 0.75rem 0 0.75rem;
220225
221-
.items {
226+
.items, .catalogs {
222227
margin-bottom: 0 !important;
223228
}
224229

src/views/Catalog.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@
4242
<Links v-if="linkPosition === 'right'" :title="$t('additionalResources')" :links="additionalLinks" :context="data" />
4343
</b-col>
4444
<b-col class="catalogs-container" v-if="hasCatalogs">
45-
<Catalogs :catalogs="catalogs" :hasMore="!!nextCollectionsLink" @loadMore="loadMoreCollections" />
45+
<Catalogs :catalogs="catalogs" :hasMore="!!nextCollectionsLink" @loadMore="loadMoreCollections">
46+
<Map v-if="isCollectionApi && !isCollection && apiCatalogPriority !== 'childs'" class="mb-2" :stac="data" :items="catalogs" v-bind="catalogs" noscroll popover />
47+
</Catalogs>
4648
</b-col>
4749
<b-col class="items-container" v-if="hasItems">
4850
<Items
49-
:stac="data" :items="items" :api="isApi"
51+
:stac="data" :items="items" :api="isItemsApi"
5052
:showFilters="showFilters" :apiFilters="filters"
5153
:pagination="itemPages" :loading="apiItemsLoading"
5254
@paginate="paginateItems" @filterItems="filterItems"
@@ -135,7 +137,7 @@ export default {
135137
};
136138
},
137139
computed: {
138-
...mapState(['data', 'url', 'apiItems', 'apiItemsLink', 'apiItemsPagination', 'nextCollectionsLink', 'stateQueryParameters']),
140+
...mapState(['data', 'url', 'apiItems', 'apiItemsLink', 'apiItemsPagination', 'apiCatalogPriority', 'nextCollectionsLink', 'stateQueryParameters']),
139141
...mapGetters(['catalogs', 'collectionLink', 'isCollection', 'items', 'getApiItemsLoading', 'parentLink', 'rootLink']),
140142
cssStacType() {
141143
if (Utils.hasText(this.data?.type)) {
@@ -204,11 +206,14 @@ export default {
204206
}
205207
return pages;
206208
},
207-
isApi() {
209+
isCollectionApi() {
210+
return this.data && this.data.getApiCollectionsLink();
211+
},
212+
isItemsApi() {
208213
return Boolean(this.apiItemsLink);
209214
},
210215
hasItems() {
211-
return this.items.length > 0 || this.isApi;
216+
return this.items.length > 0 || this.isItemsApi;
212217
},
213218
hasCatalogs() {
214219
return this.catalogs.length > 0;

0 commit comments

Comments
 (0)