delete cms app and move dom magic to respective components; profil vue router integration; profil component reloads with watcher on uid property; profiLUpdateRequest app->comp TODO; deleted profil app;

This commit is contained in:
Johann Hoffmann
2025-01-22 15:16:15 +01:00
parent bb8ebdd465
commit de8a206f27
9 changed files with 115 additions and 516 deletions
+24
View File
@@ -1,5 +1,6 @@
import raum_contentmittitel from './Content_types/Raum_contentmittitel.js'
import general from './Content_types/General.js'
import BsConfirm from "../../Bootstrap/Confirm";
export default {
name: "ContentComponent",
@@ -32,6 +33,29 @@ export default {
return this.$fhcApi.factory.cms.content(this.content_id_internal, this.version, this.sprache, this.sichtbar).then(res => {
this.content = res.data.content;
this.content_type = res.data.type;
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
);
});
});
}
},
+24
View File
@@ -1,5 +1,6 @@
import Pagination from "../../Pagination/Pagination.js";
import StudiengangInformation from "./StudiengangInformation/StudiengangInformation.js";
import BsConfirm from "../../Bootstrap/Confirm";
export default {
name: "NewsComponent",
@@ -31,6 +32,29 @@ export default {
.then(res => res.data)
.then(result => {
this.content = result;
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
);
});
});
},
loadNewPageContent: function (data) {
+40 -30
View File
@@ -40,6 +40,12 @@ export const Profil = {
ViewMitarbeiterProfil,
Loading,
},
props: {
uid: {
type: String,
default: 'Profil'
}
},
data() {
return {
//? loading property is used for showing/hiding the loading modal
@@ -124,6 +130,35 @@ export const Profil = {
};
},
methods: {
async load() {
// fetch profilUpdateStates to provide them to children components
await this.$fhcApi.factory.profilUpdate.getStatus()
.then((response) => {
this.profilUpdateStates = response.data;
})
.catch((error) => {
console.error(error);
});
this.$fhcApi.factory.profilUpdate.getTopic()
.then((response) => {
this.profilUpdateTopic = response.data;
})
.catch((error) => {
console.error(error);
});
let uid = this.uid ?? location.pathname.split("/").pop();
this.$fhcApi.factory.profil.getView(uid).then((res) => {
if (!res.data) {
this.notFoundUID = uid;
} else {
this.view = res.data?.view;
this.data = res.data?.data;
}
});
},
zustellAdressenCount() {
if (!this.data || !this.data.adressen) {
return null;
@@ -319,39 +354,14 @@ export const Profil = {
this.$refs.loadingModalRef.hide();
}
},
uid (newVal, oldVal) {
console.log('watch uid', newVal)
this.load()
}
},
async created() {
// fetch profilUpdateStates to provide them to children components
await this.$fhcApi.factory.profilUpdate.getStatus()
.then((response) => {
this.profilUpdateStates = response.data;
})
.catch((error) => {
console.error(error);
});
this.$fhcApi.factory.profilUpdate.getTopic()
.then((response) => {
this.profilUpdateTopic = response.data;
})
.catch((error) => {
console.error(error);
});
//? uid contains the last part of the uri
let uid = location.pathname.split("/").pop();
this.$fhcApi.factory.profil.getView(uid).then((res) => {
if (!res.data) {
this.notFoundUID = uid;
} else {
this.view = res.data?.view;
this.data = res.data?.data;
}
});
this.load()
},
template: `
<div>
<div v-if="notFoundUID">