mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-18 23:42:17 +00:00
Notizcomponent: using factories as endpoint
This commit is contained in:
@@ -0,0 +1,384 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
class Notiz extends Notiz_Controller
|
||||
{
|
||||
public function __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']
|
||||
]);
|
||||
|
||||
//Load Models
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui'
|
||||
]);
|
||||
}
|
||||
|
||||
/* public function getUid()
|
||||
{
|
||||
$this->terminateWithSuccess(getAuthUID());
|
||||
}*/
|
||||
|
||||
|
||||
public function getNotizen($id, $type)
|
||||
{
|
||||
|
||||
//check if valid type
|
||||
$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) ?: []);
|
||||
|
||||
// return $this->terminateWithError("type not valid", self::ERROR_TYPE_GENERAL);
|
||||
|
||||
}
|
||||
|
||||
/* public function loadNotiz()
|
||||
{
|
||||
$_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
|
||||
THEN public.tbl_notiz.updateamum ELSE public.tbl_notiz.insertamum END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate");
|
||||
$this->NotizModel->addLimit(1);
|
||||
|
||||
$result = $this->NotizModel->loadWhere(
|
||||
array('notiz_id' => $notiz_id)
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
elseif (!hasData($result))
|
||||
{
|
||||
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->terminateWithSuccess(current(getData($result)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function updateNotiz()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$this->load->library('DmsLib');
|
||||
|
||||
if (isset($_POST['data']))
|
||||
{
|
||||
$data = json_decode($_POST['data']);
|
||||
unset($_POST['data']);
|
||||
foreach ($data as $k => $v) {
|
||||
$_POST[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$notiz_id = $this->input->post('notiz_id');
|
||||
|
||||
if(!$notiz_id)
|
||||
{
|
||||
$this->terminateWithError($this->p->t('ui','error_missingId',['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
//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());
|
||||
}
|
||||
|
||||
//update Notiz
|
||||
$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;
|
||||
$erledigt = $this->input->post('erledigt');
|
||||
$start = $this->input->post('start');
|
||||
$ende = $this->input->post('ende');
|
||||
|
||||
$result = $this->NotizModel->update(
|
||||
[
|
||||
'notiz_id' => $notiz_id
|
||||
],
|
||||
[
|
||||
'titel' => $titel,
|
||||
'updatevon' => $uid,
|
||||
'updateamum' => date('c'),
|
||||
'text' => $text,
|
||||
'verfasser_uid' => $verfasser_uid,
|
||||
'bearbeiter_uid' => $bearbeiter_uid,
|
||||
'start' => $start,
|
||||
'ende' => $ende,
|
||||
'erledigt' => $erledigt
|
||||
]
|
||||
);
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
//update(1) laden aller bereits mit dieser notiz_id verknüpften DMS-Einträge
|
||||
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
|
||||
$this->NotizdokumentModel->addJoin('campus.tbl_dms_version', 'dms_id');
|
||||
$dms_uploaded = null;
|
||||
|
||||
$result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id));
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
elseif (!hasData($result))
|
||||
{
|
||||
$dms_id_arr = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = getData($result);
|
||||
foreach($result as $doc) {
|
||||
$dms_id_arr[] = array(
|
||||
'name' => $doc->name,
|
||||
'dms_id' => $doc->dms_id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($_FILES as $k => $file)
|
||||
{
|
||||
//update(2) alle neuen files (alle außer type application/x.fhc-dms+json) anhängen
|
||||
if($file["type"] == 'application/x.fhc-dms+json')
|
||||
{
|
||||
$dms_uploaded[] = array(
|
||||
'name' => $file["name"]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$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, array('*'));
|
||||
|
||||
if (isError($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))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//update(3) check if Dateien gelöscht wurden
|
||||
if(count($dms_uploaded) != count($dms_id_arr))
|
||||
{
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
foreach ($filesDeleted as $file)
|
||||
{
|
||||
$result = $this->dmslib->removeAll($file['dms_id']);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
else
|
||||
$this->outputJson($result);
|
||||
}
|
||||
}
|
||||
return $this->terminateWithSuccess($result);
|
||||
}*/
|
||||
|
||||
|
||||
/* 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 = [];
|
||||
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
|
||||
|
||||
$result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id));
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
if(hasData($result))
|
||||
{
|
||||
$result = getData($result);
|
||||
foreach ($result as $doc) {
|
||||
$dms_id_arr[] = $doc->dms_id;
|
||||
}
|
||||
}
|
||||
|
||||
if($dms_id_arr)
|
||||
{
|
||||
$this->load->library('DmsLib');
|
||||
foreach($dms_id_arr as $dms_id)
|
||||
{
|
||||
$result = $this->dmslib->removeAll($dms_id);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$this->outputJson($result);
|
||||
}
|
||||
}
|
||||
|
||||
//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)
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if(!hasData($result))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
return $this->terminateWithSuccess(current(getData($result)));
|
||||
}*/
|
||||
|
||||
/* public function loadDokumente()
|
||||
{
|
||||
$_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.*');
|
||||
|
||||
$this->NotizModel->addJoin('public.tbl_notiz_dokument', 'ON (public.tbl_notiz_dokument.notiz_id = public.tbl_notiz.notiz_id)');
|
||||
$this->NotizModel->addJoin('campus.tbl_dms_version', 'ON (public.tbl_notiz_dokument.dms_id = campus.tbl_dms_version.dms_id)');
|
||||
|
||||
$result = $this->NotizModel->loadWhere(
|
||||
array('public.tbl_notiz.notiz_id' => $notiz_id)
|
||||
);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
if(!hasData($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->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);*/
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import navigation from "./navigation.js";
|
||||
import filter from "./filter.js";
|
||||
import studstatus from "./studstatus.js";
|
||||
import stv from "./stv.js";
|
||||
import notiz from "./notiz.js";
|
||||
|
||||
export default {
|
||||
search,
|
||||
@@ -28,5 +29,6 @@ export default {
|
||||
navigation,
|
||||
filter,
|
||||
studstatus,
|
||||
stv
|
||||
stv,
|
||||
notiz
|
||||
};
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
//TODO(Manu) refactor with require or async
|
||||
//sonst Error wenn extension file nicht vorhanden
|
||||
|
||||
import person from "./notiz/person.js";
|
||||
import softwarenotiz from "../../extensions/FHC-Core-Softwarebereitstellung/js/api/softwarenotiz.js";
|
||||
//import pppnotiz from "../../extensions/FHC-Core-PEP/js/api/pppnotiz.js";
|
||||
|
||||
|
||||
export default {
|
||||
person,
|
||||
softwarenotiz,
|
||||
// pppnotiz
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
export default {
|
||||
getNotizen(url, config, params){
|
||||
return this.$fhcApi.get('api/frontend/v1/notiz/notiz/getNotizen/' + params.id + '/' + params.type);
|
||||
},
|
||||
getUid(){
|
||||
return this.$fhcApi.get('api/frontend/v1/notiz/notiz/getUid/');
|
||||
},
|
||||
addNewNotiz(id, formData) {
|
||||
return this.$fhcApi.post('api/frontend/v1/notiz/notiz/addNewNotiz/' + id,
|
||||
formData
|
||||
);
|
||||
},
|
||||
loadNotiz(notiz_id){
|
||||
return this.$fhcApi.post('api/frontend/v1/notiz/notiz/loadNotiz/', {
|
||||
notiz_id
|
||||
});
|
||||
},
|
||||
loadDokumente(notiz_id){
|
||||
return this.$fhcApi.post('api/frontend/v1/notiz/notiz/loadDokumente/', {
|
||||
notiz_id
|
||||
});
|
||||
},
|
||||
deleteNotiz(notiz_id, type_id, id){
|
||||
return this.$fhcApi.post('api/frontend/v1/notiz/notiz/deleteNotiz/', {
|
||||
notiz_id,
|
||||
type_id,
|
||||
id
|
||||
});
|
||||
},
|
||||
updateNotiz(notiz_id, formData){
|
||||
return this.$fhcApi.post('api/frontend/v1/notiz/notiz/updateNotiz/' + notiz_id,
|
||||
formData
|
||||
);
|
||||
},
|
||||
getMitarbeiter(event){
|
||||
return this.$fhcApi.get('api/frontend/v1/notiz/notiz/getMitarbeiter/' + event);
|
||||
}
|
||||
}
|
||||
@@ -26,209 +26,213 @@ export default {
|
||||
'showDocument',
|
||||
'showTinyMCE',
|
||||
'visibleColumns'
|
||||
],
|
||||
],
|
||||
data(){
|
||||
return {
|
||||
tabulatorOptions: {
|
||||
ajaxURL: this.endpoint + 'getNotizen/' + this.id + '/' + this.typeId,
|
||||
ajaxRequestFunc: this.$fhcApi.get,
|
||||
ajaxResponse: (url, params, response) => response.data,
|
||||
columns: [
|
||||
{
|
||||
title: "Titel",
|
||||
field: "titel",
|
||||
width: 100,
|
||||
tooltip:function(e, cell, onRendered){
|
||||
var el = document.createElement("div");
|
||||
el.style.backgroundColor = "white";
|
||||
el.style.color = "black";
|
||||
el.style.fontWeight = "bold";
|
||||
el.style.padding = "5px";
|
||||
el.style.border = "1px solid black";
|
||||
el.style.borderRadius = "5px";
|
||||
|
||||
el.innerText = cell.getValue();
|
||||
|
||||
el.innerText = cell.getColumn().getField() + " - " + cell.getValue();
|
||||
|
||||
return el;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Text",
|
||||
field: "text_stripped",
|
||||
width: 250,
|
||||
tooltip:function(e, cell, onRendered){
|
||||
var el = document.createElement("div");
|
||||
el.style.backgroundColor = "white";
|
||||
el.style.color = "black";
|
||||
el.style.fontWeight = "bold";
|
||||
el.style.padding = "5px";
|
||||
el.style.border = "1px solid black";
|
||||
el.style.borderRadius = "5px";
|
||||
|
||||
el.innerText = cell.getValue();
|
||||
|
||||
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: '<i class="fa fa-check text-success"></i>',
|
||||
crossElement: '<i class="fa fa-xmark text-danger"></i>'
|
||||
}
|
||||
},
|
||||
{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',
|
||||
width: 100,
|
||||
formatter: (cell, formatterParams, onRendered) => {
|
||||
let container = document.createElement('div');
|
||||
container.className = "d-flex gap-2";
|
||||
|
||||
let button = document.createElement('button');
|
||||
button.className = 'btn btn-outline-secondary btn-action';
|
||||
button.innerHTML = '<i class="fa fa-edit"></i>';
|
||||
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 = '<i class="fa fa-xmark"></i>';
|
||||
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'
|
||||
return {
|
||||
tabulatorOptions: {
|
||||
ajaxURL: 'dummy',
|
||||
ajaxRequestFunc: this.endpoint.getNotizen,
|
||||
ajaxParams: {
|
||||
id: this.id,
|
||||
type: this.typeId
|
||||
},
|
||||
tabulatorEvents: [
|
||||
ajaxResponse: (url, params, response) => response.data,
|
||||
columns: [
|
||||
{
|
||||
event: 'tableBuilt',
|
||||
handler: async () => {
|
||||
title: "Titel",
|
||||
field: "titel",
|
||||
width: 100,
|
||||
tooltip:function(e, cell, onRendered){
|
||||
var el = document.createElement("div");
|
||||
el.style.backgroundColor = "white";
|
||||
el.style.color = "black";
|
||||
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;
|
||||
el.innerText = cell.getColumn().getField() + " - " + cell.getValue();
|
||||
|
||||
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
|
||||
});
|
||||
cm.getColumnByField('type_id').component.updateDefinition({
|
||||
visible: this.showVariables.showType_id
|
||||
});
|
||||
cm.getColumnByField('id').component.updateDefinition({
|
||||
visible: this.showVariables.showId
|
||||
});
|
||||
return el;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Text",
|
||||
field: "text_stripped",
|
||||
width: 250,
|
||||
tooltip:function(e, cell, onRendered){
|
||||
var el = document.createElement("div");
|
||||
el.style.backgroundColor = "white";
|
||||
el.style.color = "black";
|
||||
el.style.fontWeight = "bold";
|
||||
el.style.padding = "5px";
|
||||
el.style.border = "1px solid black";
|
||||
el.style.borderRadius = "5px";
|
||||
|
||||
el.innerText = cell.getValue();
|
||||
|
||||
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: '<i class="fa fa-check text-success"></i>',
|
||||
crossElement: '<i class="fa fa-xmark text-danger"></i>'
|
||||
}
|
||||
},
|
||||
{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',
|
||||
width: 100,
|
||||
formatter: (cell, formatterParams, onRendered) => {
|
||||
let container = document.createElement('div');
|
||||
container.className = "d-flex gap-2";
|
||||
|
||||
let button = document.createElement('button');
|
||||
button.className = 'btn btn-outline-secondary btn-action';
|
||||
button.innerHTML = '<i class="fa fa-edit"></i>';
|
||||
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 = '<i class="fa fa-xmark"></i>';
|
||||
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
|
||||
});
|
||||
cm.getColumnByField('type_id').component.updateDefinition({
|
||||
visible: this.showVariables.showType_id
|
||||
});
|
||||
cm.getColumnByField('id').component.updateDefinition({
|
||||
visible: this.showVariables.showId
|
||||
});
|
||||
|
||||
}
|
||||
],
|
||||
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,
|
||||
showType_id: false,
|
||||
showId: false,
|
||||
showLastupdate: false
|
||||
},
|
||||
}
|
||||
],
|
||||
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,
|
||||
showType_id: false,
|
||||
showId: false,
|
||||
showLastupdate: false
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -271,33 +275,21 @@ export default {
|
||||
|
||||
formData.append('data', JSON.stringify(this.notizData));
|
||||
Object.entries(this.notizData.anhang).forEach(([k, v]) => formData.append(k, v));
|
||||
/* 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 => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
|
||||
this.resetFormData();
|
||||
this.reload();
|
||||
})
|
||||
return this.endpoint.addNewNotiz(this.id, formData)
|
||||
.then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
|
||||
this.resetFormData();
|
||||
this.reload();
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError)
|
||||
.finally(() => {
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
},
|
||||
deleteNotiz(notiz_id) {
|
||||
this.param = {
|
||||
'notiz_id': notiz_id,
|
||||
'type_id': this.typeId,
|
||||
'id': this.id
|
||||
};
|
||||
|
||||
return this.$fhcApi.post(this.endpoint + 'deleteNotiz/', this.param)
|
||||
return this.endpoint.deleteNotiz(notiz_id, this.typeId, this.id)
|
||||
//return this.$fhcApi.post(this.endpoint + 'deleteNotiz/', this.param)
|
||||
.then(result => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
|
||||
this.$refs.deleteNotizModal.hide();
|
||||
@@ -310,11 +302,7 @@ export default {
|
||||
});
|
||||
},
|
||||
loadNotiz(notiz_id) {
|
||||
this.param = {
|
||||
'notiz_id': notiz_id
|
||||
};
|
||||
return this.$fhcApi.post(this.endpoint + 'loadNotiz/',
|
||||
this.param)
|
||||
return this.endpoint.loadNotiz(notiz_id)
|
||||
.then(result => {
|
||||
this.notizData = result.data;
|
||||
this.notizData.typeId = this.typeId;
|
||||
@@ -323,11 +311,7 @@ export default {
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
loadDocEntries(notiz_id) {
|
||||
this.param = {
|
||||
'notiz_id': notiz_id
|
||||
};
|
||||
return this.$fhcApi.post(this.endpoint + 'loadDokumente/',
|
||||
this.param)
|
||||
return this.endpoint.loadDokumente(notiz_id)
|
||||
.then(
|
||||
result => {
|
||||
this.notizData.anhang = result.data;
|
||||
@@ -340,19 +324,12 @@ export default {
|
||||
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
|
||||
};
|
||||
|
||||
return this.$fhcApi.post(
|
||||
this.endpoint + 'updateNotiz/',
|
||||
formData,
|
||||
{Headers: {"Content-Type": "multipart/form-data"}}
|
||||
).then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
|
||||
this.resetFormData();
|
||||
this.reload();
|
||||
})
|
||||
return this.endpoint.updateNotiz(notiz_id, formData)
|
||||
.then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
|
||||
this.resetFormData();
|
||||
this.reload();
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError)
|
||||
.finally(() => {
|
||||
window.scrollTo(0, 0);
|
||||
@@ -379,16 +356,14 @@ export default {
|
||||
};
|
||||
},
|
||||
getUid() {
|
||||
this.$fhcApi
|
||||
.get(this.endpoint + 'getUid')
|
||||
return this.endpoint.getUid()
|
||||
.then(result => {
|
||||
this.notizData.intVerfasser = result.data;
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
search(event) {
|
||||
return this.$fhcApi
|
||||
.get(this.endpoint + 'getMitarbeiter/' + event.query)
|
||||
return this.endpoint.getMitarbeiter(event.query)
|
||||
.then(result => {
|
||||
this.filteredMitarbeiter = result.data.retval;
|
||||
});
|
||||
@@ -535,7 +510,7 @@ export default {
|
||||
<label for="text" class="form-label col-sm-2">{{$p.t('global','text')}} *</label>
|
||||
|
||||
<!-- TinyMce 5 -->
|
||||
<div v-if="showTinyMCE"class="col-sm-7">
|
||||
<div v-if="showTinyMCE" class="col-sm-7">
|
||||
<textarea
|
||||
ref="editor"
|
||||
rows="5"
|
||||
@@ -1062,4 +1037,3 @@ export default {
|
||||
<br>
|
||||
`,
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,9 @@ export default {
|
||||
template: `
|
||||
<div class="stv-details-details h-100 pb-3">
|
||||
<h3>Notizen</h3>
|
||||
<NotizComponent
|
||||
|
||||
<!--oldversion ohne factory-->
|
||||
<!-- <NotizComponent
|
||||
endpoint="api/frontend/v1/stv/Notiz/"
|
||||
ref="formc"
|
||||
typeId="person_id"
|
||||
@@ -21,6 +23,20 @@ export default {
|
||||
:showTinyMCE="false"
|
||||
:visibleColumns="['titel','text','verfasser','bearbeiter','dokumente']"
|
||||
>
|
||||
</NotizComponent>-->
|
||||
|
||||
<!-- mit factory als endpoint -->
|
||||
<NotizComponent
|
||||
:endpoint="$fhcApi.factory.notiz.person"
|
||||
ref="formc"
|
||||
typeId="person_id"
|
||||
:id="modelValue.person_id"
|
||||
notizLayout="twoColumnsFormLeft"
|
||||
:showErweitert="true"
|
||||
:showDocument="true"
|
||||
:showTinyMCE="true"
|
||||
:visibleColumns="['titel','text','verfasser','bearbeiter','dokumente']"
|
||||
>
|
||||
</NotizComponent>
|
||||
|
||||
<!--
|
||||
@@ -87,4 +103,4 @@ visibleColumns: list, which fields shoult be showed as default in filter compone
|
||||
|
||||
</div>
|
||||
`
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user