Skip to content
Snippets Groups Projects
Commit 7a7e2acb authored by Julian's avatar Julian
Browse files

Create object overview component

parent 85d9ce7f
No related branches found
No related tags found
1 merge request!1123Resolve "Finalise Vuetify app as SPA"
<template>
<div>
<slot name="loading" v-if="$apollo.queries.object.loading"></slot>
<slot v-else-if="object" v-bind="object"></slot>
<error-page
v-else
:shortErrorMessageKey="shortErrorMessageKey"
:longErrorMessageKey="longErrorMessageKey"
/>
</div>
</template>
<script>
export default {
name: "ObjectOverview",
props: {
titleAttr: {
type: String,
required: true,
},
query: {
type: Object,
required: true,
},
shortErrorMessageKey: {
type: String,
required: false,
default: "network_errors.error_404",
},
longErrorMessageKey: {
type: String,
required: false,
default: "network_errors.page_not_found",
},
},
methods: {
getTitleAttr(obj) {
let tmpObj = obj;
this.titleAttr.split(".").forEach((attr) => {tmpObj = tmpObj[attr]})
return tmpObj;
}
},
apollo: {
object() {
return {
query: this.query,
variables() {
if (this.$route.params.id) {
return {
id: this.$route.params.id,
};
}
return {};
},
result({data}) {
if (data && data.object) {
this.$root.$setPageTitle(this.getTitleAttr(data.object));
}
},
};
},
},
}
</script>
<style scoped>
</style>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment