loading result items with route
This commit is contained in:
@@ -0,0 +1,63 @@
|
|||||||
|
<template>
|
||||||
|
<transition name="fade" appear>
|
||||||
|
<span v-if="!loaded">Loading...</span>
|
||||||
|
<article v-else class="item">
|
||||||
|
<header>
|
||||||
|
<h1>
|
||||||
|
{{ item.title }}
|
||||||
|
</h1>
|
||||||
|
</header>
|
||||||
|
<section v-html="item.tei" />
|
||||||
|
</article>
|
||||||
|
</transition>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
import { REST } from 'api/rest-axios'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'Item',
|
||||||
|
props: {
|
||||||
|
uuid: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data: () => ({
|
||||||
|
loaded: false,
|
||||||
|
item: {}
|
||||||
|
}),
|
||||||
|
watch: {
|
||||||
|
'$route' (to, from) {
|
||||||
|
console.log('item route change')
|
||||||
|
this.loadItem()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created () {
|
||||||
|
console.log('Item created', this.uuid)
|
||||||
|
this.loadItem()
|
||||||
|
},
|
||||||
|
updated () {
|
||||||
|
console.log('item updated', this.uuid)
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
loadItem () {
|
||||||
|
this.loaded = false
|
||||||
|
REST.get(`/items/` + this.uuid, {})
|
||||||
|
.then(({ data }) => {
|
||||||
|
console.log('item REST: data', data)
|
||||||
|
this.item = data.content
|
||||||
|
this.loaded = true
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn('Issue with item', error)
|
||||||
|
Promise.reject(error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
</style>
|
||||||
@@ -29,12 +29,10 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
onclick () {
|
onclick () {
|
||||||
console.log('clicked on result item', this.result)
|
console.log('clicked on result item', this.result)
|
||||||
// this.$router.push({
|
this.$router.push({
|
||||||
// name:`article`,
|
name: `item`,
|
||||||
// params: { alias:this.alias },
|
params: { uuid: this.result.uuid }
|
||||||
// query: { uuid: this.item.uuid }
|
})
|
||||||
// // meta: { uuid:this.item.uuid },
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import Vue from 'vue'
|
|||||||
import Router from 'vue-router'
|
import Router from 'vue-router'
|
||||||
|
|
||||||
import Home from 'pages/Home'
|
import Home from 'pages/Home'
|
||||||
|
import Item from 'components/Content/Item'
|
||||||
import Corpus from 'pages/Corpus'
|
import Corpus from 'pages/Corpus'
|
||||||
import Nominum from 'pages/Nominum'
|
import Nominum from 'pages/Nominum'
|
||||||
import NominumItem from 'components/Content/NominumItem'
|
import NominumItem from 'components/Content/NominumItem'
|
||||||
@@ -18,6 +19,12 @@ const routes = [
|
|||||||
path: '/',
|
path: '/',
|
||||||
component: Home
|
component: Home
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'item',
|
||||||
|
path: '/items/:uuid',
|
||||||
|
component: Item,
|
||||||
|
props: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'corpus',
|
name: 'corpus',
|
||||||
path: '/corpus',
|
path: '/corpus',
|
||||||
|
|||||||
Reference in New Issue
Block a user