Commit e6a36028 authored by dindigala's avatar dindigala
Browse files

feat: annotation panel shows annotation about current text type

parent 08a24453
Pipeline #196977 passed with stages
in 3 minutes and 48 seconds
......@@ -131,21 +131,26 @@ export default {
* caller: *getItemData()*
* @param string url
*/
getAnnotations(url) {
this.request(url)
.then((annotations) => {
if (annotations.annotationCollection.first) {
this.request(annotations.annotationCollection.first)
.then((current) => {
if (current.annotationPage.items.length) {
this.annotations = current.annotationPage.items;
} else this.annotations = [];
});
}
})
.catch(() => {
this.$q.notify({ message: 'No annotations available' });
});
async getAnnotations(url) {
try {
const annotations = await this.request(url);
if (!annotations.annotationCollection.first) {
this.annotations = [];
return;
}
const current = await this.request(annotations.annotationCollection.first);
if (current.annotationPage.items.length) {
this.annotations = current.annotationPage.items;
} else {
this.annotations = [];
}
} catch (err) {
this.annotations = [];
this.$q.notify({ message: 'No annotations available' });
}
},
/**
* get collection data according to 'entrypoint'
......
......@@ -45,7 +45,7 @@ export default {
},
data() {
return {
ids: [],
};
},
computed: {
......@@ -59,6 +59,15 @@ export default {
created() {
this.icons = Icons;
},
mounted() {
this.$root.$on('update-content', async () => {
await new Promise((resolve) => setTimeout(resolve, 1000));
const ids = [...document.querySelectorAll('.ab')].map((x) => x.id);
this.ids = ids;
});
},
methods: {
createSVG(name) {
const [path, viewBox] = Icons[name].split('|');
......@@ -86,7 +95,11 @@ export default {
filterAnnotationTypes() {
const types = [];
this.annotations.forEach((annotation) => {
if (this.configuredTypes.filter((type) => type === annotation.body['x-content-type']).length > 0) {
let id = annotation.target.id.split('/');
id = id[id.length - 1];
if (this.configuredTypes.filter((type) => type === annotation.body['x-content-type']).length > 0 && this.ids.some((x) => id.startsWith(x))) {
types.push(annotation);
// function is triggered on list rendering, so we use it as init call to set up the text
this.setText(annotation);
......
......@@ -119,6 +119,7 @@ export default {
}
this.content = data;
this.$root.$emit('update-content');
});
},
},
......
......@@ -31,7 +31,7 @@
-->
<script id="tido-config" type="application/json">
{
"entrypoint": "",
"entrypoint": "https://ahikar-dev.sub.uni-goettingen.de/api/textapi/ahikar/arabic-karshuni/collection.json",
"annotations": {
"show": true,
"types": [
......
Markdown is supported
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