changes how the content and the news are displayed and also modifies the modals for the roominformation which now get their data from props instead of passing them directly via refs

This commit is contained in:
SimonGschnell
2024-06-19 11:15:06 +02:00
parent 6230aa47ae
commit 629ea3716e
16 changed files with 249 additions and 89 deletions
+5 -6
View File
@@ -69,12 +69,11 @@ class Cms extends Auth_Controller
*/
public function content($content_id, $version = null, $sprache = null, $sichtbar = true)
{
$content = $this->cmslib->getContent($content_id, $version, $sprache, $sichtbar);
if (isError($content))
return $this->load->view('CisHmvc/Error', ['error' => getError($content)]);
$this->load->view('CisHmvc/Cms/Content', ['content' => getData($content)]);
// return early if the content_id for the content is missing
if(!isset($content_id))
$this->terminateWithError("content_id is missing");
$this->load->view('CisHtml/Cms/Content', ['content_id' => $content_id, 'version' => $version, 'sprache' => $sprache, 'sichtbar' => $sichtbar]);
}
/**
+5 -6
View File
@@ -45,12 +45,11 @@ class Cms extends FHC_Controller
*/
public function content($content_id, $version = null, $sprache = null, $sichtbar = true)
{
$content = $this->cmslib->getContent($content_id, $version, $sprache, $sichtbar);
if (isError($content))
return $this->load->view('CisHtml/Error', ['error' => getError($content)]);
$this->load->view('CisHtml/Cms/Content', ['content' => getData($content)]);
// return early if the content_id for the content is missing
if(!isset($content_id))
$this->terminateWithError("content_id is missing");
$this->load->view('CisHtml/Cms/Content', ['content_id' => $content_id, 'version' => $version, 'sprache' => $sprache, 'sichtbar' => $sichtbar]);
}
/**
+5 -6
View File
@@ -39,12 +39,11 @@ class Cms extends FHC_Controller
*/
public function content($content_id, $version = null, $sprache = null, $sichtbar = true)
{
$content = $this->cmslib->getContent($content_id, $version, $sprache, $sichtbar);
if (isError($content))
return $this->load->view('CisHtml/Error', ['error' => getError($content)]);
$this->load->view('CisHtml/Cms/Content', ['content' => getData($content)]);
// return early if the content_id for the content is missing
if(!isset($content_id))
$this->terminateWithError("content_id is missing");
$this->load->view('CisHtml/Cms/Content', ['content_id' => $content_id, 'version' => $version, 'sprache' => $sprache, 'sichtbar' => $sichtbar]);
}
/**
@@ -0,0 +1,98 @@
<?php
/**
* Copyright (C) 2024 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* This controller operates between (interface) the JS (GUI) and the SearchBarLib (back-end)
* Provides data to the ajax get calls about the searchbar component
* This controller works with JSON calls on the HTTP GET and the output is always JSON
*/
class Cms extends FHCAPI_Controller
{
/**
* Object initialization
*/
public function __construct()
{
// NOTE(chris): additional permission checks will be done in SearchBarLib
parent::__construct([
'ContentID' => self::PERM_LOGGED,
'getOrtKurzbzContent' => self::PERM_LOGGED,
'content' => self::PERM_LOGGED,
]);
$this->load->library('CmsLib');
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* Gets a JSON body via HTTP POST and provides the parameters
*/
public function content()
{
// getting the get parameters
$content_id = $this->input->get("content_id",TRUE);
$version = $this->input->get("version",TRUE);
$sprache = $this->input->get("sprache",TRUE);
$sichtbar = $this->input->get("sichtbar",TRUE);
// return early if the content_id is missing
if(!isset($content_id))
$this->terminateWithError("content_id is missing", self::ERROR_TYPE_GENERAL);
$content = $this->cmslib->getContent($content_id, $version, $sprache, $sichtbar);
if (isError($content))
$this->terminateWithError(getError($content), self::ERROR_TYPE_GENERAL);
$this->terminateWithSuccess(getData($content));
}
/**
* Gets a JSON body via HTTP POST and provides the parameters
*/
public function ContentID()
{
// if error
//$this->terminateWithError(SearchBarLib::ERROR_WRONG_JSON, self::ERROR_TYPE_GENERAL);
$ort_kurzbz = $this->input->get('ort_kurzbz',TRUE);
if(!$ort_kurzbz){
$this->terminateWithError("missing ort_kurzbz parameter", self::ERROR_TYPE_GENERAL);
}
$result = $this->OrtModel->getContentID($ort_kurzbz);
if(isError($result)){
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$result = hasData($result) ? current(getData($result)) : null;
$this->terminateWithSuccess($result->content_id ?? NULL);
}
}
+2 -3
View File
@@ -10,11 +10,10 @@ $includesArray = array(
$this->load->view('templates/FHC-Header', $includesArray);
?>
<div id="cms">
<?php echo (isset($content) ? $content : '<content/>'); ?>
<?php echo (isset($content_id) ? '<cms-content :content_id="'.$content_id.'" :version="'.$version.'" :sprache="'.$sprache.'" :sichtbar="'.$sichtbar.'" />' : '<cms-news/>'); ?>
</div>
<?php $this->load->view('templates/FHC-Footer', $includesArray); ?>
+2 -1
View File
@@ -12,8 +12,9 @@ $this->load->view('templates/CISHTML-Header', $includesArray);
?>
<div id="cms">
<?php echo (isset($content) ? $content : '<content/>'); ?>
<?php echo (isset($content_id) ? '<cms-content :content_id="'.$content_id.'" :version="'.$version.'" :sprache="'.$sprache.'" :sichtbar="'.$sichtbar.'" />' : '<cms-news/>'); ?>
</div>
<?php $this->load->view('templates/CISHTML-Footer', $includesArray); ?>
+3 -1
View File
@@ -11,7 +11,9 @@ $this->load->view('templates/CISVUE-Header', $includesArray);
?>
<div id="cms">
<?php echo (isset($content) ? $content : '<content/>'); ?>
<?php echo (isset($content_id) ? '<cms-content :content_id="'.$content_id.'" :version="'.$version.'" :sprache="'.$sprache.'" :sichtbar="'.$sichtbar.'" />' : '<cms-news/>'); ?>
</div>
<?php $this->load->view('templates/CISVUE-Footer', $includesArray); ?>
+15
View File
@@ -0,0 +1,15 @@
export default {
content(content_id, version=null, sprache=null, sichtbar=null) {
return this.$fhcApi.get(
FHC_JS_DATA_STORAGE_OBJECT.app_root +
FHC_JS_DATA_STORAGE_OBJECT.ci_router +
"/api/frontend/v1/Cms/content",
{ content_id: content_id,
...(version?{version}:{}),
...(sprache?{sprache}:{}),
...(sichtbar?{sichtbar}:{}),
}
);
},
}
+2
View File
@@ -21,6 +21,7 @@ import navigation from "./navigation.js";
import filter from "./filter.js";
import studstatus from "./studstatus.js";
import ort from "./ort.js";
import cms from "./cms.js";
export default {
search,
@@ -29,4 +30,5 @@ export default {
filter,
studstatus,
ort,
cms,
};
+2 -10
View File
@@ -1,18 +1,10 @@
export default {
getContentID($ort_kurbz) {
getContentID(ort_kurbz) {
return this.$fhcApi.get(
FHC_JS_DATA_STORAGE_OBJECT.app_root +
FHC_JS_DATA_STORAGE_OBJECT.ci_router +
"/api/frontend/v1/Ort/ContentID",
{ ort_kurzbz: $ort_kurbz }
);
},
getOrtKuzbzContent($ort_kurzbz_content_id) {
return this.$fhcApi.get(
FHC_JS_DATA_STORAGE_OBJECT.app_root +
FHC_JS_DATA_STORAGE_OBJECT.ci_router +
"/api/frontend/v1/Ort/getOrtKurzbzContent",
{ content_id: $ort_kurzbz_content_id }
{ ort_kurzbz: ort_kurbz }
);
},
}
+6 -4
View File
@@ -1,13 +1,14 @@
import BsConfirm from "../../components/Bootstrap/Confirm.js";
//import Pagination from "../../components/Pagination/Pagination.js";
import Content from "../../components/Cis/Cms/Content.js";
import Fhcapi from "../api/fhcapifactory.js";
import CmsNews from "../../components/Cis/Cms/News.js";
import CmsContent from "../../components/Cis/Cms/Content.js";
import Fhcapi from "../../plugin/FhcApi.js";
Vue.$fhcapi = Fhcapi;
const app = Vue.createApp({
components: {
Content,
CmsNews,
CmsContent,
},
mounted() {
document.querySelectorAll("#cms [data-confirm]").forEach((el) => {
@@ -34,5 +35,6 @@ const app = Vue.createApp({
},
});
app.use(primevue.config.default, { zIndex: { overlay: 9999 } });
app.use(Fhcapi);
app.mount("#cms");
//#cms [data-confirm], #cms [data-href]
+1 -1
View File
@@ -109,7 +109,7 @@ export default {
document.body.appendChild(wrapper);
});
},
template: `<div ref="modal" class="bootstrap-modal modal" tabindex="-1" @[\`hide.bs.modal\`]="$emit('hideBsModal')" @[\`hidden.bs.modal\`]="$emit('hiddenBsModal')" @[\`hidePrevented.bs.modal\`]="$emit('hidePreventedBsModal')" @[\`show.bs.modal\`]="$emit('showBsModal')" @[\`shown.bs.modal\`]="$emit('shownBsModal')">
template: `<div ref="modal" class="bootstrap-modal modal" tabindex="-1" @[\`hide.bs.modal\`]="$emit('hideBsModal')" @[\`hidden.bs.modal\`]="$emit('hiddenBsModal')" @[\`hidePrevented.bs.modal\`]="$emit('hidePreventedBsModal')" @[\`show.bs.modal\`]="$emit('showBsModal')" >
<div class="modal-dialog" :class="dialogClass">
<div class="modal-content">
<div v-if="$slots.title" class="modal-header">
+27 -21
View File
@@ -1,34 +1,40 @@
import Pagination from "../../Pagination/Pagination.js";
export default {
components: {
Pagination,
props:{
content_id:{
type:Number,
required:true,
},
version:{
type:[String, Number],
default: null,
},
sprache:{
type:[String, Number],
default: null,
},
sichtbar:{
type:[String, Number],
default: null,
}
},
data() {
return {
content: null,
maxPageCount: 0,
page_size: 10,
};
},
methods: {
loadNewPageContent: function (data) {
Vue.$fhcapi.Cms.getNews(data.page, data.rows).then((result) => {
this.content = result.data;
});
},
},
created() {
Vue.$fhcapi.Cms.getNews(1, this.page_size).then((result) => {
this.content = result.data;
});
Vue.$fhcapi.Cms.getNewsRowCount().then((result) => {
this.maxPageCount = result.data;
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;
});
},
template: /*html*/ `
<pagination :page_size="page_size" @page="loadNewPageContent" :maxPageCount="maxPageCount">
<div v-html="content"></div>
</pagination>`,
<!-- div that contains the content -->
<div v-if="content" v-html="content"></div>
<p v-else>No content is available to display</p>
`,
};
+28 -10
View File
@@ -9,35 +9,53 @@ export default {
components:{
BsModal,
},
props:{
contentID:{
type: Number,
required: true,
},
ort_kurzbz:{
type: String,
required: true,
}
},
data(){
return{
content_id:null,
content:null,
ort_kurzbz:null,
result: false,
content: null,
};
},
methods:{
modalHidden: function(){
// reseting the content of the modal
this.content = null;
},
// this method is always called when the modal is shown
modalShown: function(){
}
if(this.contentID){
this.$fhcApi.factory.cms.content(this.contentID).then(res =>{
this.content = res.data;
})
}
},
},
mounted(){
this.modal = this.$refs.modalContainer;
document.addEventListener("show.bs.modal", function(){
console.log("modal is shown inside the mounted hook")
})
},
template:/*html*/`
<bs-modal @showBsModal="modalShown" ref="modalContainer" dialogClass="modal-lg">
<bs-modal @hideBsModal="modalHidden" @showBsModal="modalShown" ref="modalContainer" dialogClass="modal-lg">
<template #title>
<span v-if="ort_kurzbz">{{ort_kurzbz}}</span>
<span v-else>Ort Übersicht</span>
<span v-else>Raum Informationen</span>
</template>
<template #default>
<div v-if="content" v-html="content"></div>
<div v-else>this is the else div</div>
<div v-else>Der Content für diesen Raum konnte nicht geladen werden</div>
</template>
<template #footer>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
+34
View File
@@ -0,0 +1,34 @@
import Pagination from "../../Pagination/Pagination.js";
export default {
components: {
Pagination,
},
data() {
return {
content: null,
maxPageCount: 0,
page_size: 10,
};
},
methods: {
loadNewPageContent: function (data) {
Vue.$fhcapi.Cms.getNews(data.page, data.rows).then((result) => {
this.content = result.data;
});
},
},
created() {
Vue.$fhcapi.Cms.getNews(1, this.page_size).then((result) => {
this.content = result.data;
});
Vue.$fhcapi.Cms.getNewsRowCount().then((result) => {
this.maxPageCount = result.data;
});
},
template: /*html*/ `
<pagination :page_size="page_size" @page="loadNewPageContent" :maxPageCount="maxPageCount">
<div v-html="content"></div>
</pagination>`,
};
@@ -2,7 +2,7 @@ import Phrasen from '../../mixins/Phrasen.js';
import AbstractWidget from './Abstract.js';
import FhcCalendar from '../Calendar/Calendar.js';
import LvUebersicht from '../Cis/Mylv/LvUebersicht.js';
import ContentModal from '../Cis/Cms/ContentModal.js'
import ContentModal from '../Cis/Cms/ContentModal.js';
export default {
mixins: [
@@ -21,7 +21,8 @@ export default {
minimized: true,
events: null,
currentDay: new Date(),
roomInfoContentID: null,
ort_kurzbz: null,
}
},
computed: {
@@ -41,26 +42,18 @@ export default {
// getting the content_id of the ort_kurzbz
this.$fhcApi.factory.ort.getContentID(ort_kurzbz).then(res =>{
this.roomInfoContentID = res.data;
this.ort_kurzbz = ort_kurzbz;
let ort_kurzbz_content_id = res.data;
this.$refs.contentModal.content_id = ort_kurzbz_content_id;
this.$fhcApi.factory.ort.getOrtKuzbzContent(ort_kurzbz_content_id).then(res =>{
let result = res.data;
console.log("this is the result of the query", result);
this.$refs.contentModal.content = result;
this.$refs.contentModal.ort_kurzbz = ort_kurzbz;
if(this.$refs.contentModal.content){
this.$refs.contentModal.show();
}
})
// only showing the modal after vue was able to set the reactive data
Vue.nextTick(()=>{this.$refs.contentModal.show();});
})
}).catch(err =>{
console.err(err);
this.ort_kurzbz = null;
this.roomInfoContentID = null;
});
},
showLvUebersicht: function (event){
@@ -75,6 +68,7 @@ export default {
this.currentDay = day;
this.minimized = true;
},
// this function was the alternative of showing the room information in the content component instead of showing the room information inside a modal
showRoomInfo: function($ort_kurzbz){
this.$fhcApi.factory.ort.getContentID($ort_kurzbz).then(res =>{
@@ -118,7 +112,7 @@ export default {
template: /*html*/`
<div class="dashboard-widget-stundenplan d-flex flex-column h-100">
<lv-uebersicht ref="lvUebersicht" />
<content-modal ref="contentModal" />
<content-modal :contentID="roomInfoContentID" :ort_kurzbz="" dialogClass="modal-lg" ref="contentModal"/>
<fhc-calendar :initial-date="currentDay" class="border-0" class-header="p-0" @select:day="selectDay" v-model:minimized="minimized" :events="events" no-week-view :show-weeks="false" />
<div v-show="minimized" class="flex-grow-1 overflow-scroll">
<div v-if="events === null" class="d-flex h-100 justify-content-center align-items-center">