diff --git a/application/config/stv.php b/application/config/stv.php index d6d06f44e..000242ac5 100644 --- a/application/config/stv.php +++ b/application/config/stv.php @@ -61,7 +61,11 @@ $config['tabs'] = 'notes' => [ //if true, the count of Messages will be shown in the header of the Tab Messages 'showCountNotes' => true - ] + ], + 'combinePeople' => [ + //multitab should only be shown with this length of selection + 'validCountMulti' => 2, + ], ]; // List of fields to show when ZGV_DOKTOR_ANZEIGEN is defined diff --git a/application/controllers/api/frontend/v1/stv/Config.php b/application/controllers/api/frontend/v1/stv/Config.php index 20e43d23a..67b71c36d 100644 --- a/application/controllers/api/frontend/v1/stv/Config.php +++ b/application/controllers/api/frontend/v1/stv/Config.php @@ -231,6 +231,7 @@ class Config extends FHCAPI_Controller $result['combinePeople'] = [ 'title' => $this->p->t('stv', 'tab_combine_people'), 'component' => './Stv/Studentenverwaltung/Details/CombinePeople.js', + 'config' => $config['combinePeople'] ]; Events::trigger('stv_conf_students', function & () use (&$result) { diff --git a/public/js/components/Stv/Studentenverwaltung/Details/CombinePeople.js b/public/js/components/Stv/Studentenverwaltung/Details/CombinePeople.js index 4374687fe..facf8848f 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/CombinePeople.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/CombinePeople.js @@ -8,50 +8,83 @@ export default { props: { modelValue: Object, }, + data(){ + return { + iframeUrl: null, + viewLoaded: false + } + }, computed: { personIds(){ if (this.modelValue.person_id) { return [this.modelValue.person_id]; } return this.modelValue.map(e => e.person_id); - } + }, + detailStringPerson1(){ + let person1 = this.modelValue[0]; + return person1.vorname + " " + person1.nachname + "(" + person1.person_id + ")"; + }, + detailStringPerson2(){ + let person2 = this.modelValue[1]; + return person2.vorname + " " + person2.nachname + "(" + person2.person_id+ ")"; + }, + }, methods: { combinePeople(){ - + this.viewLoaded = true; let person1_id = this.personIds[0]; let person2_id = this.personIds[1]; if(person1_id == person2_id) { - return this.$fhcAlert.alertError("gleiche Person, keine Zusammenlegeung möglich"); + //TODO(Manu) Phrase + return this.$fhcAlert.alertError("gleiche Person, keine Zusammenlegung möglich"); } - let linkCombinePeople = this.cisRoot + 'vilesci/stammdaten/personen_wartung.php?person_id_1=' + person1_id + '&person_id_2='+ person2_id; + // let linkCombinePeople = this.cisRoot + 'vilesci/stammdaten/personen_wartung.php?person_id_1=' + person1_id + '&person_id_2='+ person2_id; + let linkCombinePeople = 'https://c3p0.ma0068.technikum-wien.at/fhcomplete/vilesci/stammdaten/personen_wartung.php?person_id_1=' + person1_id + '&person_id_2='+ person2_id; console.log(linkCombinePeople); - window.open(linkCombinePeople, '_blank'); - - + //window.open(linkCombinePeople, '_blank'); + this.openLink(linkCombinePeople); + }, + openLink(url) { + this.iframeUrl = url; + }, + goBack(){ + this.viewLoaded = false; + this.iframeUrl = null; } }, - data(){ - return {} - }, template: /*html*/ `
-

Personen zusammenlegen

- {{personIds}} - -
- -

- -

-

- ungültige Anzahl: {{this.modelValue.length}} -

+
+

Personen zusammenlegen

+
+
+ +

Die Personen {{detailStringPerson1}} und {{detailStringPerson2}} zusammenlegen?

+ +
+
+ ungültige Anzahl: {{this.modelValue.length}} +
+
+
+ +
+ + + +
` }; \ No newline at end of file diff --git a/public/js/components/Tabs.js b/public/js/components/Tabs.js index aedd5c1c9..5db8d66ba 100644 --- a/public/js/components/Tabs.js +++ b/public/js/components/Tabs.js @@ -33,7 +33,8 @@ export default { data() { return { current: null, - tabs: {} + tabs: {}, + count: null } }, computed: { @@ -113,10 +114,12 @@ export default { }; } - if (Array.isArray(config)) + if (Array.isArray(config)) { config.forEach((item, key) => _addToTabs(key, item)); - else + } + else { Object.entries(config).forEach(([key, item]) => _addToTabs(key, item)); + } if (this.current === null || !tabs[this.current]) { if (tabs[this.default]) @@ -129,6 +132,57 @@ export default { updateSuffix() { this.getTabSuffix(this.currentTab); }, + removeInvalidCountTabs(){ + if(this.modelValue.length) + { + let countIst = this.modelValue.length; + const tabsToDelete = []; + + Object.entries(this.config).forEach(([key, item]) => { + + const target = item?.config ? item : item?.value || item; + + // check config for validCountMulti + if (target.config?.validCountMulti !== undefined) { + let tab; + let countSoll; + tab = key; + countSoll = target.config.validCountMulti; + + //check if tab is existing + if (countSoll !== undefined && countSoll == countIst) { + //add tab if it was removed before + if (tab in this.tabs == false) { + const value = Vue.reactive({ + suffix: '', + showSuffix: item.showSuffix || false + }); + + this.tabs[tab] = { + component: Vue.markRaw(Vue.defineAsyncComponent(() => import(item.component))), + title: Vue.computed(() => item.title || tab), + config: item.config, + tab, + value, + suffixhelper: item.suffixhelper ?? null + }; + } + } + + //add to toDeleteArray if count is not allowed + if (countSoll !== undefined && countSoll !== countIst) { + tabsToDelete.push(tab); + } + } + }); + + // Delete all tabs with count not allowed + tabsToDelete.forEach(k => { + delete this.tabs[k]; + }); + + } + }, async getTabSuffix(tab) { if (!tab.value.showSuffix) { return; @@ -151,9 +205,11 @@ export default { }, mounted() { this.getTabSuffixes(); + this.removeInvalidCountTabs(); }, updated() { this.getTabSuffixes(); + this.removeInvalidCountTabs(); }, template: `