add lvvw menu and clean up stv menu

This commit is contained in:
chfhtw
2026-05-13 16:53:21 +02:00
parent 0f1059d5a5
commit bd164e611f
7 changed files with 135 additions and 51 deletions
+2 -1
View File
@@ -19,4 +19,5 @@
if (!defined('BASEPATH')) exit('No direct script access allowed');
$config['stv'] = "menu/StvMenuLib";
$config['stv'] = "menu/StvMenuLib"; // TODO(chris): rename to StudVw
$config['lvvw'] = "menu/LvVwMenuLib";
+126
View File
@@ -0,0 +1,126 @@
<?php
/**
* Copyright (C) 2026 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH . 'libraries/MenuBuilderLib.php');
require_once(APPPATH . 'traits/menu/StgTrait.php');
use \ReflectionMethod as ReflectionMethod;
/**
* LvVw Menu library
*/
class LvVwMenuLib extends MenuBuilderLib
{
use StgTrait;
protected $children = [
'ModifiedStg' => 'stg'
];
public function build($url_segments = [])
{
$result = $this->buildSubmenu($url_segments);
if ($result === null)
show_404();
return $result;
}
protected function initModifiedStg()
{
$config = $this->initStg();
$config['children'] = [
'ModifiedSemester' => 'semester',
'ModifiedOrgform' => 'orgform'
];
return $config;
}
protected function initModifiedSemester()
{
$config = $this->initSemester();
unset($config['children']);
$config['build'] = 'getModifiedSemester';
return $config;
}
protected function getModifiedSemester($vars, $pathTemplate, $linkTemplate)
{
$result = $this->getSemester($vars, $pathTemplate, $linkTemplate);
foreach (array_keys($result) as $key)
$result[$key]->leaf = true;
return $result;
}
protected function initModifiedOrgform()
{
$config = $this->initOrgform();
unset($config['children']);
$config['build'] = 'getModifiedOrgform';
return $config;
}
protected function getModifiedOrgform($vars, $pathTemplate, $linkTemplate)
{
$result = $this->getOrgform($vars, $pathTemplate, $linkTemplate);
foreach (array_keys($result) as $key)
$result[$key]->leaf = true;
return $result;
}
protected function getLinkTemplate($path, $vars)
{
$result = '';
$children = $this->children;
while (count($path)) {
$segment = array_shift($path);
$key = array_search($segment, $children);
$config = $this->getNodeConfig($key, $segment);
if (isset($config['identifiers'])) {
if (is_array($config['identifiers'])) {
$count = count($config['identifiers']);
} else {
$reflection = new ReflectionMethod($this, $config['identifiers']);
$count = $reflection->getNumberOfParameters();
}
while ($count--) {
if (count($path))
$result .= array_shift($path) . '/';
}
} else {
$result .= $segment . '/';
}
if (isset($config['children']))
$children = $config['children'];
else
return '%s';
}
return $result . '%s';
}
}
-2
View File
@@ -17,7 +17,6 @@
import app from './stv/app.js';
import lists from './stv/lists.js';
import verband from './stv/verband.js';
import students from './stv/students.js';
import filter from './stv/filter.js';
import konto from './stv/konto.js';
@@ -34,7 +33,6 @@ import admissionDates from './stv/admissionDates.js';
export default {
app,
lists,
verband,
students,
filter,
konto,
-43
View File
@@ -1,43 +0,0 @@
/**
* Copyright (C) 2025 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
export default {
get(path) {
let url = 'api/frontend/v1/stv/verband';
if (path)
url += '/' + path;
return {
method: 'get',
url
};
},
favorites: {
get() {
return {
method: 'get',
url: 'api/frontend/v1/stv/favorites'
};
},
set(favorites) {
return {
method: 'post',
url: 'api/frontend/v1/stv/favorites/set',
params: { favorites }
};
}
}
};
@@ -285,7 +285,7 @@ export default {
<div class="offcanvas-header justify-content-end px-1 d-md-none">
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" :aria-label="$p.t('ui/schliessen')"></button>
</div>
<stv-verband :preselectedKey="selectedStudiengang" :endpoint="endpoint" @select-verband="onSelectVerband" class="col" style="height:0%"></stv-verband>
<stv-verband menu="lvvw" :preselectedKey="selectedStudiengang" :endpoint="endpoint" @select-verband="onSelectVerband" class="col" style="height:0%"></stv-verband>
<stv-studiensemester v-model:studiensemester-kurzbz="selectedStudiensemester" @update:studiensemester-kurzbz="studiensemesterChanged"></stv-studiensemester>
</nav>
@@ -27,7 +27,6 @@ import StvStudiensemester from "./Studentenverwaltung/Studiensemester.js";
import ApiSearchbar from "../../api/factory/searchbar.js";
import ApiStv from "../../api/factory/stv.js";
import ApiStvVerband from '../../api/factory/stv/verband.js';
import ApiStvConfig from '../../api/factory/stv/config.js';
@@ -149,7 +148,6 @@ export default {
sprachen: [],
geschlechter: []
},
verbandEndpoint: ApiStvVerband,
filter: []
}
},
@@ -636,7 +634,7 @@ export default {
<div class="offcanvas-header justify-content-end px-1 d-md-none">
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" :aria-label="$p.t('ui/schliessen')"></button>
</div>
<stv-verband :preselectedKey="studiengangKz ? '' + studiengangKz : null" :endpoint="verbandEndpoint" @select-verband="onSelectVerband" class="col" style="height:0%"></stv-verband>
<stv-verband menu="stv" :preselectedKey="studiengangKz ? '' + studiengangKz : null" @select-verband="onSelectVerband" class="col" style="height:0%"></stv-verband>
<stv-studiensemester v-model:studiensemester-kurzbz="studiensemesterKurzbz" @update:studiensemester-kurzbz="studiensemesterChanged"></stv-studiensemester>
</nav>
<main class="col-md-8 ms-sm-auto col-lg-9 col-xl-10">
@@ -27,6 +27,10 @@ export default {
'selectVerband'
],
props: {
menu: {
type: String,
required: true
},
preselectedKey: {
type: String,
default: null
@@ -85,7 +89,7 @@ export default {
<div class="overflow-auto" tabindex="-1">
<base-menu
ref="menu"
config="stv"
:config="menu"
:preselected-key="preselectedKey"
@select-entry="onSelectTreeNode"
@drop="onDrop"