diff --git a/application/controllers/api/frontend/v1/stv/Notiz.php b/application/controllers/api/frontend/v1/stv/Notiz.php index 3d84c2d68..426408863 100644 --- a/application/controllers/api/frontend/v1/stv/Notiz.php +++ b/application/controllers/api/frontend/v1/stv/Notiz.php @@ -4,7 +4,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); use \DateTime as DateTime; -class Notiz extends FHCAPI_Controller +class Notiz extends Notiz_Controller { public function __construct() { @@ -32,32 +32,33 @@ class Notiz extends FHCAPI_Controller ]); } - public function getUid() +/* public function getUid() { $this->terminateWithSuccess(getAuthUID()); - } + }*/ + public function getNotizen($id, $type) { + //check if valid type - $isValidType = $this->NotizzuordnungModel->isValidType($type); + $result = $this->NotizzuordnungModel->isValidType($type); + if(isError($result)) + $this->terminateWithError($result->retval, self::ERROR_TYPE_GENERAL); - if($isValidType) - { - $result = $this->NotizModel->getNotizWithDocEntries($id, $type); + //$this->terminateWithError(" after check type not valid", self::ERROR_TYPE_GENERAL); + $result = $this->NotizModel->getNotizWithDocEntries($id, $type); - if (isError($result)) { - $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); - } - return $this->terminateWithSuccess(getData($result) ?: []); - } - else - { - return $this->terminateWithError("type not valid", self::ERROR_TYPE_GENERAL); + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } + return $this->terminateWithSuccess(getData($result) ?: []); + + // return $this->terminateWithError("type not valid", self::ERROR_TYPE_GENERAL); + } - public function loadNotiz() +/* public function loadNotiz() { $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); @@ -87,96 +88,6 @@ class Notiz extends FHCAPI_Controller } } - public function addNewNotiz($id, $paramTyp = null) - { - //$this->load->model('person/Notiz_model', 'NotizModel'); - - $this->load->library('DmsLib'); - $this->load->library('form_validation'); - - $uid = getAuthUID(); - - if (isset($_POST['data'])) - { - $data = json_decode($_POST['data']); - unset($_POST['data']); - foreach ($data as $k => $v) { - $_POST[$k] = $v; - } - } - - //Form Validation - $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) - { - $this->terminateWithValidationErrors($this->form_validation->error_array()); - } - - $titel = $this->input->post('titel'); - $text = $this->input->post('text'); - $erledigt = $this->input->post('erledigt'); - $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('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); - if (isError($result)) - { - return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); - } - $notiz_id = $result->retval; - - //Speichern der Files - $dms_id_arr = []; - foreach ($_FILES as $k => $file) - { - $dms = array( - 'kategorie_kurzbz' => 'notiz', - 'version' => 0, - 'name' => $file["name"], - 'mimetype' => $file["type"], - 'insertamum' => date('c'), - 'insertvon' => $uid - ); - - //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']);*/ - if (isError($result)) - { - return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); - } - $dms_id_arr[] = $result->retval['dms_id']; - } - - //Eintrag in Notizdokument speichern - if($dms_id_arr) - { - // Loads model Notizdokument_model - $this->load->model('person/Notizdokument_model', 'NotizdokumentModel'); - foreach($dms_id_arr as $dms_id) - { - $result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id)); - if (isError($result)) - { - return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); - } - } - } - - return $this->terminateWithSuccess($result); - } public function updateNotiz() { @@ -336,12 +247,15 @@ class Notiz extends FHCAPI_Controller } } return $this->terminateWithSuccess($result); - } + }*/ - public function deleteNotiz() + +/* public function deleteNotiz() { $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); $notiz_id = $this->input->post('notiz_id'); + $type = $this->input->post('type_id'); + $id = $this->input->post('id'); //dms_id auslesen aus notizdokument wenn vorhanden $dms_id_arr = []; @@ -378,10 +292,33 @@ class Notiz extends FHCAPI_Controller } } - //delete Notiz und Notizzuordnung - $this->load->model('person/Notiz_model', 'NotizModel'); - $this->NotizModel->addJoin('public.tbl_notizzuordnung', 'notiz_id'); + //delete Notizzuordnung + if($type == "software_id") + { + // Loads extension Model + $this->load->model('extensions/FHC-Core-Softwarebereitstellung/Softwarenotizzuordnung_model', 'ExtensionnotizzuordnungModel'); + $result = $this->ExtensionnotizzuordnungModel->delete([ + 'notiz_id' => $notiz_id, + 'id' => strval($id) + ], + [ + 'type_id' => $type + ]); + } + else + { + //notizzuordnungsid! + $result = $this->NotizzuordnungModel->delete(['notiz_id' => $notiz_id, $type => $id]); + } + + + $this->load->model('person/Notiz_model', 'NotizModel'); + //$this->NotizModel->addJoin('public.tbl_notizzuordnung', 'notiz_id'); + + //TODO (erweitern um Type_id) für Extensions, damit auch Notizzuordnung gelöscht werden kann + + //Löschen von Notiz $result = $this->NotizModel->delete( array('notiz_id' => $notiz_id) ); @@ -396,9 +333,9 @@ class Notiz extends FHCAPI_Controller } return $this->terminateWithSuccess(current(getData($result))); - } + }*/ - public function loadDokumente() +/* public function loadDokumente() { $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); $notiz_id = $this->input->post('notiz_id'); @@ -420,9 +357,9 @@ class Notiz extends FHCAPI_Controller 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) +/* public function getMitarbeiter($searchString) { $this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); $result = $this->MitarbeiterModel->searchMitarbeiter($searchString); @@ -430,6 +367,18 @@ class Notiz extends FHCAPI_Controller $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); } return $this->terminateWithSuccess($result); + }*/ + + public function isBerechtigt($id, $typeId) + { + if(!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid')) + { + $result = $this->p->t('lehre','error_keineSchreibrechte'); + + return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); + } + return success("berechtigt in überschreibender Funktion"); +/* return $this->terminateWithError('keine Berechtigung bro', self::ERROR_TYPE_GENERAL);*/ } } \ No newline at end of file diff --git a/application/core/Notiz_Controller.php b/application/core/Notiz_Controller.php index 49aa9da61..51d6854b7 100644 --- a/application/core/Notiz_Controller.php +++ b/application/core/Notiz_Controller.php @@ -4,8 +4,9 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); use \DateTime as DateTime; -class Notiz_Controller extends FHCAPI_Controller +abstract class Notiz_Controller extends FHCAPI_Controller { + //public function __construct($zuordnung = 'person/Notizzuordnung_model') public function __construct() { parent::__construct([ @@ -16,12 +17,12 @@ class Notiz_Controller extends FHCAPI_Controller 'updateNotiz' => 'assistenz:r', // TODO(manu): self::PERM_LOGGED 'deleteNotiz' => ['admin:r', 'assistenz:r'], 'loadDokumente' => ['admin:r', 'assistenz:r'], - 'getMitarbeiter' => ['admin:r', 'assistenz:r'] + 'getMitarbeiter' => ['admin:r', 'assistenz:r'], + 'isBerechtigt' => ['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('VariableLib', ['uid' => getAuthUID()]); @@ -37,24 +38,47 @@ class Notiz_Controller extends FHCAPI_Controller $this->terminateWithSuccess(getAuthUID()); } - public function getNotizen($id, $type) + + //Standardfall: für extensions überschreiben: speichern der Zuordnung in eigene Extensiontabelle angeben + protected function assignNotiz($notiz_id, $id, $type) { - - //check if valid type + $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); $result = $this->NotizzuordnungModel->isValidType($type); - if(isError($result)) - $this->terminateWithError($result->retval, self::ERROR_TYPE_GENERAL); - - //$this->terminateWithError(" after check type not valid", self::ERROR_TYPE_GENERAL); - $result = $this->NotizModel->getNotizWithDocEntries($id, $type); - if (isError($result)) { $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } - return $this->terminateWithSuccess(getData($result) ?: []); + $result = $this->NotizzuordnungModel->insert(array('notiz_id' => $notiz_id, $type => $id)); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return success(getData($result)); + } - // return $this->terminateWithError("type not valid", self::ERROR_TYPE_GENERAL); + //Standardfall: für extensions überschreiben: speichern der Zuordnung in eigene Extensiontabelle angeben + protected function deleteNotizzuordnung($notiz_id, $id, $type) + { + $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); + $result = $this->NotizzuordnungModel->isValidType($type); + if (isError($result)) { + $this->terminateWithError('type not in table notizzuordnung enthalten..', self::ERROR_TYPE_GENERAL); + } + $result = $this->NotizzuordnungModel->delete(['notiz_id' => $notiz_id, $type => $id]); + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return success(getData($result)); + } + + + + //TODO(manu) abstract + protected function getNotizen($id, $type) {} + + //TODO(manu) to abstract + protected function isBerechtigt($id, $typeId){ + return $this->terminateWithError("in abstract function: define right in extension", self::ERROR_TYPE_GENERAL); } public function loadNotiz() @@ -89,8 +113,6 @@ class Notiz_Controller extends FHCAPI_Controller public function addNewNotiz($id, $paramTyp = null) { - //$this->load->model('person/Notiz_model', 'NotizModel'); - $this->load->library('DmsLib'); $this->load->library('form_validation'); @@ -122,21 +144,37 @@ class Notiz_Controller extends FHCAPI_Controller $titel = $this->input->post('titel'); $text = $this->input->post('text'); $erledigt = $this->input->post('erledigt'); - $verfasser_uid = isset($_POST['verfasser']) ? $_POST['verfasser'] : $uid; - $bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : null; + $verfasser_uid = isset($_POST['verfasser_uid']) ? $_POST['verfasser_uid'] : $uid; + $bearbeiter_uid = isset($_POST['bearbeiter_uid']) ? $_POST['bearbeiter_uid'] : null; $type = $this->input->post('typeId'); $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); + // Start DB transaction + $this->db->trans_start(); + + //Speichern der Notiz + $result = $this->NotizModel->insert(array('titel' => $titel, 'text' => $text, 'erledigt' => $erledigt, 'verfasser_uid' => $verfasser_uid, + "insertvon" => $verfasser_uid, 'start' => $start, 'ende' => $ende, 'bearbeiter_uid' => $bearbeiter_uid)); + if (isError($result)) { - $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + $this->db->trans_rollback(); + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } + $notiz_id = $result->retval; - //Speichern der Files + //Speichern der Notizzuordnung + $result = $this->assignNotiz($notiz_id, $id, $type); + + if (isError($result)) + { + $this->db->trans_rollback(); + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + + //Speichern der Dokumente $dms_id_arr = []; foreach ($_FILES as $k => $file) { @@ -155,6 +193,7 @@ class Notiz_Controller extends FHCAPI_Controller /* $result = $this->dmslib->upload($dms, $k, ['application/pdf','application/x.fhc-dms+json']);*/ if (isError($result)) { + $this->db->trans_rollback(); return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } $dms_id_arr[] = $result->retval['dms_id']; @@ -170,11 +209,12 @@ class Notiz_Controller extends FHCAPI_Controller $result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id)); if (isError($result)) { + $this->db->trans_rollback(); return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } } } - + $this->db->trans_commit(); return $this->terminateWithSuccess($result); } @@ -217,8 +257,8 @@ class Notiz_Controller extends FHCAPI_Controller $uid = getAuthUID(); $titel = $this->input->post('titel'); $text = $this->input->post('text'); - $verfasser_uid = $this->input->post('verfasser'); - $bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : $uid; + $verfasser_uid = $this->input->post('verfasser_uid'); + $bearbeiter_uid = isset($_POST['bearbeiter_uid']) ? $_POST['bearbeiter_uid'] : $uid; $erledigt = $this->input->post('erledigt'); $start = $this->input->post('start'); $ende = $this->input->post('ende'); @@ -338,14 +378,20 @@ class Notiz_Controller extends FHCAPI_Controller return $this->terminateWithSuccess($result); } - public function deleteNotiz() { + $this->load->library('DmsLib'); + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); $notiz_id = $this->input->post('notiz_id'); - $type = $this->input->post('type_id'); + $typeId = $this->input->post('type_id'); $id = $this->input->post('id'); + if(!$this->isBerechtigt($id, $typeId)) + { + $this->terminateWithError($this->p->t('ui', 'keineBerechtigung'), self::ERROR_TYPE_GENERAL); + } + //dms_id auslesen aus notizdokument wenn vorhanden $dms_id_arr = []; $this->load->model('person/Notizdokument_model', 'NotizdokumentModel'); @@ -367,13 +413,20 @@ class Notiz_Controller extends FHCAPI_Controller if($dms_id_arr) { + // Start DB transaction + $this->db->trans_start(); + + //return $this->terminateWithError("dms_id kommt: " . $notiz_id, self::ERROR_TYPE_GENERAL); $this->load->library('DmsLib'); + + foreach($dms_id_arr as $dms_id) { $result = $this->dmslib->removeAll($dms_id); if (isError($result)) { + $this->db->trans_rollback(); return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } @@ -382,30 +435,14 @@ class Notiz_Controller extends FHCAPI_Controller } //delete Notizzuordnung - if($type == "software_id") + $result = $this-> deleteNotizzuordnung($notiz_id, $id, $typeId); + if (isError($result)) { - // Loads extension Model - $this->load->model('extensions/FHC-Core-Softwarebereitstellung/Softwarenotizzuordnung_model', 'ExtensionnotizzuordnungModel'); - $result = $this->ExtensionnotizzuordnungModel->delete([ - 'notiz_id' => $notiz_id, - 'id' => strval($id) - ], - [ - 'type_id' => $type - ]); - + $this->db->trans_rollback(); + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } - else - { - //notizzuordnungsid! - $result = $this->NotizzuordnungModel->delete(['notiz_id' => $notiz_id, $type => $id]); - } - $this->load->model('person/Notiz_model', 'NotizModel'); - //$this->NotizModel->addJoin('public.tbl_notizzuordnung', 'notiz_id'); - - //TODO (erweitern um Type_id) für Extensions, damit auch Notizzuordnung gelöscht werden kann //Löschen von Notiz $result = $this->NotizModel->delete( @@ -414,6 +451,7 @@ class Notiz_Controller extends FHCAPI_Controller if (isError($result)) { + $this->db->trans_rollback(); return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL); } if(!hasData($result)) @@ -421,11 +459,16 @@ class Notiz_Controller extends FHCAPI_Controller return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL); } + $this->db->trans_rollback(); return $this->terminateWithSuccess(current(getData($result))); } public function loadDokumente() { + if(!$this->isBerechtigt('$id', '$typeId')) + { + $this->terminateWithError($this->p->t('ui', 'keineBerechtigung'), self::ERROR_TYPE_GENERAL); + } $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); $notiz_id = $this->input->post('notiz_id'); diff --git a/application/models/person/Notiz_model.php b/application/models/person/Notiz_model.php index f9cd76724..560d6c0c7 100644 --- a/application/models/person/Notiz_model.php +++ b/application/models/person/Notiz_model.php @@ -180,13 +180,29 @@ class Notiz_model extends DB_Model { $notiz_id = $result->retval; - if (isSuccess($result)) + //TODO(Manu) neue Function assign Notiz + if($type == "software_id") + { + // Loads extension Model + $this->load->model('extensions/FHC-Core-Softwarebereitstellung/Softwarenotizzuordnung_model', 'ExtensionnotizzuordnungModel'); + $result = $this->ExtensionnotizzuordnungModel->insert([ + 'notiz_id' => $notiz_id, + 'id' => $id, + 'type_id' => $type + ]); + } + else { - $notiz_id = $result->retval; $result = $this->NotizzuordnungModel->insert(array('notiz_id' => $notiz_id, $type => $id)); } + if (isError($result)) + { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + return error('Fehler Insert Zuordnungstabelle'); + } } + // Transaction complete! $this->db->trans_complete(); @@ -207,8 +223,10 @@ class Notiz_model extends DB_Model /** * Add a Notiz for a given person with DMS_id + * */ - public function addNotizForPersonWithDoc($person_id, $titel, $text, $erledigt, $verfasser_uid, $von, $bis, $dms_id = null) + //Todo(manu) deprecated? +/* public function addNotizForPersonWithDoc($person_id, $titel, $text, $erledigt, $verfasser_uid, $von, $bis, $dms_id = null) { // Loads model Notizzuordnung_model $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); @@ -228,7 +246,7 @@ class Notiz_model extends DB_Model { // Loads model Notizdokument_model $this->load->model('person/Notizdokument_model', 'NotizdokumentModel'); - //Todo(manu) change for multiple files + $result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id)); } } @@ -249,7 +267,7 @@ class Notiz_model extends DB_Model } return $result; - } + }*/ /** * gets all Notizen for a person @@ -271,32 +289,33 @@ class Notiz_model extends DB_Model */ public function getNotizWithDocEntries($id, $type) { - $qry = " - SELECT - n.*, count(dms_id) as countDoc, z.notizzuordnung_id, - TO_CHAR (CASE - 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, - 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 - public.tbl_notizzuordnung z USING (notiz_id) - LEFT JOIN - public.tbl_notiz_dokument dok USING (notiz_id) - LEFT JOIN - campus.tbl_dms_version USING (dms_id) - WHERE - z.$type = ? - GROUP BY - notiz_id, z.notizzuordnung_id - "; + $qry = " + SELECT + n.*, count(dms_id) as countDoc, z.notizzuordnung_id, + TO_CHAR (CASE + 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, + TO_CHAR(n.start::timestamp, 'DD.MM.YYYY') AS start_format, + TO_CHAR(n.ende::timestamp, 'DD.MM.YYYY') AS ende_format, + z.notiz_id, z.person_id as id, ? as type_id + + FROM + public.tbl_notiz n + JOIN + public.tbl_notizzuordnung z USING (notiz_id) + LEFT JOIN + public.tbl_notiz_dokument dok USING (notiz_id) + LEFT JOIN + campus.tbl_dms_version USING (dms_id) + WHERE + z.$type = ? + GROUP BY + notiz_id, z.notizzuordnung_id + "; - return $this->execQuery($qry, array($id)); + return $this->execQuery($qry, array($type, $id)); } diff --git a/application/models/person/Notizzuordnung_model.php b/application/models/person/Notizzuordnung_model.php index 8a6672424..b94ff3fb6 100644 --- a/application/models/person/Notizzuordnung_model.php +++ b/application/models/person/Notizzuordnung_model.php @@ -32,14 +32,17 @@ class Notizzuordnung_model extends DB_Model $validTypes[] = $t->column_name; } - if (in_array($type, $validTypes)) + //TODO(manu) param id + if (in_array($type, $validTypes) ) + //if (in_array($type, $validTypes) ||($type == 'software_id')) //Just for testing { - $result = success('Type of Id is valid'); + return success("Type " . $type . " is valid"); + // $result = success('Type of Id is valid'); } else { - $result = error('Type of Id is not valid'); + return error("Type " . $type . " is NOT valid"); } - return $result; + //return $result; } } diff --git a/public/js/components/Notiz/NotizComponent.js b/public/js/components/Notiz/NotizComponent.js index fe2ecc3e8..663376aa4 100644 --- a/public/js/components/Notiz/NotizComponent.js +++ b/public/js/components/Notiz/NotizComponent.js @@ -18,6 +18,7 @@ export default { BsModal }, props: [ + 'endpoint', 'typeId', 'id', 'notizLayout', @@ -29,16 +30,14 @@ export default { data(){ return { tabulatorOptions: { - ajaxURL: 'api/frontend/v1/stv/Notiz/getNotizen/' + this.id + '/' + this.typeId, + ajaxURL: this.endpoint + '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"; @@ -55,7 +54,6 @@ export default { title: "Text", field: "text_stripped", width: 250, - visible: true, tooltip:function(e, cell, onRendered){ var el = document.createElement("div"); el.style.backgroundColor = "white"; @@ -88,6 +86,8 @@ export default { }, {title: "Notiz_id", field: "notiz_id", width: 92, visible: false}, {title: "Notizzuordnung_id", field: "notizzuordnung_id", width: 164, visible: false}, + {title: "type_id", field: "type_id", width: 164, visible: false}, + {title: "extension_id", field: "id", width: 135, visible: false}, {title: "letzte Änderung", field: "lastupdate", width: 146, visible: false}, { title: 'Aktionen', field: 'actions', @@ -142,11 +142,11 @@ export default { }); cm.getColumnByField('titel').component.updateDefinition({ title: this.$p.t('global', 'titel'), - visible: this.showVariables.showTitel + //visible: this.showVariables.showTitel }); cm.getColumnByField('text_stripped').component.updateDefinition({ title: this.$p.t('global', 'text'), - visible: this.showVariables.showText + //visible: this.showVariables.showText }); cm.getColumnByField('bearbeiter_uid').component.updateDefinition({ title: this.$p.t('notiz', 'bearbeiter'), @@ -178,6 +178,12 @@ export default { cm.getColumnByField('notizzuordnung_id').component.updateDefinition({ visible: this.showVariables.showNotizzuordnung_id }); + cm.getColumnByField('type_id').component.updateDefinition({ + visible: this.showVariables.showType_id + }); + cm.getColumnByField('id').component.updateDefinition({ + visible: this.showVariables.showId + }); } } @@ -214,6 +220,8 @@ export default { showErledigt: false, showNotiz_id: false, showNotizzuordnung_id: false, + showType_id: false, + showId: false, showLastupdate: false }, } @@ -258,7 +266,13 @@ export default { formData.append('data', JSON.stringify(this.notizData)); Object.entries(this.notizData.anhang).forEach(([k, v]) => formData.append(k, v)); - this.$fhcApi.post('api/frontend/v1/stv/notiz/addNewNotiz/' + this.id, +/* this.formData = { + 'id': this.id, + 'typeId': this.typeId, + ...formData + };*/ + + return this.$fhcApi.post(this.endpoint + 'addNewNotiz/' + this.id, formData, {Headers: {"Content-Type": "multipart/form-data"}} ).then(response => { @@ -273,10 +287,12 @@ export default { }, deleteNotiz(notiz_id) { this.param = { - 'notiz_id': notiz_id + 'notiz_id': notiz_id, + 'type_id': this.typeId, + 'id': this.id }; - return this.$fhcApi.post('api/frontend/v1/stv/notiz/deleteNotiz/', this.param) + return this.$fhcApi.post(this.endpoint + 'deleteNotiz/', this.param) .then(result => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete')); this.$refs.deleteNotizModal.hide(); @@ -292,7 +308,7 @@ export default { this.param = { 'notiz_id': notiz_id }; - return this.$fhcApi.post('api/frontend/v1/stv/notiz/loadNotiz/', + return this.$fhcApi.post(this.endpoint + 'loadNotiz/', this.param) .then(result => { this.notizData = result.data; @@ -305,7 +321,7 @@ export default { this.param = { 'notiz_id': notiz_id }; - return this.$fhcApi.post('api/frontend/v1/stv/notiz/loadDokumente/', + return this.$fhcApi.post(this.endpoint + 'loadDokumente/', this.param) .then( result => { @@ -324,7 +340,7 @@ export default { }; return this.$fhcApi.post( - 'api/frontend/v1/stv/notiz/updateNotiz/', + this.endpoint + 'updateNotiz/', formData, {Headers: {"Content-Type": "multipart/form-data"}} ).then(response => { @@ -359,7 +375,7 @@ export default { }, getUid() { this.$fhcApi - .get('api/frontend/v1/stv/notiz/getUid') + .get(this.endpoint + 'getUid') .then(result => { this.notizData.intVerfasser = result.data; }) @@ -367,7 +383,7 @@ export default { }, search(event) { return this.$fhcApi - .get('api/frontend/v1/stv/notiz/getMitarbeiter/' + event.query) + .get(this.endpoint + 'getMitarbeiter/' + event.query) .then(result => { this.filteredMitarbeiter = result.data.retval; }); diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js b/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js index fc92ce243..f93bb19cd 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js @@ -11,14 +11,15 @@ export default {