From d33f493543f3ccef3353d111530216072bcdc9e2 Mon Sep 17 00:00:00 2001 From: Alexei Karpenko Date: Sat, 24 May 2025 10:14:08 +0200 Subject: [PATCH 1/5] Studentenverwaltung archive: switched to new api factory --- .../api/frontend/v1/stv/Archiv.php | 6 +- public/js/api/factory/stv/archiv.js | 44 ++++ .../Stv/Studentenverwaltung/Details/Archiv.js | 247 +++++++++--------- .../Details/Archiv/Edit.js | 2 +- 4 files changed, 168 insertions(+), 131 deletions(-) create mode 100644 public/js/api/factory/stv/archiv.js diff --git a/application/controllers/api/frontend/v1/stv/Archiv.php b/application/controllers/api/frontend/v1/stv/Archiv.php index 91fc9643d..cc636951d 100644 --- a/application/controllers/api/frontend/v1/stv/Archiv.php +++ b/application/controllers/api/frontend/v1/stv/Archiv.php @@ -34,7 +34,7 @@ class Archiv extends FHCAPI_Controller public function __construct() { parent::__construct([ - 'get' => ['admin:r', 'assistenz:r'], + 'getArchiv' => ['admin:r', 'assistenz:r'], 'getArchivVorlagen' => ['admin:r', 'assistenz:r'], 'archive' => ['admin:w', 'assistenz:w'], 'download' => ['admin:w', 'assistenz:w'], @@ -60,9 +60,9 @@ class Archiv extends FHCAPI_Controller * @return void */ - public function get() + public function getArchiv() { - $person_id = $this->input->post('person_id'); + $person_id = $this->input->get('person_id'); $this->load->library('form_validation'); diff --git a/public/js/api/factory/stv/archiv.js b/public/js/api/factory/stv/archiv.js new file mode 100644 index 000000000..4205a5ecc --- /dev/null +++ b/public/js/api/factory/stv/archiv.js @@ -0,0 +1,44 @@ +export default { + getArchiv(person_id) { + console.log(person_id); + return { + method: 'get', + url: 'api/frontend/v1/stv/archiv/getArchiv', + params: { person_id } + }; + }, + getArchivVorlagen() { + return { + method: 'get', + url: 'api/frontend/v1/stv/archiv/getArchivVorlagen' + }; + }, + archive(data) { + return { + method: 'post', + url: 'api/frontend/v1/documents/archive', + params: data + }; + }, + archiveSigned(data) { + return { + method: 'post', + url: 'api/frontend/v1/documents/archiveSigned', + params: data + }; + }, + update(data) { + return { + method: 'post', + url: 'api/frontend/v1/stv/archiv/update', + params: data + }; + }, + delete(akte_id, studiengang_kz) { + return { + method: 'post', + url: 'api/frontend/v1/stv/archiv/delete', + params: {akte_id, studiengang_kz} + }; + } +}; diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Archiv.js b/public/js/components/Stv/Studentenverwaltung/Details/Archiv.js index 5bd20e154..f9c884782 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Archiv.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Archiv.js @@ -2,6 +2,8 @@ import {CoreFilterCmpt} from "../../../filter/Filter.js"; import FormInput from "../../../Form/Input.js"; import AkteEdit from "./Archiv/Edit.js"; +import ApiStvArchiv from '../../../../api/factory/stv/archiv.js'; + export default { components: { CoreFilterCmpt, @@ -61,131 +63,118 @@ export default { 'abschlussdokument_lehrgaenge.xml.php': [ 'AbschlussdokumentLehrgaenge' ] - } - //studiengang_kz: false - }; - }, - computed: { - //~ personIds() { - //~ if (this.modelValue.person_id) - //~ return [this.modelValue.person_id]; - //~ return this.modelValue.map(e => e.person_id); - //~ }, - tabulatorColumns() { - const columns = [ - {title: "Akte Id", field: "akte_id", visible: false}, - {title: this.$p.t('stv', 'archiv_title'), field: "titel"}, - {title: this.$p.t('stv', 'archiv_description'), field: "bezeichnung"}, - {title: this.$p.t('stv', 'archiv_creation_date'), field: "erstelltam"}, - { - title: this.$p.t('stv', 'archiv_signiert'), - field: "signiert", - formatter:"tickCross", - hozAlign:"center", - formatterParams: { - tickElement: '', - crossElement: '' - } - }, - { - title: "Selfservice", - field: "stud_selfservice", - formatter:"tickCross", - hozAlign:"center", - formatterParams: { - tickElement: '', - crossElement: '' - }, - }, - {title: this.$p.t('stv', 'archiv_accepted_on_at'), field: "akzeptiertamum"}, - { - title: this.$p.t('stv', 'archiv_gedruckt'), - field: "gedruckt", - visible: false, - formatter:"tickCross", - hozAlign:"center", - formatterParams: { - tickElement: '', - crossElement: '' - } - }, - { - title: 'Aktionen', field: 'actions', - formatter: (cell, formatterParams, onRendered) => { - let container = document.createElement('div'); - container.className = "d-flex gap-2"; - - let downloadButton = document.createElement('button'); - downloadButton.className = 'btn btn-outline-secondary'; - downloadButton.innerHTML = ''; - downloadButton.title = this.$p.t('ui', 'downloadDok'); - downloadButton.addEventListener('click', evt => { - evt.stopPropagation(); - this.actionDownload(cell.getData().akte_id); - }); - container.append(downloadButton); - - if (this.config.showEdit) - { - let editButton = document.createElement('button'); - editButton.className = 'btn btn-outline-secondary'; - editButton.innerHTML = ''; - editButton.title = this.$p.t('ui', 'bearbeiten'); - editButton.addEventListener('click', () => - this.$refs.edit.open(cell.getData()) - ); - container.append(editButton); + }, + tabulatorOptions: { + ajaxURL: 'dummy', + ajaxRequestFunc: () => this.$api.call( + ApiStvArchiv.getArchiv( + this.modelValue.person_id ? [this.modelValue.person_id] : null || this.modelValue.map(e => e.person_id) + ) + ), + ajaxResponse: (url, params, response) => response.data, + columns: [ + {title: "Akte Id", field: "akte_id", visible: false}, + {title: this.$p.t('stv', 'archiv_title'), field: "titel"}, + {title: this.$p.t('stv', 'archiv_description'), field: "bezeichnung"}, + {title: this.$p.t('stv', 'archiv_creation_date'), field: "erstelltam"}, + { + title: this.$p.t('stv', 'archiv_signiert'), + field: "signiert", + formatter:"tickCross", + hozAlign:"center", + formatterParams: { + tickElement: '', + crossElement: '' } - - let deleteButton = document.createElement('button'); - deleteButton.className = 'btn btn-outline-secondary'; - deleteButton.innerHTML = ''; - deleteButton.title = this.$p.t('ui', 'loeschen'); - deleteButton.addEventListener('click', evt => { - evt.stopPropagation(); - this.$fhcAlert - .confirmDelete() - .then(result => result ? {akte_id: cell.getData().akte_id, studiengang_kz: this.modelValue.studiengang_kz} : Promise.reject({handled:true})) - .then(this.$fhcApi.factory.stv.archiv.delete) - .then(() => { - //cell.getRow().delete(); - this.reload(); - }) - .catch(this.$fhcAlert.handleSystemError); - }); - container.append(deleteButton); - - return container; }, - minWidth: 150, // Ensures Action-buttons will be always fully displayed - maxWidth: 150, - frozen: true - } - ]; - return Object.values(columns); - }, - tabulatorOptions() { - return this.$fhcApi.factory.stv.archiv.tabulatorConfig({ + { + title: "Selfservice", + field: "stud_selfservice", + formatter:"tickCross", + hozAlign:"center", + formatterParams: { + tickElement: '', + crossElement: '' + }, + }, + {title: this.$p.t('stv', 'archiv_accepted_on_at'), field: "akzeptiertamum"}, + { + title: this.$p.t('stv', 'archiv_gedruckt'), + field: "gedruckt", + visible: false, + formatter:"tickCross", + hozAlign:"center", + formatterParams: { + tickElement: '', + crossElement: '' + } + }, + { + title: 'Aktionen', field: 'actions', + formatter: (cell, formatterParams, onRendered) => { + let container = document.createElement('div'); + container.className = "d-flex gap-2"; + + let downloadButton = document.createElement('button'); + downloadButton.className = 'btn btn-outline-secondary'; + downloadButton.innerHTML = ''; + downloadButton.title = this.$p.t('ui', 'downloadDok'); + downloadButton.addEventListener('click', evt => { + evt.stopPropagation(); + this.actionDownload(cell.getData().akte_id); + }); + container.append(downloadButton); + + if (this.config.showEdit) + { + let editButton = document.createElement('button'); + editButton.className = 'btn btn-outline-secondary'; + editButton.innerHTML = ''; + editButton.addEventListener('click', () => + this.$refs.edit.open(cell.getData()) + ); + container.append(editButton); + } + + let deleteButton = document.createElement('button'); + deleteButton.className = 'btn btn-outline-secondary'; + deleteButton.innerHTML = ''; + deleteButton.addEventListener('click', evt => { + evt.stopPropagation(); + this.$fhcAlert + .confirmDelete() + .then(result => result ? {akte_id: cell.getData().akte_id, studiengang_kz : this.modelValue.studiengang_kz} : Promise.reject({handled:true})) + .then(params => this.$api.call(ApiStvArchiv.delete(params.akte_id, params.studiengang_kz))) + .then(() => { + //cell.getRow().delete(); + this.reload(); + }) + .catch(this.$fhcAlert.handleSystemError); + }); + container.append(deleteButton); + + return container; + }, + minWidth: 150, // Ensures Action-buttons will be always fully displayed + maxWidth: 150, + frozen: true + } + ], layout:"fitDataTable", - columns: this.tabulatorColumns, - //selectable: true, - //selectableRangeMode: 'click', index: 'akte_id', persistenceID: 'stv-details-archiv' - }, this); - }, - tabulatorEvents() { - const events = [ + }, + tabulatorEvents: [ { event: "rowDblClick", handler: (e, row) => { this.actionDownload(row.getData().akte_id); } } - ]; - - return events; - } + ] + }; + }, + computed: { }, watch: { modelValue() { @@ -207,18 +196,22 @@ export default { for (let archiveData of archiveDataArr) { this.loading = true; + + // sign document depending on signierbar property let archiveFunction = this.selectedVorlage.signierbar - ? this.$fhcApi.factory.stv.archiv.archiveSigned - : this.$fhcApi.factory.stv.archiv.archive; + ? ApiStvArchiv.archiveSigned + : ApiStvArchiv.archive; - archiveFunction({ - xml: this.getXmlByXsl(this.selectedVorlage.vorlage_kurzbz), - xsl: this.selectedVorlage.vorlage_kurzbz, - ss: this.defaultSemester, - uid: archiveData.uid, - prestudent_id: archiveData.prestudent_id - }) + this.$api.call( + archiveFunction({ + xml: this.getXmlByXsl(this.selectedVorlage.vorlage_kurzbz), + xsl: this.selectedVorlage.vorlage_kurzbz, + ss: this.defaultSemester, + uid: archiveData.uid, + prestudent_id: archiveData.prestudent_id + }) + ) .then(result => result.data) .then(() => { this.reload(); @@ -249,10 +242,10 @@ export default { } }, created() { - this.$fhcApi - .factory.stv.archiv.getArchivVorlagen() - .then(result => {this.vorlagenArchiv = result.data; this.selectedVorlage = result.data.filter(o => o.vorlage_kurzbz == 'Zeugnis')[0];}) - .catch(this.$fhcAlert.handleSystemError); + this.$api + .call(ApiStvArchiv.getArchivVorlagen()) + .then(result => {this.vorlagenArchiv = result.data; this.selectedVorlage = result.data.filter(o => o.vorlage_kurzbz == 'Zeugnis')[0];}) + .catch(this.$fhcAlert.handleSystemError); }, template: ` diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Archiv/Edit.js b/public/js/components/Stv/Studentenverwaltung/Details/Archiv/Edit.js index 6e271b4d0..56929a3fc 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Archiv/Edit.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Archiv/Edit.js @@ -115,4 +115,4 @@ export default { ` -}; \ No newline at end of file +}; From b4a1720a948ad7750e275cdb3b3393fa2a4b1253 Mon Sep 17 00:00:00 2001 From: Alexei Karpenko Date: Tue, 15 Jul 2025 23:08:12 +0200 Subject: [PATCH 2/5] Studierendenverwaltung archiv: removed tabulator columns from computed --- .../components/Stv/Studentenverwaltung/Details/Archiv.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Archiv.js b/public/js/components/Stv/Studentenverwaltung/Details/Archiv.js index f9c884782..ec92539db 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Archiv.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Archiv.js @@ -63,8 +63,12 @@ export default { 'abschlussdokument_lehrgaenge.xml.php': [ 'AbschlussdokumentLehrgaenge' ] - }, - tabulatorOptions: { + } + }; + }, + computed: { + tabulatorOptions() { + const options = { ajaxURL: 'dummy', ajaxRequestFunc: () => this.$api.call( ApiStvArchiv.getArchiv( From c728f60ec5161253171c2c4fff331ae66a614c65 Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Tue, 5 Aug 2025 11:28:18 +0200 Subject: [PATCH 3/5] fix cherry picked Archiv.js --- .../Stv/Studentenverwaltung/Details/Archiv.js | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Archiv.js b/public/js/components/Stv/Studentenverwaltung/Details/Archiv.js index ec92539db..632a14088 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Archiv.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Archiv.js @@ -71,11 +71,14 @@ export default { const options = { ajaxURL: 'dummy', ajaxRequestFunc: () => this.$api.call( - ApiStvArchiv.getArchiv( - this.modelValue.person_id ? [this.modelValue.person_id] : null || this.modelValue.map(e => e.person_id) - ) - ), + ApiStvArchiv.getArchiv( + this.modelValue.person_id ? [this.modelValue.person_id] : null || this.modelValue.map(e => e.person_id) + ) + ), ajaxResponse: (url, params, response) => response.data, + layout:"fitDataTable", + index: 'akte_id', + persistenceID: 'stv-details-archiv', columns: [ {title: "Akte Id", field: "akte_id", visible: false}, {title: this.$p.t('stv', 'archiv_title'), field: "titel"}, @@ -147,8 +150,8 @@ export default { evt.stopPropagation(); this.$fhcAlert .confirmDelete() - .then(result => result ? {akte_id: cell.getData().akte_id, studiengang_kz : this.modelValue.studiengang_kz} : Promise.reject({handled:true})) - .then(params => this.$api.call(ApiStvArchiv.delete(params.akte_id, params.studiengang_kz))) + .then(result => result ? {akte_id: cell.getData().akte_id, studiengang_kz: this.modelValue.studiengang_kz} : Promise.reject({handled:true})) + .then(this.$fhcApi.factory.stv.archiv.delete) .then(() => { //cell.getRow().delete(); this.reload(); @@ -163,22 +166,22 @@ export default { maxWidth: 150, frozen: true } - ], - layout:"fitDataTable", - index: 'akte_id', - persistenceID: 'stv-details-archiv' - }, - tabulatorEvents: [ + ] + }; + return options; + }, + tabulatorEvents() { + const events = [ { event: "rowDblClick", handler: (e, row) => { this.actionDownload(row.getData().akte_id); } } - ] - }; - }, - computed: { + ]; + + return events; + } }, watch: { modelValue() { From 70274eef3a3098a69c45f1b2430cb705bb606e36 Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Tue, 5 Aug 2025 11:33:25 +0200 Subject: [PATCH 4/5] remove console.log --- public/js/api/factory/stv/archiv.js | 1 - 1 file changed, 1 deletion(-) diff --git a/public/js/api/factory/stv/archiv.js b/public/js/api/factory/stv/archiv.js index 4205a5ecc..ca8f25116 100644 --- a/public/js/api/factory/stv/archiv.js +++ b/public/js/api/factory/stv/archiv.js @@ -1,6 +1,5 @@ export default { getArchiv(person_id) { - console.log(person_id); return { method: 'get', url: 'api/frontend/v1/stv/archiv/getArchiv', From 41a46aa7b28c0aea2019732e24048fbc80ec2ac6 Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Tue, 5 Aug 2025 11:59:07 +0200 Subject: [PATCH 5/5] add component name, cssclass name, replace old delete api call with new one --- .../components/Stv/Studentenverwaltung/Details/Archiv.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Archiv.js b/public/js/components/Stv/Studentenverwaltung/Details/Archiv.js index 632a14088..3eca6d47e 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Archiv.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Archiv.js @@ -5,6 +5,7 @@ import AkteEdit from "./Archiv/Edit.js"; import ApiStvArchiv from '../../../../api/factory/stv/archiv.js'; export default { + name: 'Archiv', components: { CoreFilterCmpt, FormInput, @@ -151,7 +152,9 @@ export default { this.$fhcAlert .confirmDelete() .then(result => result ? {akte_id: cell.getData().akte_id, studiengang_kz: this.modelValue.studiengang_kz} : Promise.reject({handled:true})) - .then(this.$fhcApi.factory.stv.archiv.delete) + .then((params) => { + return this.$api.call(ApiStvArchiv.delete(params.akte_id, params.studiengang_kz)) + }) .then(() => { //cell.getRow().delete(); this.reload(); @@ -256,7 +259,7 @@ export default { }, template: ` -
+