Opens item edition from item card. #20.

This commit is contained in:
mateuswetah 2022-06-28 17:20:56 -03:00
parent a0413df2a3
commit 045e3bafca
2 changed files with 20 additions and 5 deletions

View File

@ -1,7 +1,7 @@
<template>
<ion-row class="items-list-container">
<ion-col size="4" v-for="item of items" :key="item.id">
<ion-card button color="light" >
<ion-card @click="openItemEdition(item)" button color="light" >
<ion-img :src="(item.thumbnail && item.thumbnail['tainacan-medium'] && item.thumbnail['tainacan-medium'][0]) ? item.thumbnail['tainacan-medium'][0] : thumbnailPlaceholder" :alt="(item.thumbnail_alt ? item.thumbnail_alt : (item.title ? item.title : 'Imagem de item sem título'))"></ion-img>
<ion-card-header>
<ion-card-title>{{ item.title ? item.title : $t('label_item_without_title') }}</ion-card-title>
@ -22,6 +22,8 @@ import {
} from '@ionic/vue';
import { computed } from 'vue';
import { useWpStore } from '@/store/storeWp';
import { InAppBrowserEvent } from '@awesome-cordova-plugins/in-app-browser';
export default {
props: [
"items"
@ -35,8 +37,24 @@ export default {
IonCardTitle
},
setup() {
const wpStore = useWpStore();
const thumbnailPlaceholder = computed (() => require('../../assets/placeholder_square_small.png'));
return { thumbnailPlaceholder }
const openItemEdition = function(item: any) {
wpStore.openInAppBrowser('/collections/' + item.collection_id + '/items/' + item.id + '/edit');
wpStore.listenEventInAppBrowser((event: InAppBrowserEvent) => {
if (event &&
event.data &&
event.data.type === 'item_updated' &&
event.data.item &&
event.data.item.status !== 'auto-draft'
) {
wpStore.hideInAppBrowser();
}
});
}
return { thumbnailPlaceholder, wpStore, openItemEdition }
}
}
</script>

View File

@ -3,10 +3,7 @@ import axios from "axios";
import { Storage } from "@ionic/storage";
import {
InAppBrowser,
InAppBrowserEvent,
InAppBrowserEventType,
InAppBrowserObject,
InAppBrowserOriginal
} from "@awesome-cordova-plugins/in-app-browser/index";
const store = new Storage();