diff --git a/application/controllers/api/frontend/v1/stv/Notiz.php b/application/controllers/api/frontend/v1/stv/Notiz.php index 29a0b576e..cf46f79a6 100644 --- a/application/controllers/api/frontend/v1/stv/Notiz.php +++ b/application/controllers/api/frontend/v1/stv/Notiz.php @@ -127,8 +127,8 @@ class Notiz extends FHCAPI_Controller $verfasser_uid = isset($_POST['verfasser']) ? $_POST['verfasser'] : $uid; $bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : null; $type = $this->input->post('typeId'); - $start = $this->input->post('von'); - $ende = $this->input->post('bis'); + $start = $this->input->post('start'); + $ende = $this->input->post('ende'); //Speichern der Notiz und Notizzuordnung inkl Prüfung ob valid type $result = $this->NotizModel->addNotizForType($type, $id, $titel, $text, $uid, $start, $ende, $erledigt, $verfasser_uid, $bearbeiter_uid); @@ -222,8 +222,8 @@ class Notiz extends FHCAPI_Controller $verfasser_uid = $this->input->post('verfasser'); $bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : $uid; $erledigt = $this->input->post('erledigt'); - $start = $this->input->post('von'); - $ende = $this->input->post('bis'); + $start = $this->input->post('start'); + $ende = $this->input->post('ende'); $result = $this->NotizModel->update( [ @@ -426,6 +426,7 @@ class Notiz extends FHCAPI_Controller public function getMitarbeiter($searchString) { + $this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); $result = $this->MitarbeiterModel->searchMitarbeiter($searchString); if (isError($result)) { $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); diff --git a/public/js/components/Form/Upload/Dms.js b/public/js/components/Form/Upload/Dms.js index c531065ff..6ad69848c 100644 --- a/public/js/components/Form/Upload/Dms.js +++ b/public/js/components/Form/Upload/Dms.js @@ -53,8 +53,14 @@ export default { }, watch: { modelValue(n) { - if (n instanceof FileList) + if (!n) + return; + if (n instanceof FileList) { + if (!this.$refs.upload) { + return; + } return this.$refs.upload.files = n; + } const dt = new DataTransfer(); const dms = []; diff --git a/public/js/components/Notiz/NotizComponent.js b/public/js/components/Notiz/NotizComponent.js index 3ba8615fe..fe2ecc3e8 100644 --- a/public/js/components/Notiz/NotizComponent.js +++ b/public/js/components/Notiz/NotizComponent.js @@ -3,6 +3,8 @@ import PvAutoComplete from "../../../../index.ci.php/public/js/components/primev import FormUploadDms from '../Form/Upload/Dms.js'; import {CoreFilterCmpt} from "../filter/Filter.js"; import BsModal from "../Bootstrap/Modal"; +import FormForm from '../Form/Form.js'; +import FormInput from '../Form/Input.js'; export default { @@ -11,148 +13,226 @@ export default { VueDatePicker, PvAutoComplete, FormUploadDms, + FormForm, + FormInput, BsModal }, props: [ 'typeId', 'id', + 'notizLayout', 'showErweitert', 'showDocument', - 'showTinyMCE' + 'showTinyMCE', + 'visibleColumns' ], data(){ - return { - tabulatorOptions: { - ajaxURL: 'api/frontend/v1/stv/Notiz/getNotizen/' + this.id + '/' + this.typeId, - ajaxRequestFunc: this.$fhcApi.get, - ajaxResponse: (url, params, response) => response.data, - //ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Notiz/getNotizen/' + this.id + '/' + this.typeId), - columns: [ - {title: "Titel", field: "titel"}, - {title: "Text", field: "text_stripped", width: 250}, - {title: "VerfasserIn", field: "verfasser_uid"}, - {title: "BearbeiterIn", field: "bearbeiter_uid", visible: false}, - {title: "Start", field: "start_format", visible: false}, - {title: "Ende", field: "ende_format", visible: false}, - {title: "Dokumente", field: "countdoc"}, - {title: "Erledigt", field: "erledigt", visible: false}, - {title: "Notiz_id", field: "notiz_id", visible: false}, - {title: "Notizzuordnung_id", field: "notizzuordnung_id", visible: false}, - {title: "letzte Änderung", field: "lastupdate", visible: false}, - {title: 'Aktionen', field: 'actions', - minWidth: 150, // Ensures Action-buttons will be always fully displayed - formatter: (cell, formatterParams, onRendered) => { - let container = document.createElement('div'); - container.className = "d-flex gap-2"; + return { + tabulatorOptions: { + ajaxURL: 'api/frontend/v1/stv/Notiz/getNotizen/' + this.id + '/' + this.typeId, + ajaxRequestFunc: this.$fhcApi.get, + ajaxResponse: (url, params, response) => response.data, + //ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Notiz/getNotizen/' + this.id + '/' + this.typeId), + columns: [ + { + title: "Titel", + field: "titel", + width: 100, + visible: true, + tooltip:function(e, cell, onRendered){ + var el = document.createElement("div"); + el.style.backgroundColor = "white"; + el.style.fontWeight = "bold"; + el.style.padding = "5px"; + el.style.border = "1px solid black"; - let button = document.createElement('button'); - button.className = 'btn btn-outline-secondary btn-action'; - button.innerHTML = ''; - button.addEventListener( - 'click', - (event) => - this.actionEditNotiz(cell.getData().notiz_id) - ); - container.append(button); + el.innerText = cell.getColumn().getField() + " - " + cell.getValue(); - button = document.createElement('button'); - button.className = 'btn btn-outline-secondary btn-action'; - button.innerHTML = ''; - button.addEventListener( - 'click', - () => - this.actionDeleteNotiz(cell.getData().notiz_id) - ); - container.append(button); - - return container; + return el; + }, }, - frozen: true - }], - layout: 'fitColumns', - layoutColumnsOnNewData: false, - height: '150', - selectableRangeMode: 'click', - selectable: true, - index: 'notiz_id' - }, - tabulatorEvents: [ - { - event: 'tableBuilt', - handler: async() => { + { + title: "Text", + field: "text_stripped", + width: 250, + visible: true, + tooltip:function(e, cell, onRendered){ + var el = document.createElement("div"); + el.style.backgroundColor = "white"; + el.style.fontWeight = "bold"; + el.style.padding = "5px"; + el.style.border = "1px solid black"; + el.style.borderRadius = "5px"; - await this.$p.loadCategory(['notiz','global']); + el.innerText = cell.getValue(); - let cm = this.$refs.table.tabulator.columnManager; + return el; + }, + }, + {title: "VerfasserIn", field: "verfasser_uid", width: 124, visible: false}, + {title: "BearbeiterIn", field: "bearbeiter_uid", width: 126, visible: false}, + {title: "Start", field: "start_format", width: 86, visible: false}, + {title: "Ende", field: "ende_format", width: 86, visible: false}, + {title: "Dokumente", field: "countdoc", width: 100, visible: false}, + { + title: "Erledigt", + field: "erledigt", + width: 97, + visible: false, + formatter:"tickCross", + hozAlign:"center", + formatterParams: { + tickElement: '', + crossElement: '' + } + }, + {title: "Notiz_id", field: "notiz_id", width: 92, visible: false}, + {title: "Notizzuordnung_id", field: "notizzuordnung_id", width: 164, visible: false}, + {title: "letzte Änderung", field: "lastupdate", width: 146, visible: false}, + { + title: 'Aktionen', field: 'actions', + width: 100, + formatter: (cell, formatterParams, onRendered) => { + let container = document.createElement('div'); + container.className = "d-flex gap-2"; - cm.getColumnByField('verfasser_uid').component.updateDefinition({ - title: this.$p.t('notiz', 'verfasser') - }); - cm.getColumnByField('titel').component.updateDefinition({ - title: this.$p.t('global', 'titel') - }); - cm.getColumnByField('text_stripped').component.updateDefinition({ - title: this.$p.t('global', 'text') - }); - cm.getColumnByField('bearbeiter_uid').component.updateDefinition({ - title: this.$p.t('notiz', 'bearbeiter') - }); - cm.getColumnByField('start_format').component.updateDefinition({ - title: this.$p.t('global', 'gueltigVon') - }); - cm.getColumnByField('ende_format').component.updateDefinition({ - title: this.$p.t('global', 'gueltigBis') - }); - cm.getColumnByField('countdoc').component.updateDefinition({ - title: this.$p.t('notiz', 'document') - }); - cm.getColumnByField('erledigt').component.updateDefinition({ - title: this.$p.t('notiz', 'erledigt') - }); - cm.getColumnByField('lastupdate').component.updateDefinition({ - title: this.$p.t('notiz', 'letzte_aenderung') - }); + let button = document.createElement('button'); + button.className = 'btn btn-outline-secondary btn-action'; + button.innerHTML = ''; + button.addEventListener( + 'click', + (event) => + this.actionEditNotiz(cell.getData().notiz_id) + ); + container.append(button); + button = document.createElement('button'); + button.className = 'btn btn-outline-secondary btn-action'; + button.innerHTML = ''; + button.addEventListener( + 'click', + () => + this.actionDeleteNotiz(cell.getData().notiz_id) + ); + container.append(button); + + return container; + }, + frozen: true + }], + layout: 'fitColumns', + layoutColumnsOnNewData: false, + height: '250', + selectableRangeMode: 'click', + selectable: true, + index: 'notiz_id' + }, + tabulatorEvents: [ + { + event: 'tableBuilt', + handler: async () => { + + await this.$p.loadCategory(['notiz', 'global']); + + let cm = this.$refs.table.tabulator.columnManager; + + cm.getColumnByField('verfasser_uid').component.updateDefinition({ + title: this.$p.t('notiz', 'verfasser'), + visible: this.showVariables.showVerfasser + }); + cm.getColumnByField('titel').component.updateDefinition({ + title: this.$p.t('global', 'titel'), + visible: this.showVariables.showTitel + }); + cm.getColumnByField('text_stripped').component.updateDefinition({ + title: this.$p.t('global', 'text'), + visible: this.showVariables.showText + }); + cm.getColumnByField('bearbeiter_uid').component.updateDefinition({ + title: this.$p.t('notiz', 'bearbeiter'), + visible: this.showVariables.showBearbeiter + }); + cm.getColumnByField('start_format').component.updateDefinition({ + title: this.$p.t('global', 'gueltigVon'), + visible: this.showVariables.showVon + }); + cm.getColumnByField('ende_format').component.updateDefinition({ + title: this.$p.t('global', 'gueltigBis'), + visible: this.showVariables.showBis + }); + cm.getColumnByField('countdoc').component.updateDefinition({ + title: this.$p.t('notiz', 'document'), + visible: this.showVariables.showDokumente + }); + cm.getColumnByField('erledigt').component.updateDefinition({ + title: this.$p.t('notiz', 'erledigt'), + visible: this.showVariables.showErledigt + }); + cm.getColumnByField('lastupdate').component.updateDefinition({ + title: this.$p.t('notiz', 'letzte_aenderung'), + visible: this.showVariables.showLastupdate + }); + cm.getColumnByField('notiz_id').component.updateDefinition({ + visible: this.showVariables.showNotiz_id + }); + cm.getColumnByField('notizzuordnung_id').component.updateDefinition({ + visible: this.showVariables.showNotizzuordnung_id + }); + + } } - } - ], - notizen: [], - multiupload: true, - mitarbeiter: [], - filteredMitarbeiter: [], - zwischenvar: '', - editorInitialized: false, - editor: null, - notizData: { - typeId: this.typeId, - titel: null, - statusNew: true, - text: null, - lastChange: null, - von: null, - bis: null, - document: null, - erledigt: false, - verfasser: null, - bearbeiter: null, - anhang: [] - }, - }; + ], + notizen: [], + multiupload: true, + mitarbeiter: [], + filteredMitarbeiter: [], + zwischenvar: '', + editorInitialized: false, + editor: null, + notizData: { + typeId: this.typeId, + titel: null, + statusNew: true, + text: null, + lastUpdate: null, + von: null, + bis: null, + document: null, + erledigt: false, + verfasser: null, + bearbeiter: null, + anhang: [] + }, + showVariables: { + showTitel: false, + showText: false, + showVerfasser: false, + showBearbeiter: false, + showVon: false, + showBis: false, + showDokumente: false, + showErledigt: false, + showNotiz_id: false, + showNotizzuordnung_id: false, + showLastupdate: false + }, + } }, methods: { - actionDeleteNotiz(notiz_id){ + actionDeleteNotiz(notiz_id) { this.loadNotiz(notiz_id).then(() => { - this.$refs.deleteNotizModal.show(); + this.$refs.deleteNotizModal.show(); }); }, - actionEditNotiz(notiz_id){ + actionEditNotiz(notiz_id) { this.loadNotiz(notiz_id).then(() => { - if(this.notizen.notiz_id) { + if (this.notizen.notiz_id) { + this.notizData.typeId = this.typeId; this.notizData.titel = this.notizen.titel; this.notizData.statusNew = false; this.notizData.text = this.notizen.text; this.notizData.intText = this.notizen.text; - this.notizData.lastChange = this.notizen.lastupdate; + this.notizData.lastupdate = this.notizen.lastupdate; this.notizData.von = this.notizen.start; this.notizData.bis = this.notizen.ende; this.notizData.document = this.notizen.dms_id; @@ -164,14 +244,13 @@ export default { } }) .then(() => { - if(this.notizData.dms_id){ + if (this.notizData.dms_id) { this.loadDocEntries(this.notizData.notiz_id); - } - else + } else this.notizData.anhang = []; }); }, - actionNewNotiz(){ + actionNewNotiz() { this.resetFormData(); }, addNewNotiz() { @@ -181,82 +260,84 @@ export default { Object.entries(this.notizData.anhang).forEach(([k, v]) => formData.append(k, v)); this.$fhcApi.post('api/frontend/v1/stv/notiz/addNewNotiz/' + this.id, formData, - { Headers: { "Content-Type": "multipart/form-data" } } + {Headers: {"Content-Type": "multipart/form-data"}} ).then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); - this.resetFormData(); - this.reload(); + this.resetFormData(); + this.reload(); }) .catch(this.$fhcAlert.handleSystemError) .finally(() => { - window.scrollTo(0, 0); - }); + window.scrollTo(0, 0); + }); }, - deleteNotiz(notiz_id){ + deleteNotiz(notiz_id) { this.param = { - 'notiz_id': notiz_id + 'notiz_id': notiz_id }; return this.$fhcApi.post('api/frontend/v1/stv/notiz/deleteNotiz/', this.param) .then(result => { - this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete')); - this.$refs.deleteNotizModal.hide(); - this.reload(); + this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete')); + this.$refs.deleteNotizModal.hide(); + this.reload(); + this.resetFormData(); }) .catch(this.$fhcAlert.handleSystemError) - .finally(()=> { + .finally(() => { window.scrollTo(0, 0); }); }, - loadNotiz(notiz_id){ + loadNotiz(notiz_id) { this.param = { - 'notiz_id': notiz_id + 'notiz_id': notiz_id }; return this.$fhcApi.post('api/frontend/v1/stv/notiz/loadNotiz/', this.param) - .then(result => { - this.notizData = result.data; - return result; - }) + .then(result => { + this.notizData = result.data; + this.notizData.typeId = this.typeId; + return result; + }) .catch(this.$fhcAlert.handleSystemError); }, - loadDocEntries(notiz_id){ + loadDocEntries(notiz_id) { this.param = { - 'notiz_id': notiz_id + 'notiz_id': notiz_id }; return this.$fhcApi.post('api/frontend/v1/stv/notiz/loadDokumente/', this.param) .then( result => { - this.notizData.anhang = result.data; + this.notizData.anhang = result.data; return result; }) .catch(this.$fhcAlert.handleSystemError); }, - updateNotiz(notiz_id){ + updateNotiz(notiz_id) { const formData = new FormData(); formData.append('data', JSON.stringify(this.notizData)); Object.entries(this.notizData.anhang).forEach(([k, v]) => formData.append(k, v)); this.param = { - 'notiz_id': notiz_id + 'notiz_id': notiz_id }; return this.$fhcApi.post( - 'api/frontend/v1/stv/notiz/updateNotiz/' , + 'api/frontend/v1/stv/notiz/updateNotiz/', formData, - { Headers: { "Content-Type": "multipart/form-data" } } + {Headers: {"Content-Type": "multipart/form-data"}} ).then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); - this.resetFormData(); - this.reload(); + this.resetFormData(); + this.reload(); }) - .catch(this.$fhcAlert.handleSystemError) - .finally(() => { - window.scrollTo(0, 0); - }); + .catch(this.$fhcAlert.handleSystemError) + .finally(() => { + window.scrollTo(0, 0); + }); }, - reload(){ + reload() { this.$refs.table.reloadTable(); }, resetFormData() { @@ -266,7 +347,7 @@ export default { titel: null, statusNew: true, text: null, - lastChange: null, + lastUpdate: null, von: null, bis: null, document: null, @@ -276,11 +357,11 @@ export default { anhang: [] }; }, - getUid(){ + getUid() { this.$fhcApi .get('api/frontend/v1/stv/notiz/getUid') .then(result => { - this.notizData.intVerfasser = result.data; + this.notizData.intVerfasser = result.data; }) .catch(this.$fhcAlert.handleSystemError); }, @@ -301,14 +382,14 @@ export default { //toolbar: " blocks | bold italic underline | alignleft aligncenter alignright alignjustify", toolbar: 'styleselect | bold italic underline | alignleft aligncenter alignright alignjustify', style_formats: [ - { title: 'Blocks', block: 'div' }, - { title: 'Paragraph', block: 'p' }, - { title: 'Heading 1', block: 'h1' }, - { title: 'Heading 2', block: 'h2' }, - { title: 'Heading 3', block: 'h3' }, - { title: 'Heading 4', block: 'h4' }, - { title: 'Heading 5', block: 'h5' }, - { title: 'Heading 6', block: 'h6' }, + {title: 'Blocks', block: 'div'}, + {title: 'Paragraph', block: 'p'}, + {title: 'Heading 1', block: 'h1'}, + {title: 'Heading 2', block: 'h2'}, + {title: 'Heading 3', block: 'h3'}, + {title: 'Heading 4', block: 'h4'}, + {title: 'Heading 5', block: 'h5'}, + {title: 'Heading 6', block: 'h6'}, ], autoresize_bottom_margin: 16, @@ -324,9 +405,16 @@ export default { }, updateText(value) { this.notizData.text = value; - } + }, + initializeShowVariables() { + this.visibleColumns.forEach(column => { + const columnToShow = "show" + column.charAt(0).toUpperCase() + column.slice(1); + this.showVariables[columnToShow] = true; + }); + }, }, created(){ + this.initializeShowVariables(); this.getUid(); }, async mounted() { @@ -370,9 +458,9 @@ export default { } }, template: ` -
- +
+