This commit is contained in:
2023-06-19 16:17:41 +02:00
parent 9543bb863c
commit ea111c2af1
3 changed files with 97 additions and 84 deletions
+1 -1
View File
@@ -101,7 +101,7 @@ export default {
let itemparts, icon, newspan
for (var i = 0; i < items.length; i++) {
itemparts = RegExp(/<span[^>]*class="([^"]+)"[^>]*>.+<\/span>/g).exec(items[i], 'g')
console.log('itemparts', itemparts)
// console.log('itemparts', itemparts)
switch (itemparts[1]) {
case 'placeName':
icon = '<span class="index-item-icon mdi mdi-map-marker"></span>'
+8 -4
View File
@@ -51,11 +51,15 @@ export default {
},
created () {
let max = 40
if (this.result.title.length > max) {
let subString = this.result.title.substr(0, max)
this.shorted_title = subString.substr(0, subString.lastIndexOf(' ')) + '&nbsp&hellip;'
if (this.result.title) {
if (this.result.title.length > max) {
let subString = this.result.title.substr(0, max)
this.shorted_title = subString.substr(0, subString.lastIndexOf(' ')) + '&nbsp&hellip;'
} else {
this.shorted_title = this.result.title
}
} else {
this.shorted_title = this.result.title
console.warn(`no result title for ${this.result.uuid}`, this.result)
}
// if (this.result.extract) {
// const subString = this.result.extract.substr(0, 80)
+88 -79
View File
@@ -224,6 +224,9 @@ export default {
watch: {
$route (to, from) {
console.log('Edition Watcher $route', from, to)
if (to.params.id !== this.editionid) {
this.setValues()
}
if (to.params.textid) {
// change textid when route change
this.textid = to.params.textid
@@ -274,90 +277,96 @@ export default {
}
},
created () {
// console.log('Edition this.$route.params.id', this.$route.params.id)
this.editionid = this.$route.params.id
// get the text if textid available
if (this.$route.params.textid) {
this.textid = this.$route.params.textid
}
// get the searchkeys from route param (only comming from result item) for text highlighting
if (this.$route.params.ocid) {
this.extractid = this.$route.params.ocid
// scrolling is not working :(
this.reftoscrollto = '#mark-1'
}
// wait for editions list from Corpus Store if not already loaded
if (!this.corpusLoaded) {
// this.getCorpuses()
// subsribe to store to get the editionbyuuid list
// https://dev.to/viniciuskneves/watch-for-vuex-state-changes-2mgj
this.edUuuidsUnsubscribe = this.$store.subscribe((mutation, state) => {
// console.log('Edition store subscribe', mutation.type)
if (mutation.type === 'Corpus/setEditionsByUUID') {
// console.log('Edition state.Coprus.editionsbyuuid', this.editionid, state.Corpus.editionsbyuuid)
this.title = this.metainfotitle = state.Corpus.editionsbyuuid[this.editionid].title
this.meta = [
{ name: 'test', content: 'edition chargé' }
]
this.biblio = state.Corpus.editionsbyuuid[this.editionid].biblio
this.description = state.Corpus.editionsbyuuid[this.editionid].description
this.date = state.Corpus.editionsbyuuid[this.editionid].date
this.author = state.Corpus.editionsbyuuid[this.editionid].author
}
if (mutation.type === 'Corpus/setTocs') {
console.log('Edition Corpus/setTocs', this.editionid, state.Corpus.editionsbyuuid)
this.toc = state.Corpus.editionsbyuuid[this.editionid].toc
}
if (mutation.type === 'Corpus/buildFlatTocsAndFilters') {
console.log('Edition Corpus/buildFlatTocsAndFilters', this.editionid, state.Corpus.editionsbyuuid)
this.flattoc = state.Corpus.editionsbyuuid[this.editionid].flattoc
// launch infinitloading
this.inifinite_load_id += 1
// if no textid in new route (e.g. edition front)
// but we have toc
// get the first item
// will be replaced by front page of edition
if (!this.textid) { this.textid = this.flattoc[1] }
//
this.indexes = state.Corpus.editionsbyuuid[this.editionid].indexes
}
if (mutation.type === 'Corpus/setPaginations') {
// console.log('Edition state.Coprus.editionsbyuuid', this.editionid, state.Corpus.editionsbyuuid)
this.pagination = state.Corpus.editionsbyuuid[this.editionid].pagination
}
})
} else {
// console.log('');
this.title = this.metainfotitle = this.editionsbyuuid[this.editionid].title
this.meta = [
{ name: 'test', content: 'edition deja là' }
]
this.biblio = this.editionsbyuuid[this.editionid].biblio
this.description = this.editionsbyuuid[this.editionid].description
this.date = this.editionsbyuuid[this.editionid].date
this.author = this.editionsbyuuid[this.editionid].author
this.toc = this.editionsbyuuid[this.editionid].toc
this.flattoc = this.editionsbyuuid[this.editionid].flattoc
// if no textid in new route (e.g. edition front)
// but we have toc
// get the first item
// will be replaced by front page of edition
if (!this.textid) { this.textid = this.toc[0].children[0].uuid }
this.indexes = this.editionsbyuuid[this.editionid].indexes
this.pagination = this.editionsbyuuid[this.editionid].pagination
}
this.setValues()
},
// updated () {
// this.setValues()
// },
methods: {
...mapActions({
getCorpuses: 'Corpus/getCorpuses'
}),
setValues () {
// console.log('Edition this.$route.params.id', this.$route.params.id)
this.editionid = this.$route.params.id
// get the text if textid available
if (this.$route.params.textid) {
this.textid = this.$route.params.textid
}
// get the searchkeys from route param (only comming from result item) for text highlighting
if (this.$route.params.ocid) {
this.extractid = this.$route.params.ocid
// scrolling is not working :(
this.reftoscrollto = '#mark-1'
}
// wait for editions list from Corpus Store if not already loaded
if (!this.corpusLoaded) {
// this.getCorpuses()
// subsribe to store to get the editionbyuuid list
// https://dev.to/viniciuskneves/watch-for-vuex-state-changes-2mgj
this.edUuuidsUnsubscribe = this.$store.subscribe((mutation, state) => {
// console.log('Edition store subscribe', mutation.type)
if (mutation.type === 'Corpus/setEditionsByUUID') {
// console.log('Edition state.Coprus.editionsbyuuid', this.editionid, state.Corpus.editionsbyuuid)
this.title = this.metainfotitle = state.Corpus.editionsbyuuid[this.editionid].title
this.meta = [
{ name: 'test', content: 'edition chargé' }
]
this.biblio = state.Corpus.editionsbyuuid[this.editionid].biblio
this.description = state.Corpus.editionsbyuuid[this.editionid].description
this.date = state.Corpus.editionsbyuuid[this.editionid].date
this.author = state.Corpus.editionsbyuuid[this.editionid].author
}
if (mutation.type === 'Corpus/setTocs') {
console.log('Edition Corpus/setTocs', this.editionid, state.Corpus.editionsbyuuid)
this.toc = state.Corpus.editionsbyuuid[this.editionid].toc
}
if (mutation.type === 'Corpus/buildFlatTocsAndFilters') {
console.log('Edition Corpus/buildFlatTocsAndFilters', this.editionid, state.Corpus.editionsbyuuid)
this.flattoc = state.Corpus.editionsbyuuid[this.editionid].flattoc
// launch infinitloading
this.inifinite_load_id += 1
// if no textid in new route (e.g. edition front)
// but we have toc
// get the first item
// will be replaced by front page of edition
if (!this.textid) { this.textid = this.flattoc[1] }
//
this.indexes = state.Corpus.editionsbyuuid[this.editionid].indexes
}
if (mutation.type === 'Corpus/setPaginations') {
// console.log('Edition state.Coprus.editionsbyuuid', this.editionid, state.Corpus.editionsbyuuid)
this.pagination = state.Corpus.editionsbyuuid[this.editionid].pagination
}
})
} else {
// console.log('');
this.title = this.metainfotitle = this.editionsbyuuid[this.editionid].title
this.meta = [
{ name: 'test', content: 'edition deja là' }
]
this.biblio = this.editionsbyuuid[this.editionid].biblio
this.description = this.editionsbyuuid[this.editionid].description
this.date = this.editionsbyuuid[this.editionid].date
this.author = this.editionsbyuuid[this.editionid].author
this.toc = this.editionsbyuuid[this.editionid].toc
this.flattoc = this.editionsbyuuid[this.editionid].flattoc
// if no textid in new route (e.g. edition front)
// but we have toc
// get the first item
// will be replaced by front page of edition
if (!this.textid) { this.textid = this.toc[0].children[0].uuid }
this.indexes = this.editionsbyuuid[this.editionid].indexes
this.pagination = this.editionsbyuuid[this.editionid].pagination
}
},
getTextContent (textid, $state = null, direction = 'next') {
console.log('getTextContent', textid)
let params = {