diff --git a/application/controllers/components/stv/Notiz.php b/application/controllers/api/frontend/v1/stv/Notiz.php similarity index 59% rename from application/controllers/components/stv/Notiz.php rename to application/controllers/api/frontend/v1/stv/Notiz.php index 7b78b06f8..29a0b576e 100644 --- a/application/controllers/components/stv/Notiz.php +++ b/application/controllers/api/frontend/v1/stv/Notiz.php @@ -2,15 +2,30 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); +use \DateTime as DateTime; -class Notiz extends FHC_Controller +class Notiz extends FHCAPI_Controller { public function __construct() { - parent::__construct(); + parent::__construct([ + 'getUid' => ['admin:r', 'assistenz:r'], + 'getNotizen' => ['admin:r', 'assistenz:r'], + 'loadNotiz' => 'assistenz:r', // TODO(manu): self::PERM_LOGGED + 'addNewNotiz' => 'assistenz:r', // TODO(manu): self::PERM_LOGGED + 'updateNotiz' => 'assistenz:r', // TODO(manu): self::PERM_LOGGED + 'deleteNotiz' => ['admin:r', 'assistenz:r'], + 'loadDokumente' => ['admin:r', 'assistenz:r'], + 'getMitarbeiter' => ['admin:r', 'assistenz:r'], + 'advanceStatus' => ['admin:r', 'assistenz:r'], + 'confirmStatus' => ['admin:r', 'assistenz:r'] + ]); + + //Load Models + $this->load->model('person/Notiz_model', 'NotizModel'); + $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); // Load Libraries - $this->load->library('AuthLib'); $this->load->library('VariableLib', ['uid' => getAuthUID()]); // Load language phrases @@ -21,19 +36,11 @@ class Notiz extends FHC_Controller public function getUid() { - // Load Libraries - $this->load->library('AuthLib'); - $this->load->library('VariableLib', ['uid' => getAuthUID()]); - $result = getAuthUid(); - - $this->outputJsonError($result); + $this->terminateWithSuccess(getAuthUID()); } public function getNotizen($id, $type) { - $this->load->model('person/Notiz_model', 'NotizModel'); - $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); - //check if valid type $isValidType = $this->NotizzuordnungModel->isValidType($type); @@ -42,23 +49,23 @@ class Notiz extends FHC_Controller $result = $this->NotizModel->getNotizWithDocEntries($id, $type); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - $this->outputJson(getError($result)); - } else { - $this->outputJson(getData($result) ?: []); + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } + return $this->terminateWithSuccess(getData($result) ?: []); } else { - //Todo manu (phrases, response?) - $result = "datatype not yet implemented for notes"; - $this->outputJson(getError($result)); + return $this->terminateWithError("type not valid", self::ERROR_TYPE_GENERAL); } } - public function loadNotiz($notiz_id) + public function loadNotiz() { - $this->load->model('person/Notiz_model', 'NotizModel'); + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + + $notiz_id = $this->input->post('notiz_id'); + + //$this->load->model('person/Notiz_model', 'NotizModel'); $this->NotizModel->addJoin('public.tbl_notiz_dokument', 'notiz_id', 'LEFT'); $this->NotizModel->addSelect('*'); $this->NotizModel->addSelect("TO_CHAR(CASE WHEN public.tbl_notiz.updateamum >= public.tbl_notiz.insertamum @@ -68,23 +75,23 @@ class Notiz extends FHC_Controller $result = $this->NotizModel->loadWhere( array('notiz_id' => $notiz_id) ); - if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - $this->outputJson($result); + if (isError($result)) + { + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); } - - elseif (!hasData($result)) { - $this->outputJson($result); + elseif (!hasData($result)) + { + $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL); } else { - $this->outputJsonSuccess(current(getData($result))); + $this->terminateWithSuccess(current(getData($result))); } } public function addNewNotiz($id, $paramTyp = null) { - $this->load->model('person/Notiz_model', 'NotizModel'); + //$this->load->model('person/Notiz_model', 'NotizModel'); $this->load->library('DmsLib'); $this->load->library('form_validation'); @@ -101,12 +108,17 @@ class Notiz extends FHC_Controller } //Form Validation - $this->form_validation->set_rules('titel', 'titel', 'callback_titel_required'); - $this->form_validation->set_rules('text', 'text', 'callback_text_required'); + $this->form_validation->set_rules('titel', 'Titel', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel']) + ]); + + $this->form_validation->set_rules('text', 'Text', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text']) + ]); if ($this->form_validation->run() == false) { - return $this->outputJsonError($this->form_validation->error_array()); + $this->terminateWithValidationErrors($this->form_validation->error_array()); } $titel = $this->input->post('titel'); @@ -115,15 +127,14 @@ class Notiz extends FHC_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('von'); + $ende = $this->input->post('bis'); //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); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } $notiz_id = $result->retval; @@ -141,12 +152,12 @@ class Notiz extends FHC_Controller ); //Todo(manu) check if filetypes weiter eingeschränkt werden sollen + //Todo(manu)check name files: nicht gleiches file 2mal hochladen $result = $this->dmslib->upload($dms, $k, ['*']); -/* $result = $this->dmslib->upload($dms, $k, ['application/pdf','application/x.fhc-dms+json']);*/ + /* $result = $this->dmslib->upload($dms, $k, ['application/pdf','application/x.fhc-dms+json']);*/ if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } $dms_id_arr[] = $result->retval['dms_id']; } @@ -161,20 +172,16 @@ class Notiz extends FHC_Controller $result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id)); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } } } - return $this->outputJsonSuccess(true); + return $this->terminateWithSuccess($result); } - public function updateNotiz($notiz_id) + public function updateNotiz() { - $this->load->model('person/Notiz_model', 'NotizModel'); - $this->load->model('person/Notizdokument_model', 'NotizdokumentModel'); - $this->load->library('form_validation'); $this->load->library('DmsLib'); @@ -187,18 +194,25 @@ class Notiz extends FHC_Controller } } + $notiz_id = $this->input->post('notiz_id'); + if(!$notiz_id) { - return $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->terminateWithError($this->p->t('ui','error_missingId',['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL); } //Form Validation - $this->form_validation->set_rules('titel', 'titel', 'callback_titel_required'); - $this->form_validation->set_rules('text', 'text', 'callback_text_required'); + $this->form_validation->set_rules('titel', 'Titel', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel']) + ]); + + $this->form_validation->set_rules('text', 'Text', 'required', [ + 'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text']) + ]); if ($this->form_validation->run() == false) { - return $this->outputJsonError($this->form_validation->error_array()); + $this->terminateWithValidationErrors($this->form_validation->error_array()); } //update Notiz @@ -208,7 +222,6 @@ class Notiz extends FHC_Controller $verfasser_uid = $this->input->post('verfasser'); $bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : $uid; $erledigt = $this->input->post('erledigt'); - //$type = $this->input->post('typeId'); //soll auch dieser geändert werden können? $start = $this->input->post('von'); $ende = $this->input->post('bis'); @@ -230,8 +243,7 @@ class Notiz extends FHC_Controller ); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } //update(1) laden aller bereits mit dieser notiz_id verknüpften DMS-Einträge @@ -242,8 +254,7 @@ class Notiz extends FHC_Controller $result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id)); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - $this->outputJson(getError($result)); + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } elseif (!hasData($result)) { @@ -256,7 +267,7 @@ class Notiz extends FHC_Controller $dms_id_arr[] = array( 'name' => $doc->name, 'dms_id' => $doc->dms_id - ); + ); } } @@ -281,20 +292,19 @@ class Notiz extends FHC_Controller ); //Todo(manu) check if filetypes weiter eingeschränkt werden sollen + //Todo(manu)check name files: nicht gleiches file 2mal hochladen $result = $this->dmslib->upload($dms, $k, array('*')); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } $dms_id = $result->retval['dms_id']; $result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id)); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } } } @@ -302,11 +312,18 @@ class Notiz extends FHC_Controller //update(3) check if Dateien gelöscht wurden if(count($dms_uploaded) != count($dms_id_arr)) { - $upload_new_names = array_column($dms_uploaded, "name"); + if (count($dms_uploaded) == 0) + { + $filesDeleted = $dms_id_arr; + } + else + { + $upload_new_names = array_column($dms_uploaded, "name"); - $filesDeleted = array_filter($dms_id_arr, function ($file) use ($upload_new_names) { - return !in_array($file["name"], $upload_new_names); - }); + $filesDeleted = array_filter($dms_id_arr, function ($file) use ($upload_new_names) { + return !in_array($file["name"], $upload_new_names); + }); + } foreach ($filesDeleted as $file) { @@ -314,18 +331,20 @@ class Notiz extends FHC_Controller if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } else $this->outputJson($result); } } - return $this->outputJsonSuccess(true); + return $this->terminateWithSuccess($result); } - public function deleteNotiz($notiz_id) + public function deleteNotiz() { + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + $notiz_id = $this->input->post('notiz_id'); + //dms_id auslesen aus notizdokument wenn vorhanden $dms_id_arr = []; $this->load->model('person/Notizdokument_model', 'NotizdokumentModel'); @@ -334,17 +353,13 @@ class Notiz extends FHC_Controller if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } - elseif (!hasData($result)) - { - $this->outputJson($result); - } - else + + if(hasData($result)) { $result = getData($result); - foreach($result as $doc) { + foreach ($result as $doc) { $dms_id_arr[] = $doc->dms_id; } } @@ -358,15 +373,13 @@ class Notiz extends FHC_Controller if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson(getError($result)); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } - else - $this->outputJson($result); + + $this->outputJson($result); } } - //Todo(manu) rollback? //delete Notiz und Notizzuordnung $this->load->model('person/Notiz_model', 'NotizModel'); $this->NotizModel->addJoin('public.tbl_notizzuordnung', 'notiz_id'); @@ -377,20 +390,20 @@ class Notiz extends FHC_Controller if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - $this->outputJson($result); + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); } - elseif (!hasData($result)) { - $this->outputJson($result); + if(!hasData($result)) + { + return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL); } - return $this->outputJsonSuccess(current(getData($result))); + return $this->terminateWithSuccess(current(getData($result))); } - public function loadDokumente($notiz_id) + public function loadDokumente() { - $this->load->model('person/Notiz_model', 'NotizModel'); - + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + $notiz_id = $this->input->post('notiz_id'); $this->NotizModel->addSelect('campus.tbl_dms_version.*'); @@ -401,51 +414,23 @@ class Notiz extends FHC_Controller array('public.tbl_notiz.notiz_id' => $notiz_id) ); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - $this->outputJson($result); + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); } - elseif (!hasData($result)) { - $this->outputJson($result); - } - else + if(!hasData($result)) { - $this->outputJsonSuccess(getData($result)); + return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL); } + return $this->terminateWithSuccess(getData($result)); } public function getMitarbeiter($searchString) { - $this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); - $result = $this->MitarbeiterModel->searchMitarbeiter($searchString); if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); } - $this->outputJson($result); + return $this->terminateWithSuccess($result); } - public function titel_required($value) - { - if (empty($value)) { - $this->form_validation->set_message('titel_required', $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel'])); - return false; - } - else - { - return true; - } - } - - public function text_required($value) - { - if (empty($value)) { - $this->form_validation->set_message('text_required', $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text'])); - return false; - } - else - { - return true; - } - } -} +} \ No newline at end of file diff --git a/application/models/person/Notiz_model.php b/application/models/person/Notiz_model.php index 2822cac47..f9cd76724 100644 --- a/application/models/person/Notiz_model.php +++ b/application/models/person/Notiz_model.php @@ -271,20 +271,6 @@ class Notiz_model extends DB_Model */ public function getNotizWithDocEntries($id, $type) { - // ci query builder returns null -/* $this->db->select('n.*, count(dms_id) as countDoc, z.notizzuordnung_id'); - $this->db->select('(CASE WHEN n.updateamum >= n.insertamum THEN n.updateamum ELSE n.insertamum END) AS lastUpdate'); - $this->db->from('public.tbl_notiz n'); - $this->db->join('public.tbl_notizzuordnung z', 'n.notiz_id = z.notiz_id'); - $this->db->join('public.tbl_notiz_dokument dok', 'n.notiz_id = dok.notiz_id', 'left'); - $this->db->join('campus.tbl_dms_version', 'dok.notiz_id = campus.tbl_dms_version.dms_id', 'left'); - $this->db->where("z.$type", $id); - $this->db->group_by('n.notiz_id, z.notizzuordnung_id'); - - $query = $this->db->get(); - return $query->result();*/ - - $qry = " SELECT n.*, count(dms_id) as countDoc, z.notizzuordnung_id, @@ -292,7 +278,10 @@ class Notiz_model extends DB_Model WHEN n.updateamum >= n.insertamum THEN n.updateamum ELSE n.insertamum END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate, - regexp_replace(n.text, '<[^>]*>', '', 'g') as text_stripped + regexp_replace(n.text, '<[^>]*>', '', 'g') as text_stripped, + TO_CHAR(n.start::timestamp, 'DD.MM.YYYY') AS start_format, + TO_CHAR(n.ende::timestamp, 'DD.MM.YYYY') AS ende_format + FROM public.tbl_notiz n JOIN diff --git a/public/js/components/Notiz/NotizComponent.js b/public/js/components/Notiz/NotizComponent.js index eb8b8dd1d..3ba8615fe 100644 --- a/public/js/components/Notiz/NotizComponent.js +++ b/public/js/components/Notiz/NotizComponent.js @@ -1,7 +1,6 @@ import VueDatePicker from '../vueDatepicker.js.php'; import PvAutoComplete from "../../../../index.ci.php/public/js/components/primevue/autocomplete/autocomplete.esm.min.js"; import FormUploadDms from '../Form/Upload/Dms.js'; -import {CoreRESTClient} from "../../RESTClient"; import {CoreFilterCmpt} from "../filter/Filter.js"; import BsModal from "../Bootstrap/Modal"; @@ -24,14 +23,17 @@ export default { data(){ return { tabulatorOptions: { - ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Notiz/getNotizen/' + this.id + '/' + this.typeId), + 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", visible: false}, - {title: "Ende", field: "ende", 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}, @@ -74,7 +76,46 @@ export default { selectable: true, index: 'notiz_id' }, - tabulatorEvents: [], + 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') + }); + 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') + }); + + } + } + ], notizen: [], multiupload: true, mitarbeiter: [], @@ -101,14 +142,11 @@ export default { methods: { actionDeleteNotiz(notiz_id){ this.loadNotiz(notiz_id).then(() => { - if(this.notizen.notiz_id) { this.$refs.deleteNotizModal.show(); - } }); }, actionEditNotiz(notiz_id){ this.loadNotiz(notiz_id).then(() => { - console.log(this.notizen); if(this.notizen.notiz_id) { this.notizData.titel = this.notizen.titel; this.notizData.statusNew = false; @@ -126,10 +164,11 @@ export default { } }) .then(() => { - if(this.notizen.dms_id){ - console.log("loadEntries with " + this.notizen.notiz_id); - this.loadDocEntries(this.notizen.notiz_id); + if(this.notizData.dms_id){ + this.loadDocEntries(this.notizData.notiz_id); } + else + this.notizData.anhang = []; }); }, actionNewNotiz(){ @@ -140,103 +179,80 @@ export default { formData.append('data', JSON.stringify(this.notizData)); Object.entries(this.notizData.anhang).forEach(([k, v]) => formData.append(k, v)); - CoreRESTClient.post( - 'components/stv/Notiz/addNewNotiz/' + this.id, + this.$fhcApi.post('api/frontend/v1/stv/notiz/addNewNotiz/' + this.id, formData, { Headers: { "Content-Type": "multipart/form-data" } } ).then(response => { - if (!response.data.error) { - this.$fhcAlert.alertSuccess('Anlegen von neuer Notiz erfolgreich'); + this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); this.resetFormData(); this.reload(); - } else { - const errorData = response.data.retval; - Object.entries(errorData).forEach(entry => { - const [key, value] = entry; - this.$fhcAlert.alertError(value); - }); - } - }).catch(error => { - if (error.response) { - console.log(error.response); - this.$fhcAlert.alertError(error.response.data); - } - }).finally(() => { + }) + .catch(this.$fhcAlert.handleSystemError) + .finally(() => { window.scrollTo(0, 0); }); }, deleteNotiz(notiz_id){ - CoreRESTClient.post('components/stv/Notiz/deleteNotiz/' + notiz_id) - .then(response => { - if (!response.data.error) { - this.$fhcAlert.alertSuccess('Löschen erfolgreich'); + this.param = { + '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(); - } else { - this.$fhcAlert.alertError('Keine Notiz mit Id ' + notiz_id + ' gefunden'); - } - }).catch(error => { - this.$fhcAlert.alertError('Fehler bei Löschroutine aufgetreten'); - }).finally(()=> { + }) + .catch(this.$fhcAlert.handleSystemError) + .finally(()=> { window.scrollTo(0, 0); }); }, loadNotiz(notiz_id){ - return CoreRESTClient.get('components/stv/Notiz/loadNotiz/' + notiz_id) - .then( - result => { - if(result.data.retval) { - this.notizen = result.data.retval; - } - else { - this.notizen = {}; - this.$fhcAlert.alertError('Keine Notiz mit Id ' + notiz_id + ' gefunden'); - } + this.param = { + 'notiz_id': notiz_id + }; + return this.$fhcApi.post('api/frontend/v1/stv/notiz/loadNotiz/', + this.param) + .then(result => { + this.notizData = result.data; return result; - } - ); + }) + .catch(this.$fhcAlert.handleSystemError); }, loadDocEntries(notiz_id){ - return CoreRESTClient.get('components/stv/Notiz/loadDokumente/' + notiz_id) + this.param = { + 'notiz_id': notiz_id + }; + return this.$fhcApi.post('api/frontend/v1/stv/notiz/loadDokumente/', + this.param) .then( result => { - if(result.data.retval) { - this.notizData.anhang = result.data.retval; - console.log(this.notizData.anhang); - } - else - { - this.notizData.anhang = {}; - this.$fhcAlert.alertError('Kein Dokumenteneintrag mit NotizId ' + notiz_id + ' gefunden'); - } + this.notizData.anhang = result.data; return result; - } - ); + }) + .catch(this.$fhcAlert.handleSystemError); }, 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)); - CoreRESTClient.post( - 'components/stv/Notiz/updateNotiz/' + notiz_id, + this.param = { + 'notiz_id': notiz_id + }; + + return this.$fhcApi.post( + 'api/frontend/v1/stv/notiz/updateNotiz/' , formData, { Headers: { "Content-Type": "multipart/form-data" } } ).then(response => { - if (!response.data.error) { - this.$fhcAlert.alertSuccess('Update von Notiz erfolgreich'); + this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); this.resetFormData(); this.reload(); - } else { - const errorData = response.data.retval; - Object.entries(errorData).forEach(entry => { - const [key, value] = entry; - this.$fhcAlert.alertError(value); - }); - } - }).catch(error => { - this.$fhcAlert.alertError('Fehler bei Updateroutine aufgetreten'); - }).finally(() => { + }) + .catch(this.$fhcAlert.handleSystemError) + .finally(() => { window.scrollTo(0, 0); }); }, @@ -261,20 +277,18 @@ export default { }; }, getUid(){ - CoreRESTClient - .get('components/stv/Notiz/getUid') + this.$fhcApi + .get('api/frontend/v1/stv/notiz/getUid') .then(result => { - if(result.data.retval) { - this.notizData.intVerfasser = result.data.retval; - } + this.notizData.intVerfasser = result.data; }) .catch(this.$fhcAlert.handleSystemError); }, search(event) { - return CoreRESTClient - .get('components/stv/Notiz/getMitarbeiter/' + event.query) + return this.$fhcApi + .get('api/frontend/v1/stv/notiz/getMitarbeiter/' + event.query) .then(result => { - this.filteredMitarbeiter = CoreRESTClient.getData(result.data); + this.filteredMitarbeiter = result.data.retval; }); }, initTinyMCE() { @@ -319,38 +333,6 @@ export default { if(this.showTinyMCE){ this.initTinyMCE(); } - - 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') - }); - 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').component.updateDefinition({ - title: this.$p.t('global', 'gueltigVon') - }); - cm.getColumnByField('ende').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') - }); }, watch: { //watcher für Tinymce-Textfeld @@ -398,7 +380,7 @@ export default { @@ -410,7 +392,7 @@ export default { :side-menu="false" reload new-btn-show - new-btn-label="Neu" + new-btn-label="Notiz" @click:new="actionNewNotiz" > @@ -534,7 +516,7 @@ export default { - + `