diff --git a/application/config/menubuilder.php b/application/config/menubuilder.php index 64337a691..f2b5256e1 100644 --- a/application/config/menubuilder.php +++ b/application/config/menubuilder.php @@ -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"; diff --git a/application/libraries/menu/LvVwMenuLib.php b/application/libraries/menu/LvVwMenuLib.php new file mode 100644 index 000000000..8b47a32ec --- /dev/null +++ b/application/libraries/menu/LvVwMenuLib.php @@ -0,0 +1,126 @@ +. + */ + +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'; + } +} diff --git a/public/js/api/factory/stv.js b/public/js/api/factory/stv.js index 95bc227f5..15ae15649 100644 --- a/public/js/api/factory/stv.js +++ b/public/js/api/factory/stv.js @@ -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, diff --git a/public/js/api/factory/stv/verband.js b/public/js/api/factory/stv/verband.js deleted file mode 100644 index 114931e4c..000000000 --- a/public/js/api/factory/stv/verband.js +++ /dev/null @@ -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 . - */ - -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 } - }; - } - } -}; \ No newline at end of file diff --git a/public/js/components/LVVerwaltung/LVVerwaltung.js b/public/js/components/LVVerwaltung/LVVerwaltung.js index 42c50bdfa..98c95c00e 100644 --- a/public/js/components/LVVerwaltung/LVVerwaltung.js +++ b/public/js/components/LVVerwaltung/LVVerwaltung.js @@ -285,7 +285,7 @@ export default {
- + diff --git a/public/js/components/Stv/Studentenverwaltung.js b/public/js/components/Stv/Studentenverwaltung.js index 25fee8a2e..5d75779b8 100644 --- a/public/js/components/Stv/Studentenverwaltung.js +++ b/public/js/components/Stv/Studentenverwaltung.js @@ -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 {
- +
diff --git a/public/js/components/Stv/Studentenverwaltung/Verband.js b/public/js/components/Stv/Studentenverwaltung/Verband.js index e93bc3224..b9419d0c9 100644 --- a/public/js/components/Stv/Studentenverwaltung/Verband.js +++ b/public/js/components/Stv/Studentenverwaltung/Verband.js @@ -27,6 +27,10 @@ export default { 'selectVerband' ], props: { + menu: { + type: String, + required: true + }, preselectedKey: { type: String, default: null @@ -85,7 +89,7 @@ export default {