Commit c0704579 authored by schneider210's avatar schneider210
Browse files

Merge branch 'develop' into issue/make-language-switch-configurable

parents 26071d5c 8dbca9cb
Pipeline #223540 passed with stages
in 3 minutes and 33 seconds
......@@ -22,6 +22,7 @@
:annotations="annotations"
:collection="collection"
:config="config"
:contentindex="contentindex"
:contenttypes="contentTypes"
:contenturls="contentUrls"
:fontsize="fontsize"
......@@ -30,6 +31,7 @@
:item="item"
:labels="config.labels"
:manifests="manifests"
:oncontentindexchange="oncontentindexchange"
:panels="panels"
:request="request"
:tree="tree"
......@@ -60,6 +62,7 @@ export default {
collection: {},
collectiontitle: '',
config: {},
contentindex: 0,
contentTypes: [],
contentUrls: [],
fontsize: 16,
......@@ -252,7 +255,16 @@ export default {
.then((data) => {
this.item = data;
const previousManifest = (this.contentUrls[0] || '').split('/').pop().split('-')[0];
this.contentUrls = this.getContentUrls(data.content);
const currentManifest = this.contentUrls[0].split('/').pop().split('-')[0];
if (previousManifest !== currentManifest) {
this.$root.$emit('manifest-changed');
}
this.imageurl = data.image.id || '';
if (data.annotationCollection) {
......@@ -402,6 +414,10 @@ export default {
: this.getManifest(this.config.entrypoint);
},
oncontentindexchange(index) {
this.contentindex = index;
},
onItemUrlChange() {
if (this.loaded) {
return;
......
......@@ -11,6 +11,7 @@
<q-tab
v-for="annotationTab in annotationTabs"
:key="annotationTab.key"
:class="{'disabled-tab': annotationTab.key === currentTab}"
:label="$t(annotationTab.collectionTitle)"
:name="annotationTab.key"
@click="activeTab(annotationTab.key, annotationTab.type)"
......@@ -111,8 +112,7 @@ export default {
key,
collectionTitle: key,
type,
}))
.filter((el) => this.annotations.find((x) => el.type.includes(x.body['x-content-type'])));
}));
},
annotationTabConfig() {
return this.config?.annotations?.tabs || {};
......@@ -196,10 +196,16 @@ export default {
},
},
mounted() {
this.currentTab = this.annotationTabs?.[0].key;
this.$root.$on('update-annotations', this.onContentUpdate);
this.$root.$on('update-annotation-loading', (isProcessing) => {
this.isProcessing = !!isProcessing;
});
this.$root.$on('manifest-changed', () => {
this.currentTab = this.annotationTabs?.[0].key;
});
},
methods: {
activeTab(key) {
......@@ -356,7 +362,6 @@ export default {
onContentUpdate(ids) {
try {
this.currentTab = this.annotationTabs[0].key;
this.contentIds = ids;
this.highlightActiveContent(this.filteredAnnotations);
......@@ -576,4 +581,8 @@ export default {
flex: 1;
flex-direction: column;
}
.disabled-tab {
pointer-events: none;
}
</style>
<template>
<div class="item">
<q-tabs
v-model="activeTab"
v-model="activeTabContents"
dense
class="text-grey q-mb-sm"
active-color="$q.dark.isActive ? 'white' : 'accent'"
......@@ -79,6 +79,10 @@ export default {
type: Array,
default: () => [],
},
contentindex: {
type: Number,
default: () => 0,
},
fontsize: {
type: Number,
default: () => 16,
......@@ -87,6 +91,10 @@ export default {
type: Array,
default: () => [],
},
oncontentindexchange: {
type: Function,
default: () => null,
},
request: {
type: Function,
default: null,
......@@ -101,7 +109,7 @@ export default {
},
},
data: () => ({
activeTab: null,
activeTabContents: '',
content: '',
fontSizeLimits: {
min: 14,
......@@ -115,13 +123,23 @@ export default {
return Object.keys(support).length && support.url !== '';
},
activeTab() {
return this.contenturls[this.contentindex];
},
},
watch: {
fontsize() {
this.$refs.contentsize.style.fontSize = `${this.fontsize}px`;
},
async activeTab(url) {
activeTabContents(url) {
this.oncontentindexchange(this.contenturls.findIndex((x) => x === url));
},
activeTab: {
async handler(url) {
if (!url) {
return;
}
this.$root.$emit('update-annotation-loading', true);
const data = await this.request(url, 'text');
......@@ -160,6 +178,8 @@ export default {
}
this.content = dom.documentElement.innerHTML;
// to improve performance, here we are trying to get candidates of annotation that are
// possibly be the annotation and try to match them with their respective annotations.
const displayedAnnotations = [
...dom.querySelectorAll('[data-annotation]'),
]
......@@ -176,14 +196,22 @@ export default {
this.$root.$emit('update-annotations', displayedAnnotations);
this.$root.$emit('update-annotation-loading', false);
},
immediate: true,
},
},
async created() {
this.fasSearchPlus = fasSearchPlus;
this.fasSearchMinus = fasSearchMinus;
const [contentUrl] = this.contenturls;
const activeTab = this.contenturls[this.contentindex];
const [contenturls] = this.contenturls[0];
this.activeTabContents = activeTab;
this.activeTab = contentUrl;
if (!activeTab) {
this.oncontentindexchange(0);
this.activeTabContents = contenturls;
}
},
mounted() {
......@@ -194,6 +222,13 @@ export default {
this.getSupport(this.manifests[index].support);
}
});
const [contenturls] = this.contenturls[0];
this.$root.$on('manifest-changed', () => {
this.activeTabContents = contenturls;
this.oncontentindexchange(0);
});
},
methods: {
async delay(ms = 2500) {
......
......@@ -75,6 +75,10 @@ export default {
this.panels = newPanels;
});
this.$root.$on('manifest-changed', () => {
this.panels = [...this.panels].map((tab) => ({ ...tab, tab_model: 'tab0' }));
});
this.$root.$on('add-panel', () => {
const newPanel = {
id: uuidv4(),
......
......@@ -93,6 +93,10 @@ export default {
type: Object,
default: () => {},
},
contentindex: {
type: Number,
default: () => 0,
},
contenttypes: {
type: Array,
default: () => [],
......@@ -125,6 +129,10 @@ export default {
type: Array,
default: () => [],
},
oncontentindexchange: {
type: Function,
default: () => null,
},
panels: {
type: Array,
default: () => [],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment