adds a view components for the news if the content that gets loaded has the template_kurzbz news

This commit is contained in:
SimonGschnell
2024-06-26 14:17:44 +02:00
parent 478adb740e
commit 4640db5aff
5 changed files with 67 additions and 16 deletions
+1
View File
@@ -51,6 +51,7 @@ class Cms extends FHC_Controller
$this->terminateWithError(getError($content));
$content = getData($content);
if(NULL === $content)
$this->terminateWithError("Content not found");
@@ -48,9 +48,10 @@ class Cms extends FHCAPI_Controller
private function fetchContent($content_id){
$content = $this->cmslib->getContent($content_id);
if (isError($content))
$this->terminateWithError(getError($content), self::ERROR_TYPE_GENERAL);
if (isError($content)){
$this->terminateWithError(getError($content), self::ERROR_TYPE_GENERAL);
}
if(getData($content)){
return getData($content);
@@ -79,7 +80,7 @@ class Cms extends FHCAPI_Controller
$content = $this->fetchContent($content_id);
$this->terminateWithSuccess(getData($content));
$this->terminateWithSuccess($content);
}
/**
@@ -130,7 +131,7 @@ class Cms extends FHCAPI_Controller
// collect the content of the news
foreach($news as $news_element){
$this->addMeta("asdfs",$news_element->content_id);
$this->addMeta("content_id",$news_element->content_id);
$news_element->content_obj = $this->fetchContent($news_element->content_id);
}
+6 -3
View File
@@ -1,4 +1,5 @@
import raum_contentmittitel from './Content_types/Raum_contentmittitel.js'
import news from './Content_types/News.js'
export default {
@@ -32,15 +33,17 @@ export default {
};
},
created() {
console.log("this is the api", this.$fhcApi);
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;
this.content_type=res.data.content;
});
},
mounted(){
},
template: /*html*/ `
<!-- div that contains the content -->
<component :is="content_type" v-if="content" :content="content" />
<component :is="'raum_contentmittitel'" v-if="content" :content="content" />
<p v-else>No content is available to display</p>
`,
@@ -0,0 +1,38 @@
export default {
props:{
content:{
type:String,
required:true,
},
},
mounted(){
document.querySelectorAll("#cms [data-confirm]").forEach((el) => {
el.addEventListener("click", (evt) => {
evt.preventDefault();
BsConfirm.popup(el.dataset.confirm)
.then(() => {
Axios.get(el.href)
.then((res) => {
// TODO(chris): check for success then show message and/or reload
location = location;
})
.catch((err) => console.error("ERROR:", err));
})
.catch(() => {});
});
});
document.querySelectorAll("#cms [data-href]").forEach((el) => {
el.href = el.dataset.href.replace(
/^ROOT\//,
FHC_JS_DATA_STORAGE_OBJECT.app_root
);
});
},
template: /*html*/ `
<!-- div that contains the content -->
<div v-html="content" v-if="content" :content="content" />
<p v-else>Content was not found</p>
`,
};
+16 -8
View File
@@ -13,6 +13,9 @@ export default {
AbstractWidget
],
computed: {
newsList(){
//Return news amount depending on widget width and size
let quantity = this.width;
@@ -28,14 +31,18 @@ export default {
}
},
created(){
console.log(MAX_LOADED_NEWS,"this are the max news");
this.$fhcApi.factory.cms.news(MAX_LOADED_NEWS)
.then(res => { this.allNewsList = res.data })
.catch(err => { console.error('ERROR: ', err.response.data) });
this.$fhcApi.factory.cms.news(MAX_LOADED_NEWS)
.then(res => { this.allNewsList = res.data })
.catch(err => { console.error('ERROR: ', err.response.data) });
this.$emit('setConfig', false);
},
methods: {
contentURI: function(content_id){
return FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/CisVue/Cms/content/' + content_id;
},
setSingleNews(singleNews){
this.singleNews = singleNews;
this.$refs.newsModal.show();
@@ -53,7 +60,7 @@ export default {
<div v-for="news in newsList" :key="news.id" class="mt-2">
<div class="card">
<div class=" card-body">
<a href="#newsModal" class="stretched-link" @click="setSingleNews(news)">{{ news.content_obj.betreff?news.content_obj.betreff:'Kein Betreff vorhanden' }}</a><br>
<a :href="contentURI(news.content_id)" class="stretched-link" >{{ news.content_obj.betreff?news.content_obj.betreff:'Kein Betreff vorhanden' }}</a><br>
<span class="small text-muted">{{ formatDateTime(news.insertamum) }}</span>
</div>
</div>
@@ -78,8 +85,8 @@ export default {
</div>
<!-- News Modal -->
<BsModal ref="newsModal" id="newsModal" dialog-class="modal-lg">
<!-- News Modal old way of showing the news content if clicking on the little content format-->
<!--<BsModal ref="newsModal" id="newsModal" dialog-class="modal-lg">
<template #title>
<div class="row">
<div class="col-5"><img :src="placeHolderImgURL" class="img-fluid rounded-start"></div>
@@ -89,6 +96,7 @@ export default {
</template>
<template #default>{{ singleNews.text }}</template>
</BsModal>
-->
<!-- All News Modal -->
<BsModal ref="allNewsModal" id="allNewsModal" dialog-class="modal-fullscreen">