Skip to content

Commit

Permalink
Support collection links everywhere radiantearth/stac-spec#1236
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Jun 14, 2023
1 parent a621102 commit 2689b44
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 19 deletions.
45 changes: 45 additions & 0 deletions src/components/CollectionLink.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<template>
<section v-if="collection" class="parent-collection card-list mb-4">
<h2>{{ $tc('stacCollection') }}</h2>
<Catalog :catalog="collection" :showThumbnail="showThumbnail" />
</section>
</template>

<script>
import Catalog from './Catalog.vue';
import { mapGetters } from 'vuex';
import Utils from '../utils';
export default {
name: "CollectionLink",
components: {
Catalog
},
props: {
link: {
type: Object,
required: true
},
showThumbnail: {
type: Boolean,
default: false
}
},
computed: {
...mapGetters(['getStac']),
collection() {
return this.getStac(this.link);
}
},
watch: {
link: {
immediate: true,
handler(newLink) {
if (Utils.isObject(newLink)) {
this.$store.dispatch("load", { url: newLink.href });
}
}
}
}
};
</script>
4 changes: 3 additions & 1 deletion src/views/Catalog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<Assets v-if="hasItemAssets && !hasItems" :assets="data.item_assets" :definition="true" />
<Providers v-if="hasProviders" :providers="data.providers" />
<Metadata :title="$t('metadata.title')" class="mb-4" :type="data.type" :data="data" :ignoreFields="ignoredMetadataFields" />
<CollectionLink v-if="collectionLink" :link="collectionLink" />
<Links v-if="linkPosition === 'right'" :title="$t('additionalResources')" :links="additionalLinks" />
</b-col>
<b-col class="catalogs-container" v-if="hasCatalogs">
Expand Down Expand Up @@ -76,6 +77,7 @@ export default {
BTabs,
BTab,
Catalogs,
CollectionLink: () => import('../components/CollectionLink.vue'),
DeprecationNotice: () => import('../components/DeprecationNotice.vue'),
Description,
Items,
Expand Down Expand Up @@ -126,7 +128,7 @@ export default {
},
computed: {
...mapState(['data', 'url', 'apiItems', 'apiItemsLink', 'apiItemsPagination']),
...mapGetters(['additionalLinks', 'catalogs', 'isCollection', 'items', 'hasMoreCollections', 'getApiItemsLoading', 'parentLink', 'rootLink']),
...mapGetters(['additionalLinks', 'catalogs', 'collectionLink', 'isCollection', 'items', 'hasMoreCollections', 'getApiItemsLoading', 'parentLink', 'rootLink']),
hasThumbnails() {
return this.thumbnails.length > 0;
},
Expand Down
21 changes: 3 additions & 18 deletions src/views/Item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@
</ReadMore>
<Keywords v-if="Array.isArray(data.properties.keywords) && data.properties.keywords.length > 0" :keywords="data.properties.keywords" />
</section>
<section class="item-collection card-list mb-4" v-if="collection">
<h2>{{ $tc('stacCollection') }}</h2>
<Catalog :catalog="collection" :showThumbnail="false" />
</section>
<CollectionLink v-if="collectionLink" :link="collectionLink" />
<Providers v-if="data.properties.providers" :providers="data.properties.providers" />
<Metadata :data="data" type="Item" :ignoreFields="ignoredMetadataFields" />
</b-col>
Expand All @@ -45,7 +42,6 @@ import Description from '../components/Description.vue';
import ReadMore from "vue-read-more-smooth";
import ShowAssetMixin from '../components/ShowAssetMixin';
import { BTabs, BTab } from 'bootstrap-vue';
import Utils from '../utils';
import { addSchemaToDocument, createItemSchema } from '../schema-org';
export default {
Expand All @@ -55,7 +51,7 @@ export default {
Assets,
BTabs,
BTab,
Catalog: () => import('../components/Catalog.vue'),
CollectionLink: () => import('../components/CollectionLink.vue'),
Description,
DeprecationNotice: () => import('../components/DeprecationNotice.vue'),
Links: () => import('../components/Links.vue'),
Expand Down Expand Up @@ -84,10 +80,7 @@ export default {
},
computed: {
...mapState(['data', 'url']),
...mapGetters(['additionalLinks', 'collectionLink', 'getStac', 'parentLink']),
collection() {
return this.getStac(this.collectionLink);
}
...mapGetters(['additionalLinks', 'collectionLink', 'parentLink'])
},
watch: {
data: {
Expand All @@ -100,14 +93,6 @@ export default {
console.error(error);
}
}
},
collectionLink: {
immediate: true,
handler(newLink) {
if (Utils.isObject(newLink)) {
this.$store.dispatch("load", { url: newLink.href });
}
}
}
}
};
Expand Down

0 comments on commit 2689b44

Please sign in to comment.