Files
FHC-Core/public/js/components/Cis/Cms/Content.js
T

68 lines
1.3 KiB
JavaScript

import raum_contentmittitel from './Content_types/Raum_contentmittitel.js'
import general from './Content_types/General.js'
export default {
props: {
content_id: {
type: Number,
required: true,
},
version: {
type: [String, Number],
default: null,
},
sichtbar: {
type: [String, Number],
default: null,
}
},
components: {
raum_contentmittitel,
general,
},
data() {
return {
content: null,
};
},
watch:{
sprache: function(sprache){
this.fetchContent();
console.log(sprache);
},
},
computed: {
sprache(){
return this.$p.user_language.value;
},
computeContentType: function () {
switch (this.content_type) {
case "raum_contentmittitel":
return "raum_contentmittitel";
default:
return "general";
}
;
},
},
methods:{
fetchContent(){
return this.$fhcApi.factory.cms.content(this.content_id, this.version, this.sprache, this.sichtbar).then(res => {
this.content = res.data.content;
this.content_type = res.data.type;
});
}
},
created() {
this.fetchContent();
},
template: /*html*/ `
<!-- div that contains the content -->
<component :is="computeContentType" v-if="content" :content="content" :content_id="content_id" />
<p v-else>No content is available to display</p>
`,
};