From 45bc65d32a783ef5002d7b3d1e0b5c9d52dd5026 Mon Sep 17 00:00:00 2001 From: ma0048 Date: Mon, 11 Nov 2024 07:33:49 +0100 Subject: [PATCH] - Tags testversion - header tooltips - lehre spalte markieren wenn altes semester - legende-tab hinzugefuegt --- application/core/Tag_Controller.php | 176 ++++++++++++++ application/models/system/Notiztyp_model.php | 14 ++ application/views/templates/FHC-Common.php | 1 + application/views/templates/FHC-Header.php | 3 + public/css/tags.css | 66 ++++++ public/js/components/Tag/Tag.js | 233 +++++++++++++++++++ system/dbupdate_3.4.php | 2 + 7 files changed, 495 insertions(+) create mode 100644 application/core/Tag_Controller.php create mode 100644 application/models/system/Notiztyp_model.php create mode 100644 public/css/tags.css create mode 100644 public/js/components/Tag/Tag.js diff --git a/application/core/Tag_Controller.php b/application/core/Tag_Controller.php new file mode 100644 index 000000000..740f3b09d --- /dev/null +++ b/application/core/Tag_Controller.php @@ -0,0 +1,176 @@ + self::BERECHTIGUNG_KURZBZ, + 'getTags' => self::BERECHTIGUNG_KURZBZ, + 'addTag' => self::BERECHTIGUNG_KURZBZ, + + 'updateTag' => self::BERECHTIGUNG_KURZBZ, + 'doneTag' => self::BERECHTIGUNG_KURZBZ, + 'deleteTag' => self::BERECHTIGUNG_KURZBZ, + ]; + + $merged_permissions = array_merge($default_permissions, $permissions); + + parent::__construct($merged_permissions); + + $this->_setAuthUID(); + $this->load->model('person/Notiz_model', 'NotizModel'); + $this->load->model('system/Notiztyp_model', 'NotiztypModel'); + $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); + } + + public function getTag() + { + $id = $this->input->get('id'); + + $this->NotizModel->addSelect( + 'tbl_notiz.titel, + tbl_notiz.text, + array_to_json(bezeichnung_mehrsprachig::varchar[])->>0 as bezeichnung, + tbl_notiz.notiz_id, + tbl_notiz_typ.style, + tbl_notiz.erledigt as done, + tbl_notiz.insertamum, + tbl_notiz.updateamum, + tbl_notiz.insertvon, + tbl_notiz.updatevon + ' + ); + $this->NotizModel->addJoin('public.tbl_notiz_typ', 'public.tbl_notiz.typ = public.tbl_notiz_typ.typ_kurzbz'); + $notiz = $this->NotizModel->loadWhere(array('notiz_id' => $id)); + + $this->terminateWithSuccess(hasData($notiz) ? getData($notiz)[0] : array()); + } + + public function getTags() + { + $this->NotiztypModel->addSelect( + 'typ_kurzbz as tag_typ_kurzbz, + array_to_json(bezeichnung_mehrsprachig::varchar[])->>0 as bezeichnung, + style, + beschreibung, + tag + ' + ); + $notiztypen = $this->NotiztypModel->loadWhere(array('aktiv' => true)); + $this->terminateWithSuccess(hasData($notiztypen) ? getData($notiztypen) : array()); + } + + public function addTag($withZuordnung = true) + { + $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); + + $return = ""; + + if ($withZuordnung) + { + $checkZuordnungType = $this->NotizzuordnungModel->isValidType($postData->zuordnung_typ); + if (!isSuccess($checkZuordnungType)) + $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); + + $values = array_unique($postData->values); + + foreach ($values as $value) + { + $insertResult = $this->addNotiz($postData); + + if (isError($insertResult)) + $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); + + $insertZuordnung = $this->NotizzuordnungModel->insert(array( + 'notiz_id' => $insertResult->retval, + $postData->zuordnung_typ => $value + )); + + if (isError($insertZuordnung)) + $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); + + $return[] = [$postData->zuordnung_typ => $value, 'id' => $insertResult->retval]; + } + } + else + { + $insertResult = $this->addNotiz($postData); + if (isError($insertResult)) + $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); + + $return = $insertResult->retval; + } + + $this->terminateWithSuccess($return); + } + + 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() + { + $postData = $this->getPostJson(); + $updateData = $this->NotizModel->update(array('notiz_id' => $postData->id), + array('text' => $postData->notiz) + ); + $this->terminateWithSuccess($updateData); + } + public function doneTag() + { + $postData = $this->getPostJson(); + $updateData = $this->NotizModel->update(array('notiz_id' => $postData->id), + array('erledigt' => !$postData->done) + ); + + $this->terminateWithSuccess($updateData); + } + + public function deleteTag() + { + $postData = $this->getPostJson(); + $deleteZuordnung = $this->NotizzuordnungModel->delete(array( + 'notiz_id' => $postData->id + )); + + if (isSuccess($deleteZuordnung)) + { + $deleteNotiz = $this->NotizModel->delete(array( + 'notiz_id' => $postData->id + )); + } + $this->terminateWithSuccess(true); + } + + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) + show_error('User authentification failed'); + } + + +} \ No newline at end of file diff --git a/application/models/system/Notiztyp_model.php b/application/models/system/Notiztyp_model.php new file mode 100644 index 000000000..b173377e6 --- /dev/null +++ b/application/models/system/Notiztyp_model.php @@ -0,0 +1,14 @@ +dbTable = 'public.tbl_notiz_typ'; + $this->pk = 'typ_kurzbz'; + } +} diff --git a/application/views/templates/FHC-Common.php b/application/views/templates/FHC-Common.php index 072ff1d7f..f8194d194 100644 --- a/application/views/templates/FHC-Common.php +++ b/application/views/templates/FHC-Common.php @@ -44,3 +44,4 @@ $tablewidget = isset($tablewidget) ? $tablewidget : false; $udfs = isset($udfs) ? $udfs : false; $widgets = isset($widgets) ? $widgets : false; + $tags = isset($tags) ? $tags : false; diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index ed9fa97b9..39cc881d1 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -118,6 +118,9 @@ // CIS if ($cis === true) generateCSSsInclude('public/css/cis_bs5.css'); + //Tags + if ($tags === true) generateCSSsInclude('public/css/tags.css'); + // Eventually required CSS generateCSSsInclude($customCSSs); // Eventually required CSS ?> diff --git a/public/css/tags.css b/public/css/tags.css new file mode 100644 index 000000000..b1ee7d4c9 --- /dev/null +++ b/public/css/tags.css @@ -0,0 +1,66 @@ +:is(.tag_notice, .tag_inwork, .tag_planning) { + display: inline-block; + padding: 5px 10px; + margin-right: 5px; + border-radius: 3px; + color: white; + cursor: default; + font-size: .75em; + font-weight: 700; + line-height: 1; + text-align: center; + white-space: nowrap; + vertical-align: baseline; +} + +.tag_notice { + background-color: red !important; +} +.tag_inwork { + background-color: violet !important; +} +.tag_planning { + background-color: lightblue !important; +} + +.dropdown-list { + list-style: none; + background-color: white; + border: 1px solid #ccc; + border-radius: 5px; + box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1); + z-index: 1000; + position: absolute; + padding: 10px 10px 10px; + max-width: 200px; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.plus-button-container.disabled { + pointer-events: none; + opacity: 0.5; +} + +.plus-more-tags { + font-weight: bold; + color: #007bff; + cursor: pointer; +} + +.all-tags-modal-content { + display: flex; + flex-direction: column; + gap: 0.5rem; +} + +.tag-done { + text-decoration: line-through; +} + +.modificationdate { + font-style: italic; + font-size: 0.7em; + text-align: left; +} diff --git a/public/js/components/Tag/Tag.js b/public/js/components/Tag/Tag.js new file mode 100644 index 000000000..be37659ae --- /dev/null +++ b/public/js/components/Tag/Tag.js @@ -0,0 +1,233 @@ +import CoreForm from '../Form/Form.js'; +import FormInput from "../Form/Input.js"; +import BsModal from '../Bootstrap/Modal.js'; + +export default { + components: { + CoreForm, + FormInput, + BsModal, + }, + emits: [ + 'added', + 'updated', + 'deleted', + ], + props: { + endpoint: { + type: Object, + required: true + }, + zuordnung_typ: String, + savepoint: {}, + values: { + type: Array, + required: true + } + }, + data() { + return { + showList: false, + selectedTagId: null, + tagData: { + beschreibung: "", + tag_typ_kurzbz: "", + notiz: "", + style: "", + zuordnung_typ: "", + id: "", + insertamum: "", + insertvon: "", + updateamum: "", + updatevon: "", + response: "" + }, + mode: "create" + }; + }, + created() { + this.init(); + }, + mounted() {}, + methods: { + init() { + if (!this.endpoint) + return; + this.endpoint.getTags() + .then(response => response.data) + .then(response => { + this.tags = response + }) + }, + hideList() { + this.showList = false; + }, + async editTag(tag_id) { + let getData = { + 'id': tag_id + }; + + this.endpoint.getTag(getData) + .then(result => result.data) + .then(result => this.openModal(result)) + }, + openModal(item = null) + { + this.tagData.beschreibung = item.bezeichnung; + this.tagData.tag_typ_kurzbz = item.tag_typ_kurzbz; + this.tagData.style = item.style; + this.tagData.zuordnung_typ = this.zuordnung_typ; + this.tagData.done = item.done; + this.tagData.insertamum = item.insertamum; + this.tagData.updateamum = item.updateamum; + this.tagData.updatevon = item.updatevon; + this.tagData.insertvon = item.insertvon; + + if (item && item.notiz_id) + { + this.selectedTagId = item.notiz_id; + this.tagData.notiz = item.text; + this.mode = "edit"; + } + else + { + this.selectedTagId = null; + this.tagData.notiz = ""; + this.mode = "create"; + } + this.$refs.tagModal.show(); + }, + async saveTag() + { + let postData = { + tag_typ_kurzbz: this.tagData.tag_typ_kurzbz, + notiz: this.tagData.notiz, + zuordnung_typ: this.tagData.zuordnung_typ, + values: this.values + } + + if (this.mode === "edit") + { + postData.id = this.selectedTagId; + this.tagData.id = this.selectedTagId; + this.endpoint.updateTag(postData); + this.$emit("updated", this.tagData); + this.$refs.tagModal.hide(); + } + else + { + this.endpoint.addTag(postData) + .then(response => response.data) + .then(response => { + if (typeof response === 'number') { + console.log(response); + this.tagData.id = response; + } else { + this.tagData.response = response; + } + }) + .then(() => { + this.$emit("added", this.tagData); + }) + .then(() => { + this.$refs.tagModal.hide(); + }); + } + + + }, + async doneTag() + { + this.tagData.id = this.selectedTagId; + this.tagData.done = !this.tagData.done; + + let postData = { + id: this.selectedTagId, + done: !this.tagData.done + } + this.endpoint.doneTag(postData) + this.$emit("updated", this.tagData); + this.$refs.tagModal.hide(); + }, + async deleteTag() + { + let postData = { + id: this.selectedTagId + } + this.endpoint.deleteTag(postData) + this.$emit("deleted", this.selectedTagId) + this.$refs.tagModal.hide(); + }, + reset() { + this.tagData = { + beschreibung: "", + tag_typ_kurzbz: "", + notiz: "", + style: "", + zuordnung_typ: "", + id: "", + done: false, + insertamum: "", + insertvon: "", + updateamum: "", + updatevon: "", + response: "" + }; + this.selectedTagId = null; + this.mode = "create"; + } + }, + template: ` +
+ + +
+ + + + + + `, +} \ No newline at end of file diff --git a/system/dbupdate_3.4.php b/system/dbupdate_3.4.php index 06b1e0cb4..42908ccbc 100644 --- a/system/dbupdate_3.4.php +++ b/system/dbupdate_3.4.php @@ -57,6 +57,8 @@ require_once('dbupdate_3.4/34543_ux_template.php'); require_once('dbupdate_3.4/17513_Entwicklungsteam.php'); require_once('dbupdate_3.4/28575_softwarebereitstellung.php'); require_once('dbupdate_3.4/40717_lv_faktor.php'); +require_once('dbupdate_3.4/48526_pep_tagging.php'); + // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen echo '

Pruefe Tabellen und Attribute!

';