From 368eded1fdb36ed144b2827b2c17668f154f5c14 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Mon, 11 May 2026 15:12:53 +0200 Subject: [PATCH] remove frontend filtering list for studiensemester, update logs TagJob --- application/controllers/jobs/TagJob.php | 14 ++- application/core/Tag_Controller.php | 19 --- public/js/api/factory/stv/tag.js | 8 -- .../Stv/Studentenverwaltung/List.js | 51 +------- public/js/tabulator/formatter/tags.js | 119 +++--------------- 5 files changed, 26 insertions(+), 185 deletions(-) diff --git a/application/controllers/jobs/TagJob.php b/application/controllers/jobs/TagJob.php index 5a04204d7..d12231b06 100644 --- a/application/controllers/jobs/TagJob.php +++ b/application/controllers/jobs/TagJob.php @@ -34,7 +34,7 @@ class TagJob extends JOB_Controller public function rebuildAutomatedTags() { - $this->logInfo('Start Job rebuild Automated Tags'); + $automatedTagsRes = $this->NotiztypModel->loadWhere(array('automatisiert' => true, 'taglib IS NOT NULL' => null)); $automatedTags = hasData($automatedTagsRes) ? getData($automatedTagsRes) : []; @@ -43,12 +43,14 @@ class TagJob extends JOB_Controller $result = $this->StudiensemesterModel->getAktOrNextSemester(); if (isError($result)) { + $this->logInfo('Start Job rebuild Automated Tags'); $this->logError('Error occurred during retrieving studiensemester'); return $this->logInfo('End Job rebuild Automated Tags'); } if (empty($result->retval) || !isset($result->retval[0])) { - $this->logInfo('No Studiensemester found'); + $this->logInfo('Start Job rebuild Automated Tags'); + $this->logError('No Studiensemester found'); return $this->logInfo('End Job rebuild Automated Tags'); } $studiensemester_kurzbz = $result->retval[0]->studiensemester_kurzbz ?? null; @@ -56,6 +58,7 @@ class TagJob extends JOB_Controller 'studiensemester_kurzbz' => $studiensemester_kurzbz ); + $this->logInfo('Start Job rebuild Automated Tags ' . $studiensemester_kurzbz); foreach($automatedTags as $autoTag) { // getPath: must not be lost @@ -64,7 +67,7 @@ class TagJob extends JOB_Controller if(file_exists($filePath)) { require_once($filePath); } else { - $this->logInfo("File not found: " . $filePath . PHP_EOL); + $this->logInfo("File not found: " . $filePath); continue; } @@ -93,9 +96,8 @@ class TagJob extends JOB_Controller $data = is_array($result) ? $result['retval'] : $result->retval; - //PRINT OUTPUT CONSOLE //SUMMARY - $this->logInfo("Tag " . $result->retval['input']['tag'] . " | TYPE_ID " . $typeId . " --" + $this->logInfo("Tag " . $result->retval['input']['tag'] . " | type_id " . $typeId . " --" . " Count Recycled: " . $result->retval['summary']['recycled'] . " Count Added: ". $result->retval['summary']['added'] . " Count Deleted: ". $result->retval['summary']['deleted']); @@ -109,7 +111,7 @@ class TagJob extends JOB_Controller $this->logInfo("Tag " . $result->retval['input']['tag'] . "Recycled tag(s): " . implode(', ', $result->retval['results']['retaggedIds'])); } - $this->logInfo( PHP_EOL . "End Job rebuild Automated Tags"); + $this->logInfo( "End Job rebuild Automated Tags"); } } diff --git a/application/core/Tag_Controller.php b/application/core/Tag_Controller.php index 09f42922c..fb14563ba 100644 --- a/application/core/Tag_Controller.php +++ b/application/core/Tag_Controller.php @@ -19,7 +19,6 @@ class Tag_Controller extends FHCAPI_Controller 'doneTag' => self::BERECHTIGUNG_KURZBZ, 'deleteTag' => self::BERECHTIGUNG_KURZBZ, 'getAllTags' => self::BERECHTIGUNG_KURZBZ, - 'getAllStartAndEndAutomatedTags' => self::BERECHTIGUNG_KURZBZ, 'rebuildTagsForTypeId' => self::BERECHTIGUNG_KURZBZ, ]; @@ -351,24 +350,6 @@ class Tag_Controller extends FHCAPI_Controller $this->terminateWithSuccess($result); } - public function getAllStartAndEndAutomatedTags() - { - $this->NotizModel->addSelect('notiz_id as id'); - $this->NotizModel->addSelect('start'); - $this->NotizModel->addSelect('ende'); - $this->NotizModel->addSelect('typ'); - - $result = $this->NotizModel->loadWhere(array( - 'titel' => 'TAG', - 'verfasser_uid' => 'sftest' - )); - - if (isError($result)) - return error('Error occurred during retrieving intervalls automated tags'); - $data = getData($result); - $this->terminateWithSuccess($data); - } - private function _setAuthUID() { $this->_uid = getAuthUID(); diff --git a/public/js/api/factory/stv/tag.js b/public/js/api/factory/stv/tag.js index 522dfa3ff..4a22a009e 100644 --- a/public/js/api/factory/stv/tag.js +++ b/public/js/api/factory/stv/tag.js @@ -52,7 +52,6 @@ export default { }; }, - //TODO check if necessary to expand to other idTypes getAllTagsPrestudent(prestudent_id){ return { method: 'get', @@ -61,13 +60,6 @@ export default { }; }, - getAllStartAndEndAutomatedTags(){ - return { - method: 'get', - url: 'api/frontend/v1/stv/Tags/getAllStartAndEndAutomatedTags', - }; - }, - rebuildTagsforTypeId(data){ return { method: 'post', diff --git a/public/js/components/Stv/Studentenverwaltung/List.js b/public/js/components/Stv/Studentenverwaltung/List.js index 19cb451ae..480004f8c 100644 --- a/public/js/components/Stv/Studentenverwaltung/List.js +++ b/public/js/components/Stv/Studentenverwaltung/List.js @@ -237,8 +237,7 @@ export default { dragSource: [], oldScrollUrl: '', oldScrollLeft: 0, - oldScrollTop: 0, - intervalMap: {} + oldScrollTop: 0 } }, computed: { @@ -292,15 +291,10 @@ export default { .replace(/\//g, '_'); return "StudentList_" + today + ".csv"; }, - semesterDates(){ - return this.lists.studiensemester?.find(item => item.studiensemester_kurzbz === this.currentSemester) || {}; - } }, created: function() { if(this.tagsEnabled) { - this.loadIntervals(); //preload - const coltags = { title: 'Tags', field: 'tags', @@ -308,36 +302,7 @@ export default { headerFilter: "input", headerFilterFunc: tagHeaderFilter, headerFilterFuncParams: {field: 'tags'}, - //formatter: (cell) => tagFormatter(cell, this.$refs.tagComponent), //prev. Version without filter - formatter: (cell) => { - const raw = cell.getValue(); - - const tags = - Array.isArray(raw) - ? raw - : (typeof raw === 'string' - ? JSON.parse(raw) - : []); - - const id = tags?.[0]?.id; - - const interval = id - ? this.intervalMap[id] - : null; - - const enrichedTags = { - tags: tags, - start: interval?.start || null, - ende: interval?.ende || null, - }; - - return tagFormatter( - enrichedTags, - this.$refs?.tagComponent, - this.semesterDates?.start, - this.semesterDates?.ende - ); - }, + formatter: (cell) => tagFormatter(cell, this.$refs.tagComponent), width: 150, }; this.tabulatorOptions.columns.splice(2, 0, coltags); @@ -351,18 +316,6 @@ export default { }, }, methods: { - loadIntervals() { - return this.$api - .call(ApiTag.getAllStartAndEndAutomatedTags()) - .then(result => { - const data = result.data || []; - this.intervalMap = {}; - data.forEach(item => { - this.intervalMap[item.id] = item; - }); - }) - .catch(this.$fhcAlert.handleSystemError); - }, translateTabulator() { this.$p .loadCategory(['global', 'person', 'lehre', 'ui', 'profilUpdate', 'admission', 'stv']) diff --git a/public/js/tabulator/formatter/tags.js b/public/js/tabulator/formatter/tags.js index d9a5244fd..367a8a5fb 100644 --- a/public/js/tabulator/formatter/tags.js +++ b/public/js/tabulator/formatter/tags.js @@ -1,115 +1,34 @@ -export function tagFormatter( - cell, - tagComponent, - semesterStart = null, - semesterEnd = null -) { - - // support both call versions - // 1. previous Tabulator cell: old version - // 2. custom enriched object: with start and end for tags plus semesterDates - // for check if valid tag - - const isTabulatorCell = - cell && typeof cell.getValue === 'function'; - - const normalized = isTabulatorCell - ? { - tags: cell.getValue() || [], - start: null, - ende: null, - rowData: cell.getRow().getData(), - } - : { - tags: cell.tags || [], - start: cell.start || null, - ende: cell.ende || null, - rowData: cell.rowData || {}, - }; - - const tags = normalized.tags || []; - - if (!tags.length) { - return ""; - } - +export function tagFormatter(cell, tagComponent) +{ const mappedData = tagComponent.tags.map(tag => ({ typ_kurzbz: tag.tag_typ_kurzbz, - automatisiert: tag.automatisiert, - validFrom: normalized.start - ? new Date(normalized.start) - : null, - validTo: normalized.ende - ? new Date(normalized.ende) - : null + automatisiert: tag.automatisiert })); - const hasSemesterFilter = - !!(semesterStart && semesterEnd); - const semStart = hasSemesterFilter ? new Date(semesterStart) : null; - - const semEnd = hasSemesterFilter ? new Date(semesterEnd) : null; - - const isInSemester = (tag) => { - - if (!hasSemesterFilter) { - return true; - } - - if (!tag.validFrom && !tag.validTo) { - return true; - } - - if (tag.validFrom && tag.validTo) { - return ( - tag.validFrom <= semEnd && - tag.validTo >= semStart - ); - } - - if (tag.validFrom && !tag.validTo) { - return tag.validFrom <= semEnd; - } - - if (!tag.validFrom && tag.validTo) { - return tag.validTo >= semStart; - } - - return false; - }; - - // parse tags if needed - let parsedTags = - typeof tags === 'string' - ? JSON.parse(tags) - : tags; + let tags = cell.getValue(); + if (!tags) return; let container = document.createElement('div'); container.className = "d-flex gap-1"; + let parsedTags = []; + if (typeof tags === 'string') { + parsedTags = JSON.parse(tags); + } else if (Array.isArray(tags)) { + parsedTags = tags; + } + let maxVisibleTags = 2; - const rowData = normalized.rowData; - + const rowData = cell.getRow().getData(); if (rowData._tagExpanded === undefined) { rowData._tagExpanded = false; } const renderTags = () => { container.innerHTML = ''; - - parsedTags = parsedTags.filter(tag => { - const mapped = mappedData.find( - m => m.typ_kurzbz === tag.typ_kurzbz - ); - - if (!mapped) { - return true; - } - - return isInSemester(mapped); - }); + parsedTags = parsedTags.filter(item => item !== null); parsedTags.sort((a, b) => { let adone = a.done ? 1 : 0; @@ -121,14 +40,10 @@ export function tagFormatter( } return b.id - a.id; }); - - const tagsToShow = rowData._tagExpanded - ? parsedTags - : parsedTags.slice(0, maxVisibleTags); + const tagsToShow = rowData._tagExpanded ? parsedTags : parsedTags.slice(0, maxVisibleTags); tagsToShow.forEach(tag => { if (!tag) return; - let tagElement = document.createElement('span'); tagElement.innerText = tag.beschreibung; tagElement.title = tag.notiz; @@ -151,10 +66,8 @@ export function tagFormatter( container.appendChild(tagElement); }); - // show expand button - if ( parsedTags.length > maxVisibleTags) { + if (parsedTags.length > maxVisibleTags) { let toggle = document.createElement('button'); - toggle.innerText = (rowData._tagExpanded ? '- ' : '+ ') + (parsedTags.length - maxVisibleTags); toggle.className = "display_all"; toggle.title = rowData._tagExpanded ? "Tags ausblenden" : "Tags einblenden";