mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
lvverwaltung einschraenkung bei den tags
erledigte tags werden in der header suche nicht beruecksichtigt
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
$config['lvverwaltung_tags'] = [
|
||||
'hinweis_stg_kf' => ['readonly' => false],
|
||||
'hinweis' => ['readonly' => false],
|
||||
'hinweis_assistenz' => ['readonly' => false],
|
||||
'finished_stg' => ['readonly' => false],
|
||||
|
||||
'finished_kf' => ['readonly' => true],
|
||||
'inwork_kf' => ['readonly' => true],
|
||||
];
|
||||
@@ -116,7 +116,7 @@ class Gruppe extends FHCAPI_Controller
|
||||
bezeichnung,
|
||||
gid,
|
||||
\'false\' as lehrverband');
|
||||
$gruppen_result = $this->_ci->GruppeModel->loadWhere(array('sichtbar' => true, 'aktiv' => true, 'lehre' => true, 'direktinskription' => false));
|
||||
$gruppen_result = $this->_ci->GruppeModel->loadWhere(array('sichtbar' => true, 'aktiv' => true, 'lehre' => true, 'direktinskription' => false, 'semester IS NOT NULL' => null));
|
||||
|
||||
$gruppen_array = array();
|
||||
|
||||
|
||||
@@ -20,5 +20,31 @@ class Tags extends Tag_Controller
|
||||
'doneLehre' => self::BERECHTIGUNG_KURZBZ,
|
||||
'deleteLehre' => self::BERECHTIGUNG_KURZBZ,
|
||||
]);
|
||||
|
||||
$this->config->load('lvverwaltung');
|
||||
}
|
||||
public function getTag($readonly_tags = null)
|
||||
{
|
||||
parent::getTag($this->config->item('lvverwaltung_tags'));
|
||||
}
|
||||
public function getTags($tags = null)
|
||||
{
|
||||
parent::getTags($this->config->item('lvverwaltung_tags'));
|
||||
}
|
||||
public function addTag($withZuordnung = true, $updatable_tags = null)
|
||||
{
|
||||
parent::addTag(true, $this->config->item('lvverwaltung_tags'));
|
||||
}
|
||||
public function updateTag($updatable_tags = null)
|
||||
{
|
||||
parent::updateTag($this->config->item('lvverwaltung_tags'));
|
||||
}
|
||||
public function deleteTag($withZuordnung = true, $updatable_tags = null)
|
||||
{
|
||||
parent::deleteTag(true, $this->config->item('lvverwaltung_tags'));
|
||||
}
|
||||
public function doneTag($updatable_tags = null)
|
||||
{
|
||||
parent::doneTag($this->config->item('lvverwaltung_tags'));
|
||||
}
|
||||
}
|
||||
@@ -29,13 +29,36 @@ class Tag_Controller extends FHCAPI_Controller
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
$this->load->model('system/Notiztyp_model', 'NotiztypModel');
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
|
||||
$this->loadPhrases([
|
||||
'ui'
|
||||
]);
|
||||
}
|
||||
|
||||
public function getTag()
|
||||
public function getTag($readonly_tags = null)
|
||||
{
|
||||
$language = $this->_getLanguageIndex();
|
||||
$id = $this->input->get('id');
|
||||
|
||||
if (is_array($readonly_tags) && !isEmptyArray($readonly_tags))
|
||||
{
|
||||
$readonly_tags = $this->_filterTag($readonly_tags, true);
|
||||
|
||||
foreach ($readonly_tags as $key => $tag)
|
||||
{
|
||||
$readonly_tags[$key] = $this->NotizModel->db->escape($tag);
|
||||
}
|
||||
$tags = '(' . implode(',', $readonly_tags) . ')';
|
||||
|
||||
$this->NotizModel->addSelect("
|
||||
CASE
|
||||
WHEN tbl_notiz_typ.typ_kurzbz IN $tags
|
||||
THEN TRUE
|
||||
ELSE FALSE
|
||||
END as readonly
|
||||
");
|
||||
}
|
||||
|
||||
$this->NotizModel->addSelect(
|
||||
"tbl_notiz.titel,
|
||||
tbl_notiz.text,
|
||||
@@ -54,7 +77,7 @@ class Tag_Controller extends FHCAPI_Controller
|
||||
$this->NotizModel->addJoin('public.tbl_benutzer verfasserbenutzer', 'tbl_notiz.verfasser_uid = verfasserbenutzer.uid', 'LEFT');
|
||||
$this->NotizModel->addJoin('public.tbl_person verfasserperson', 'verfasserbenutzer.person_id = verfasserperson.person_id', 'LEFT');
|
||||
|
||||
$this->NotizModel->addJoin('public.tbl_benutzer bearbeiterbenutzer', 'tbl_notiz.verfasser_uid = bearbeiterbenutzer.uid', 'LEFT');
|
||||
$this->NotizModel->addJoin('public.tbl_benutzer bearbeiterbenutzer', 'tbl_notiz.bearbeiter_uid = bearbeiterbenutzer.uid', 'LEFT');
|
||||
$this->NotizModel->addJoin('public.tbl_person bearbeiterperson', 'bearbeiterbenutzer.person_id = bearbeiterperson.person_id', 'LEFT');
|
||||
|
||||
$notiz = $this->NotizModel->loadWhere(array('notiz_id' => $id));
|
||||
@@ -62,7 +85,7 @@ class Tag_Controller extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess(hasData($notiz) ? getData($notiz)[0] : array());
|
||||
}
|
||||
|
||||
public function getTags()
|
||||
public function getTags($tags = null)
|
||||
{
|
||||
$this->NotiztypModel->addSelect(
|
||||
'typ_kurzbz as tag_typ_kurzbz,
|
||||
@@ -73,19 +96,36 @@ class Tag_Controller extends FHCAPI_Controller
|
||||
'
|
||||
);
|
||||
$this->NotiztypModel->addOrder('prioritaet');
|
||||
|
||||
if (is_array($tags) && !isEmptyArray($tags))
|
||||
{
|
||||
$tags = $this->_filterTag($tags, false);
|
||||
$this->NotiztypModel->db->where_in('typ_kurzbz', $tags);
|
||||
}
|
||||
|
||||
$notiztypen = $this->NotiztypModel->loadWhere(array('aktiv' => true));
|
||||
$this->terminateWithSuccess(hasData($notiztypen) ? getData($notiztypen) : array());
|
||||
}
|
||||
|
||||
public function addTag($withZuordnung = true)
|
||||
public function addTag($withZuordnung = true, $updatable_tags = null)
|
||||
{
|
||||
$postData = $this->getPostJson();
|
||||
|
||||
$checkTyp = $this->NotiztypModel->loadWhere(array('typ_kurzbz' => $postData->tag_typ_kurzbz));
|
||||
|
||||
if (!hasData($checkTyp))
|
||||
$this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL);
|
||||
if (isError($checkTyp))
|
||||
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
|
||||
|
||||
if (!hasData($checkTyp))
|
||||
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
|
||||
|
||||
if (is_array($updatable_tags) && !isEmptyArray($updatable_tags))
|
||||
{
|
||||
$tags = $this->_filterTag($updatable_tags, false);
|
||||
|
||||
if (!in_array($postData->tag_typ_kurzbz, $tags))
|
||||
$this->terminateWithError($this->p->t('ui', 'keineBerechtigung'));
|
||||
}
|
||||
|
||||
if ($withZuordnung)
|
||||
{
|
||||
@@ -125,48 +165,88 @@ class Tag_Controller extends FHCAPI_Controller
|
||||
}
|
||||
}
|
||||
|
||||
private function addNotiz($postData)
|
||||
{
|
||||
return $this->NotizModel->insert(array(
|
||||
'titel' => 'TAG', //TODO klären
|
||||
'text' => $postData->notiz,
|
||||
'verfasser_uid' => $this->_uid,
|
||||
'erledigt' => false,
|
||||
'insertamum' => date('Y-m-d H:i:s'),
|
||||
'insertvon' => $this->_uid,
|
||||
'typ' => $postData->tag_typ_kurzbz
|
||||
));
|
||||
|
||||
}
|
||||
public function updateTag()
|
||||
public function updateTag($updatable_tags = null)
|
||||
{
|
||||
$postData = $this->getPostJson();
|
||||
$post_tag = $this->NotizModel->loadWhere(array('notiz_id' => $postData->id));
|
||||
|
||||
if (isError($post_tag))
|
||||
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
|
||||
|
||||
if (!hasData($post_tag))
|
||||
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
|
||||
|
||||
if (is_array($updatable_tags) && !isEmptyArray($updatable_tags))
|
||||
{
|
||||
$tags = $this->_filterTag($updatable_tags, false);
|
||||
|
||||
$post_tag_typ = getData($post_tag)[0]->typ;
|
||||
|
||||
if (!in_array($post_tag_typ, $tags))
|
||||
$this->terminateWithError($this->p->t('ui', 'keineBerechtigung'));
|
||||
}
|
||||
|
||||
$updateData = $this->NotizModel->update(array('notiz_id' => $postData->id),
|
||||
array('text' => $postData->notiz,
|
||||
'updateamum' => date('Y-m-d H:i:s'),
|
||||
'updatevon' => $this->_uid,
|
||||
'bearbeiter_uid' => $this->_uid,
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->terminateWithSuccess($updateData);
|
||||
}
|
||||
public function doneTag()
|
||||
public function doneTag($updatable_tags = null)
|
||||
{
|
||||
$postData = $this->getPostJson();
|
||||
$post_tag = $this->NotizModel->loadWhere(array('notiz_id' => $postData->id));
|
||||
|
||||
if (isError($post_tag))
|
||||
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
|
||||
|
||||
if (!hasData($post_tag))
|
||||
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
|
||||
|
||||
if (is_array($updatable_tags) && !isEmptyArray($updatable_tags))
|
||||
{
|
||||
$tags = $this->_filterTag($updatable_tags, false);
|
||||
|
||||
$post_tag_typ = getData($post_tag)[0]->typ;
|
||||
|
||||
if (!in_array($post_tag_typ, $tags))
|
||||
$this->terminateWithError($this->p->t('ui', 'keineBerechtigung'));
|
||||
}
|
||||
|
||||
$updateData = $this->NotizModel->update(array('notiz_id' => $postData->id),
|
||||
array('erledigt' => !$postData->done,
|
||||
'text' => $postData->notiz,
|
||||
'updateamum' => date('Y-m-d H:i:s'),
|
||||
'updatevon' => $this->_uid,
|
||||
'bearbeiter_uid' => $this->_uid,
|
||||
)
|
||||
);
|
||||
|
||||
$this->terminateWithSuccess($updateData);
|
||||
}
|
||||
|
||||
public function deleteTag($withZuordnung = true)
|
||||
public function deleteTag($withZuordnung = true, $updatable_tags = null)
|
||||
{
|
||||
$postData = $this->getPostJson();
|
||||
$post_tag = $this->NotizModel->loadWhere(array('notiz_id' => $postData->id));
|
||||
|
||||
if (isError($post_tag))
|
||||
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
|
||||
|
||||
if (!hasData($post_tag))
|
||||
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
|
||||
|
||||
if (is_array($updatable_tags) && !isEmptyArray($updatable_tags))
|
||||
{
|
||||
$tags = $this->_filterTag($updatable_tags, false);
|
||||
|
||||
$post_tag_typ = getData($post_tag)[0]->typ;
|
||||
|
||||
if (!in_array($post_tag_typ, $tags))
|
||||
$this->terminateWithError($this->p->t('ui', 'keineBerechtigung'));
|
||||
}
|
||||
|
||||
$deleteNotiz = "";
|
||||
if ($withZuordnung)
|
||||
@@ -208,5 +288,27 @@ class Tag_Controller extends FHCAPI_Controller
|
||||
return hasData($result) ? getData($result)[0]->index : 1;
|
||||
}
|
||||
|
||||
private function _filterTag($tags, $readonly = true)
|
||||
{
|
||||
$filtered_tags = array_filter($tags, function ($tag) use ($readonly)
|
||||
{
|
||||
return isset($tag['readonly']) && $tag['readonly'] === $readonly;
|
||||
});
|
||||
|
||||
return array_keys($filtered_tags);
|
||||
}
|
||||
|
||||
private function addNotiz($postData)
|
||||
{
|
||||
return $this->NotizModel->insert(array(
|
||||
'titel' => 'TAG', //TODO klären
|
||||
'text' => $postData->notiz,
|
||||
'verfasser_uid' => $this->_uid,
|
||||
'erledigt' => false,
|
||||
'insertamum' => date('Y-m-d H:i:s'),
|
||||
'insertvon' => $this->_uid,
|
||||
'typ' => $postData->tag_typ_kurzbz
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -689,10 +689,26 @@ EOSQL;
|
||||
|
||||
private function _getTagsCTE()
|
||||
{
|
||||
$this->load->config('lvverwaltung');
|
||||
$tags = $this->config->item('tags');
|
||||
|
||||
$whereTags = '';
|
||||
if (is_array($tags) && !isEmptyArray($tags))
|
||||
{
|
||||
$tags = array_keys($tags);
|
||||
|
||||
foreach ($tags as $key => $tag)
|
||||
{
|
||||
$tags[$key] = $this->db->escape($tag);
|
||||
}
|
||||
|
||||
$whereTags = " AND tbl_notiz_typ.typ_kurzbz IN (" . implode(",", $tags) . ")";
|
||||
}
|
||||
|
||||
return "tag_data_agg AS (
|
||||
SELECT
|
||||
lehreinheit_id,
|
||||
COALESCE(json_agg(tag ORDER BY id), '[]'::json) AS tags
|
||||
COALESCE(json_agg(tag ORDER BY done), '[]'::json) AS tags
|
||||
FROM (
|
||||
SELECT DISTINCT ON (public.tbl_notiz.notiz_id)
|
||||
tbl_notiz.notiz_id AS id,
|
||||
@@ -705,8 +721,9 @@ EOSQL;
|
||||
FROM public.tbl_notizzuordnung
|
||||
JOIN public.tbl_notiz ON tbl_notizzuordnung.notiz_id = tbl_notiz.notiz_id
|
||||
JOIN public.tbl_notiz_typ ON tbl_notiz.typ = tbl_notiz_typ.typ_kurzbz
|
||||
WHERE lehreinheit_id IN (SELECT lehreinheit_id FROM lehreinheiten)
|
||||
) AS tag
|
||||
WHERE lehreinheit_id IN (SELECT lehreinheit_id FROM lehreinheiten)"
|
||||
. $whereTags.
|
||||
") AS tag
|
||||
GROUP BY lehreinheit_id
|
||||
)";
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ export default {
|
||||
this.tagData.updateamum = this.formatDateTime(item.updateamum)
|
||||
this.tagData.bearbeiter = item.bearbeiter;
|
||||
this.tagData.verfasser = item.verfasser;
|
||||
this.tagData.readonly = item.readonly;
|
||||
|
||||
if (item && item.notiz_id)
|
||||
{
|
||||
@@ -154,7 +155,8 @@ export default {
|
||||
|
||||
let postData = {
|
||||
id: this.selectedTagId,
|
||||
done: !this.tagData.done
|
||||
done: !this.tagData.done,
|
||||
notiz: this.tagData.notiz,
|
||||
}
|
||||
this.$api.call(this.endpoint.doneTag(postData))
|
||||
this.$emit("updated", this.tagData);
|
||||
@@ -182,7 +184,8 @@ export default {
|
||||
verfasser: "",
|
||||
updateamum: "",
|
||||
bearbeiter: "",
|
||||
response: ""
|
||||
response: "",
|
||||
readonly: false
|
||||
};
|
||||
this.selectedTagId = null;
|
||||
this.mode = "create";
|
||||
@@ -230,6 +233,7 @@ export default {
|
||||
v-model="tagData.notiz"
|
||||
type="textarea"
|
||||
field="notiz"
|
||||
:readonly="tagData.readonly"
|
||||
placeholder="Notiz..."
|
||||
></form-input>
|
||||
<div class="modificationdate">
|
||||
@@ -243,7 +247,7 @@ export default {
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
<template #footer v-if="!tagData.readonly">
|
||||
<div class="d-flex justify-content-between w-100">
|
||||
<div>
|
||||
<button
|
||||
|
||||
@@ -146,12 +146,13 @@ export function tagHeaderFilter(headerValue, rowValue, rowData, filterParams)
|
||||
if (Array.isArray(data))
|
||||
{
|
||||
combinedText = data
|
||||
.filter(item => item?.done === false)
|
||||
.map(item => `${item?.beschreibung} ${item?.notiz}`)
|
||||
.join(' ');
|
||||
}
|
||||
else if (typeof data === 'object' && data !== null)
|
||||
{
|
||||
combinedText = `${data?.beschreibung} ${data?.notiz}`;
|
||||
combinedText = data?.erledigt === false ? `${data?.beschreibung} ${data?.notiz}` : '';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user