implemented infinite loading
probleme with beforeItemUuid and afterItemUuid
This commit is contained in:
Generated
+5
@@ -11902,6 +11902,11 @@
|
|||||||
"integrity": "sha512-BXq3jwIagosjgNVae6tkHzzIk6a8MHFtzAdwhnV5VlvPTFxDCvIttgSiHWjdGoTJvXtmRu5HacExfdarRcFhog==",
|
"integrity": "sha512-BXq3jwIagosjgNVae6tkHzzIk6a8MHFtzAdwhnV5VlvPTFxDCvIttgSiHWjdGoTJvXtmRu5HacExfdarRcFhog==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"vue-infinite-loading": {
|
||||||
|
"version": "2.4.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/vue-infinite-loading/-/vue-infinite-loading-2.4.5.tgz",
|
||||||
|
"integrity": "sha512-xhq95Mxun060bRnsOoLE2Be6BR7jYwuC89kDe18+GmCLVrRA/dU0jrGb12Xu6NjmKs+iTW0AA6saSEmEW4cR7g=="
|
||||||
|
},
|
||||||
"vue-jest": {
|
"vue-jest": {
|
||||||
"version": "3.0.5",
|
"version": "3.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/vue-jest/-/vue-jest-3.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/vue-jest/-/vue-jest-3.0.5.tgz",
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.18.1",
|
"axios": "^0.18.1",
|
||||||
"vue": "^2.6.10",
|
"vue": "^2.6.10",
|
||||||
|
"vue-infinite-loading": "^2.4.5",
|
||||||
"vue-meta": "^1.6.0",
|
"vue-meta": "^1.6.0",
|
||||||
"vue-router": "^3.1.3",
|
"vue-router": "^3.1.3",
|
||||||
"vuex": "^3.1.1",
|
"vuex": "^3.1.1",
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import router from './router'
|
|||||||
import store from './store'
|
import store from './store'
|
||||||
// import { sync } from 'vuex-router-sync'
|
// import { sync } from 'vuex-router-sync'
|
||||||
import Meta from 'vue-meta'
|
import Meta from 'vue-meta'
|
||||||
|
import InfiniteLoading from 'vue-infinite-loading'
|
||||||
|
|
||||||
import App from './App'
|
import App from './App'
|
||||||
|
|
||||||
import 'assets/css/mdi/css/materialdesignicons.css'
|
import 'assets/css/mdi/css/materialdesignicons.css'
|
||||||
@@ -11,6 +13,23 @@ import 'assets/css/app.scss'
|
|||||||
|
|
||||||
Vue.use(Meta)
|
Vue.use(Meta)
|
||||||
|
|
||||||
|
Vue.use(InfiniteLoading, {
|
||||||
|
props: {
|
||||||
|
spinner: 'spiral'
|
||||||
|
},
|
||||||
|
slots: {
|
||||||
|
noMore: '',
|
||||||
|
noResult: ''
|
||||||
|
},
|
||||||
|
system: {
|
||||||
|
throttleLimit: 5000
|
||||||
|
}
|
||||||
|
// system: {
|
||||||
|
// throttleLimit: 50,
|
||||||
|
// /* other settings need to configure */
|
||||||
|
// }
|
||||||
|
})
|
||||||
|
|
||||||
// sync(store, router) // done. Returns an unsync callback fn
|
// sync(store, router) // done. Returns an unsync callback fn
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
|
|||||||
+48
-20
@@ -31,12 +31,18 @@
|
|||||||
|
|
||||||
<!-- default slot -->
|
<!-- default slot -->
|
||||||
<div id="text">
|
<div id="text">
|
||||||
<EdText
|
<template v-if="texts.length">
|
||||||
v-if="textdata"
|
<infinite-loading direction="top" @infinite="prevText" />
|
||||||
:tei="textdata.content.tei"
|
<EdText
|
||||||
@onHoverLink="onHoverLink"
|
v-for="text in texts"
|
||||||
@onLeaveLink="onLeaveLink"
|
:key="text.content.uuid"
|
||||||
/>
|
:tei="text.content.tei"
|
||||||
|
:uuid="text.content.uuid"
|
||||||
|
@onHoverLink="onHoverLink"
|
||||||
|
@onLeaveLink="onLeaveLink"
|
||||||
|
/>
|
||||||
|
<infinite-loading @infinite="nextText" />
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template #nav>
|
<template #nav>
|
||||||
@@ -72,7 +78,7 @@ export default {
|
|||||||
meta: null,
|
meta: null,
|
||||||
editionid: null,
|
editionid: null,
|
||||||
textid: null,
|
textid: null,
|
||||||
textdata: null,
|
texts: [],
|
||||||
metainfotitle: undefined,
|
metainfotitle: undefined,
|
||||||
title: undefined,
|
title: undefined,
|
||||||
author: undefined,
|
author: undefined,
|
||||||
@@ -90,7 +96,8 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
textid: function (newid, oldid) {
|
textid: function (newid, oldid) {
|
||||||
console.log('textid watcher', this, oldid, newid)
|
console.log('textid watcher', this, oldid, newid)
|
||||||
this.getTextContent()
|
this.texts = []
|
||||||
|
this.getTextContent(newid)
|
||||||
},
|
},
|
||||||
textdata: function (newtxtdata, oldtxtdata) {
|
textdata: function (newtxtdata, oldtxtdata) {
|
||||||
console.log('textdata watcher', oldtxtdata, newtxtdata)
|
console.log('textdata watcher', oldtxtdata, newtxtdata)
|
||||||
@@ -167,18 +174,39 @@ export default {
|
|||||||
...mapActions({
|
...mapActions({
|
||||||
getCorpuses: 'Corpus/getCorpuses'
|
getCorpuses: 'Corpus/getCorpuses'
|
||||||
}),
|
}),
|
||||||
getTextContent () {
|
getTextContent (textid, $state = null, direction = 'next') {
|
||||||
console.log('getTextContent', this.textid)
|
console.log('getTextContent', textid)
|
||||||
if (this.textid) {
|
REST.get(`/items/${textid}`, {})
|
||||||
REST.get(`/items/` + this.textid, {})
|
.then(({ data }) => {
|
||||||
.then(({ data }) => {
|
console.log('text REST: data', data)
|
||||||
console.log('text REST: data', data)
|
if (direction === 'next') {
|
||||||
this.textdata = data
|
this.texts.push(data)
|
||||||
})
|
} else {
|
||||||
.catch((error) => {
|
this.texts.unshift(data)
|
||||||
console.warn('Issue with getTextContent', error)
|
}
|
||||||
Promise.reject(error)
|
if ($state) {
|
||||||
})
|
$state.loaded()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn('Issue with getTextContent', error)
|
||||||
|
Promise.reject(error)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
nextText ($state) {
|
||||||
|
console.log('infinite loading nextText()', this.texts[this.texts.length - 1].content.itemAfterUuid, $state)
|
||||||
|
if (this.texts[this.texts.length - 1].content.itemAfterUuid) {
|
||||||
|
this.getTextContent(this.texts[this.texts.length - 1].content.itemAfterUuid, $state, 'next')
|
||||||
|
} else {
|
||||||
|
$state.complete()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
prevText ($state) {
|
||||||
|
console.log('infinite loading prevText()', this.texts[0].content.itemBeforeUuid, $state)
|
||||||
|
if (this.texts[0].content.itemBeforeUuid) {
|
||||||
|
this.getTextContent(this.texts[0].content.itemBeforeUuid, $state, 'prev')
|
||||||
|
} else {
|
||||||
|
$state.complete()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onHoverLink (elmt) {
|
onHoverLink (elmt) {
|
||||||
|
|||||||
Reference in New Issue
Block a user