Empty thumbnail and title check

This commit is contained in:
joycitta-siqueira 2022-03-15 23:57:00 -03:00
parent bff1295fb5
commit 318e7d464d
2 changed files with 7 additions and 5 deletions

View File

@ -8,8 +8,9 @@
</ion-loading> </ion-loading>
<ion-list> <ion-list>
<ion-item v-for="collection of collections" :key="collection.id" :router-link="`/collections/${collection.id}`"> <ion-item v-for="collection of collections" :key="collection.id" :router-link="`/collections/${collection.id}`">
<ion-thumbnail slot="start"> <!-- verificar se existe a imagem de fato --> <ion-thumbnail slot="start">
<ion-img :src="collection.thumbnail.thumbnail[0]" :alt="collection.name"></ion-img> <ion-img v-if="collection.thumbnail.thumbnail[0]" :src="collection.thumbnail.thumbnail[0]" :alt="collection.name"></ion-img>
<ion-img v-else src="https://cdn.icon-icons.com/icons2/1506/PNG/512/emblemok_103757.png" :alt="collection.name"></ion-img>
</ion-thumbnail> </ion-thumbnail>
<ion-label> {{ collection.name }} </ion-label> <ion-label> {{ collection.name }} </ion-label>
</ion-item> </ion-item>
@ -51,7 +52,7 @@ export default {
created(){ created(){
this.setOpen(true) this.setOpen(true)
fetch("https://museucasadahera.acervos.museus.gov.br/wp-json/tainacan/v2/collections?perpage=4&orderby=modified") fetch("https://rcteste.tainacan.org/wp-json/tainacan/v2/collections?perpage=4&orderby=modified")
.then((response) => response.json()) .then((response) => response.json())
.then((data) => { .then((data) => {
this.collections = data; this.collections = data;

View File

@ -7,7 +7,8 @@
> >
</ion-loading> </ion-loading>
<ion-item v-for="item of items" :key="item.id"> <ion-item v-for="item of items" :key="item.id">
<ion-label> {{ item.title }} </ion-label> <ion-label v-if="item.title"> {{ item.title }} </ion-label>
<ion-label v-else>Item não possui título</ion-label>
</ion-item> </ion-item>
</base-layout> </base-layout>
</template> </template>
@ -41,7 +42,7 @@ export default {
created(){ created(){
this.setOpen(true) this.setOpen(true)
fetch(`https://museucasadahera.acervos.museus.gov.br/wp-json/tainacan/v2/collection/${this.collectionId}/items`) fetch(`https://rcteste.tainacan.org/wp-json/tainacan/v2/collection/${this.collectionId}/items`)
.then((response) => response.json()) .then((response) => response.json())
.then((data) => { .then((data) => {
this.items = data.items; this.items = data.items;