mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bd164e611f | |||
| 0f1059d5a5 | |||
| e91f8e5ca4 | |||
| c765c3c40a |
@@ -0,0 +1,23 @@
|
||||
<?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');
|
||||
|
||||
$config['stv'] = "menu/StvMenuLib"; // TODO(chris): rename to StudVw
|
||||
$config['lvvw'] = "menu/LvVwMenuLib";
|
||||
@@ -0,0 +1,58 @@
|
||||
<?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');
|
||||
|
||||
/**
|
||||
* This controller operates between (interface) the JS (GUI) and the back-end
|
||||
* Provides data to the ajax get calls about menues
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Menu extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$permissions = [];
|
||||
$router = load_class('Router');
|
||||
// TODO(chris): permission
|
||||
$permissions[$router->method] = ['admin:r', 'assistenz:r'];
|
||||
parent::__construct($permissions);
|
||||
|
||||
// Load Config
|
||||
$this->config->load('menubuilder');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param array $params (optional)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function _remap($method, $params = [])
|
||||
{
|
||||
$this->load->library($this->config->item($method), null, 'menulib');
|
||||
|
||||
if (!$this->menulib)
|
||||
show_404();
|
||||
|
||||
$submenu = $this->menulib->build($params);
|
||||
|
||||
$this->terminateWithSuccess($submenu);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
<?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');
|
||||
|
||||
use \ReflectionMethod as ReflectionMethod;
|
||||
|
||||
/**
|
||||
* MenuBuilder library
|
||||
* TODO(chris): docu
|
||||
*/
|
||||
class MenuBuilderLib
|
||||
{
|
||||
protected $_ci;
|
||||
|
||||
protected $children = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Get code igniter instance
|
||||
$this->_ci =& get_instance();
|
||||
}
|
||||
|
||||
/*private function registerTraits()
|
||||
{
|
||||
$class = $this;
|
||||
$traits = [];
|
||||
|
||||
do {
|
||||
$traits = array_merge(class_uses($class), $traits);
|
||||
} while ($class = get_parent_class($class));
|
||||
|
||||
$config = $this->registerTraitsRecursive($traits);
|
||||
$this->_ci->addMeta('test', $config);
|
||||
}
|
||||
|
||||
private function registerTraitsRecursive($traits)
|
||||
{
|
||||
// TODO(chris): implement
|
||||
$children = [];
|
||||
foreach ($traits as $name => $trait) {
|
||||
$traitId = ucfirst(str_replace("Trait", "", $name));
|
||||
$initMethod = "init" . $traitId;
|
||||
$this->_ci->addMeta('traits', $initMethod);
|
||||
$child = $this->$initMethod();
|
||||
if (!isset($child['alias']))
|
||||
$child['alias'] = strtolower($traitId);
|
||||
$children[$child['alias']] = $child;
|
||||
$childTraits = class_uses($trait);
|
||||
$children[$child['alias']]['children'] = $this->registerTraits($childTraits);
|
||||
}
|
||||
return $children;
|
||||
}*/
|
||||
|
||||
// TODO(chris): abstract
|
||||
|
||||
final protected function getPathTemplate($path)
|
||||
{
|
||||
return implode('/', $path) . '/%s';
|
||||
}
|
||||
|
||||
protected function getLinkTemplate($path, $vars)
|
||||
{
|
||||
return implode('/', $path) . '/%s';
|
||||
}
|
||||
|
||||
protected function buildMenu()
|
||||
{
|
||||
return $this->buildMenuRecursive($this->children, [], []);
|
||||
}
|
||||
|
||||
private function buildMenuRecursive($children, $identifiers, $path)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($children as $key => $segment) {
|
||||
$node_config = $this->getNodeConfig($key, $segment);
|
||||
|
||||
$nodes = $this->buildNode($node_config, $segment, $identifiers, $path);
|
||||
|
||||
foreach ($nodes as $k => $node) {
|
||||
// Convert stdClass to array
|
||||
if (!is_array($node))
|
||||
$node = get_object_vars($node);
|
||||
|
||||
// Render children
|
||||
if (isset($node_config['children'])) {
|
||||
$node_path = explode('/', $node['path']);
|
||||
|
||||
$node_identifiers = $identifiers;
|
||||
if (isset($node_config['identifiers'])) {
|
||||
if (is_string($node_config['identifiers'])) {
|
||||
$reflection = new ReflectionMethod($this, $node_config['identifiers']);
|
||||
$num_segments = $reflection->getNumberOfParameters();
|
||||
$parameters = array_slice($node_path, $num_segments * -1);
|
||||
$node_identifiers = call_user_func_array([$this, $node_config['identifiers']], $parameters);
|
||||
$node_identifiers = array_merge($identifiers, $node_identifiers);
|
||||
} else {
|
||||
if (count($node_path) < count($node_config['identifiers']))
|
||||
return null; // NOTE(chris): wrong number of url segments
|
||||
|
||||
foreach ($node_config['identifiers'] as $index => $id_name) {
|
||||
$pos = count($node_path) - count($node_config['identifiers']) + $index;
|
||||
$node_identifiers[$id_name] = $node_path[$pos];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$node['children'] = $this->buildMenuRecursive($node_config['children'], $node_identifiers, $node_path);
|
||||
} else {
|
||||
$node['leaf'] = true;
|
||||
}
|
||||
$nodes[$k] = $node;
|
||||
}
|
||||
|
||||
$result = array_merge($result, $nodes);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
final protected function getNodeConfig($key, $segment)
|
||||
{
|
||||
$traitname = is_int($key) ? $segment : $key;
|
||||
$initFunc = 'init' . ucfirst($traitname);
|
||||
|
||||
// TODO(chris): check identifiers string: single or function??
|
||||
|
||||
return $this->$initFunc();
|
||||
}
|
||||
|
||||
private function buildNode($config, $segment, $identifiers, $path)
|
||||
{// TODO(chris): why slash at beginning: "/inout"
|
||||
if (isset($config['build'])) {
|
||||
$buildFunc = $config['build'];
|
||||
$path[] = $segment;
|
||||
$pathTemplate = $this->getPathTemplate($path);
|
||||
$linkTemplate = $this->getLinkTemplate($path, $identifiers);
|
||||
return $this->$buildFunc($identifiers, $pathTemplate, $linkTemplate);
|
||||
} else {
|
||||
return $this->buildGenericItem($segment, $config, $identifiers, $path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $url_segments
|
||||
* @return array|null
|
||||
*/
|
||||
protected function buildSubmenu($url_segments)
|
||||
{
|
||||
$children = $this->children;
|
||||
$original_path = $url_segments;
|
||||
|
||||
$segment = '';
|
||||
$identifiers = [];
|
||||
$config = [];
|
||||
|
||||
while(count($url_segments)) {
|
||||
$segment = array_shift($url_segments);
|
||||
$key = array_search($segment, $children);
|
||||
if ($key === false)
|
||||
return []; // NOTE(chris): node not found
|
||||
|
||||
$config = $this->getNodeConfig($key, $segment);
|
||||
|
||||
if (!isset($config['build']) && !isset($config['name']))
|
||||
return null; // TODO(chris): invalid config
|
||||
|
||||
if (isset($config['identifiers'])) {
|
||||
if (is_string($config['identifiers'])) {
|
||||
$reflection = new ReflectionMethod($this, $config['identifiers']);
|
||||
$num_segments = $reflection->getNumberOfParameters();
|
||||
$parameters = array_slice($url_segments, 0, $num_segments);
|
||||
$url_segments = array_slice($url_segments, $num_segments);
|
||||
$new_identifiers = call_user_func_array([$this, $config['identifiers']], $parameters);
|
||||
$identifiers = array_merge($identifiers, $new_identifiers);
|
||||
} else {
|
||||
if (count($url_segments) < count($config['identifiers']))
|
||||
return null; // NOTE(chris): wrong number of url segments
|
||||
|
||||
foreach ($config['identifiers'] as $id_name) {
|
||||
$identifiers[$id_name] = array_shift($url_segments);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($config['children'])) {
|
||||
$children = $config['children'];
|
||||
} elseif (count($url_segments)) {
|
||||
return null; // NOTE(chris): wrong number of url segments
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($children as $key => $segment) {
|
||||
$node_config = $this->getNodeConfig($key, $segment);
|
||||
$nodes = $this->buildNode($node_config, $segment, $identifiers, $original_path);
|
||||
|
||||
$result = array_merge($result, $nodes);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function buildGenericItem($segment, $config, $identifiers, $path)
|
||||
{
|
||||
$vars = isset($config['vars']) ? $config['vars'] : [];
|
||||
|
||||
$vars = array_merge($identifiers, $vars);
|
||||
|
||||
$vars['name'] = $config['name'];
|
||||
|
||||
if (!isset($config['children']))
|
||||
$vars['leaf'] = true;
|
||||
|
||||
$vars['path'] = sprintf($this->getPathTemplate($path), $segment);
|
||||
$vars['link'] = sprintf($this->getLinkTemplate($path, $vars), $segment);
|
||||
|
||||
return [ $vars ];
|
||||
}
|
||||
}
|
||||
@@ -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';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?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');
|
||||
require_once(APPPATH . 'traits/menu/InoutTrait.php');
|
||||
|
||||
use \ReflectionMethod as ReflectionMethod;
|
||||
|
||||
/**
|
||||
* StudVw Menu library
|
||||
*/
|
||||
class StvMenuLib extends MenuBuilderLib
|
||||
{
|
||||
use StgTrait, InoutTrait;
|
||||
|
||||
protected $children = [
|
||||
'stg',
|
||||
'inout'
|
||||
];
|
||||
|
||||
public function build($url_segments = [])
|
||||
{
|
||||
$result = $this->buildSubmenu($url_segments);
|
||||
|
||||
if ($result === null)
|
||||
show_404();
|
||||
|
||||
return $result;
|
||||
}
|
||||
public function buildAll()
|
||||
{
|
||||
return $this->buildMenu();
|
||||
}
|
||||
|
||||
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 [];
|
||||
}
|
||||
|
||||
if (!strpos($result, '/prestudent') && !isset($vars['no_sem_reload']))
|
||||
$result = 'CURRENT_SEMESTER/' . $result;
|
||||
|
||||
return $result . '%s';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
trait InoutTrait
|
||||
{
|
||||
protected function initInout()
|
||||
{
|
||||
return [
|
||||
'children' => [
|
||||
'incoming',
|
||||
'outgoing',
|
||||
'SharedStudies' => 'shared_studies'
|
||||
],
|
||||
'name' => 'International' // TODO(chris): translate
|
||||
];
|
||||
}
|
||||
|
||||
protected function initIncoming()
|
||||
{
|
||||
return [
|
||||
'name' => 'Incoming' // TODO(chris): translate
|
||||
];
|
||||
}
|
||||
|
||||
protected function initOutgoing()
|
||||
{
|
||||
return [
|
||||
'name' => 'Outgoing' // TODO(chris): translate
|
||||
];
|
||||
}
|
||||
|
||||
protected function initSharedStudies()
|
||||
{
|
||||
return [
|
||||
'name' => 'Gemeinsame Studien' // TODO(chris): translate
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?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 . 'traits/menu/Stg/PrestudentTrait.php');
|
||||
require_once(APPPATH . 'traits/menu/Stg/SemesterTrait.php');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
trait OrgformTrait
|
||||
{
|
||||
use PrestudentTrait, SemesterTrait;
|
||||
|
||||
protected function initOrgform()
|
||||
{
|
||||
return [
|
||||
'children' => ['prestudent', 'semester'],
|
||||
'identifiers' => ['orgform_kurzbz'],
|
||||
'build' => 'getOrgform'
|
||||
];
|
||||
}
|
||||
|
||||
protected function getOrgform($vars, $pathTemplate, $linkTemplate)
|
||||
{
|
||||
// TODO(chris): permission on stg
|
||||
// TODO(chris): check vars
|
||||
|
||||
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
|
||||
// NOTE(chris): if mischform show orgforms
|
||||
$result = $this->_ci->StudiengangModel->load($vars['studiengang_kz']);
|
||||
|
||||
if (!hasData($result))
|
||||
return [];
|
||||
|
||||
$stg = current(getData($result));
|
||||
|
||||
if (!$stg->mischform)
|
||||
return [];
|
||||
|
||||
$this->_ci->load->model('organisation/Studienordnung_model', 'StudienordnungModel');
|
||||
|
||||
$this->_ci->StudienordnungModel->addDistinct();
|
||||
$this->_ci->StudienordnungModel->addSelect("FORMAT(" . $this->_ci->StudienordnungModel->escape($pathTemplate) . ", p.orgform_kurzbz) AS path");
|
||||
$this->_ci->StudienordnungModel->addSelect("FORMAT(" . $this->_ci->StudienordnungModel->escape($linkTemplate) . ", p.orgform_kurzbz) AS link");
|
||||
$this->_ci->StudienordnungModel->addSelect("p.orgform_kurzbz AS name");
|
||||
$this->_ci->StudienordnungModel->addSelect("studiengang_kz AS stg_kz");
|
||||
|
||||
$this->_ci->StudienordnungModel->addJoin('lehre.tbl_studienplan p', 'studienordnung_id');
|
||||
|
||||
$result = $this->_ci->StudienordnungModel->loadWhere([
|
||||
'aktiv' => true,
|
||||
'studiengang_kz' => $vars['studiengang_kz'],
|
||||
'p.orgform_kurzbz !=' => 'DDP'
|
||||
]);
|
||||
|
||||
return getData($result) ?: [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
<?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');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
trait StdsemFilterTrait
|
||||
{
|
||||
protected function initInteressenten()
|
||||
{
|
||||
return [
|
||||
'children' => [
|
||||
'bewebungnichtabgeschickt',
|
||||
'bewerbungabgeschickt',
|
||||
'zgv',
|
||||
'statusbestaetigt',
|
||||
'reihungstestnichtangemeldet',
|
||||
'reihungstestangemeldet'
|
||||
],
|
||||
'name' => 'Interessenten'
|
||||
];
|
||||
}
|
||||
|
||||
protected function initBewebungnichtabgeschickt()
|
||||
{
|
||||
return [ 'name' => 'Bewerbung nicht abgeschickt' ];
|
||||
}
|
||||
|
||||
protected function initBewerbungabgeschickt()
|
||||
{
|
||||
return [ 'name' => 'Bewerbung abgeschickt, Status unbestätigt' ];
|
||||
}
|
||||
|
||||
protected function initZgv()
|
||||
{
|
||||
return [ 'name' => 'ZGV erfüllt' ];
|
||||
}
|
||||
|
||||
protected function initStatusbestaetigt()
|
||||
{
|
||||
return [
|
||||
'children' => [
|
||||
'statusbestaetigtrtnichtangemeldet',
|
||||
'statusbestaetigtrtangemeldet'
|
||||
],
|
||||
'name' => 'Status bestätigt'
|
||||
];
|
||||
}
|
||||
|
||||
protected function initStatusbestaetigtrtnichtangemeldet()
|
||||
{
|
||||
return [ 'name' => 'Nicht zum Reihungstest angemeldet' ];
|
||||
}
|
||||
|
||||
protected function initStatusbestaetigtrtangemeldet()
|
||||
{
|
||||
return [ 'name' => 'Reihungstest angemeldet' ];
|
||||
}
|
||||
|
||||
protected function initReihungstestnichtangemeldet()
|
||||
{
|
||||
return [ 'name' => 'Nicht zum Reihungstest angemeldet' ];
|
||||
}
|
||||
|
||||
protected function initReihungstestangemeldet()
|
||||
{
|
||||
return [ 'name' => 'Reihungstest angemeldet' ];
|
||||
}
|
||||
|
||||
protected function initBewerber()
|
||||
{
|
||||
return [
|
||||
'children' => [
|
||||
'bewerberrtnichtangemeldet',
|
||||
'bewerberrtangemeldet'
|
||||
],
|
||||
'name' => 'Bewerber'
|
||||
];
|
||||
}
|
||||
|
||||
protected function initBewerberrtnichtangemeldet()
|
||||
{
|
||||
return [ 'name' => 'Nicht zum Reihungstest angemeldet' ];
|
||||
}
|
||||
|
||||
protected function initBewerberrtangemeldet()
|
||||
{
|
||||
return [
|
||||
'children' => [
|
||||
'bewerberrtangemeldetteilgenommen',
|
||||
'bewerberrtangemeldetnichtteilgenommen'
|
||||
],
|
||||
'name' => 'Reihungstest angemeldet'
|
||||
];
|
||||
}
|
||||
|
||||
protected function initBewerberrtangemeldetteilgenommen()
|
||||
{
|
||||
return [ 'name' => 'Teilgenommen' ];
|
||||
}
|
||||
|
||||
protected function initBewerberrtangemeldetnichtteilgenommen()
|
||||
{
|
||||
return [ 'name' => 'Nicht teilgenommen' ];
|
||||
}
|
||||
|
||||
protected function initAufgenommen()
|
||||
{
|
||||
return [ 'name' => 'Aufgenommen' ];
|
||||
}
|
||||
|
||||
protected function initWarteliste()
|
||||
{
|
||||
return [ 'name' => 'Warteliste' ];
|
||||
}
|
||||
|
||||
protected function initAbsage()
|
||||
{
|
||||
return [ 'name' => 'Absage' ];
|
||||
}
|
||||
|
||||
protected function initFilterIncoming()
|
||||
{
|
||||
return [ 'name' => 'Incoming' ];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?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 . 'traits/menu/Stg/Prestudent/Stdsem/StdsemFilterTrait.php');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
trait StdsemTrait
|
||||
{
|
||||
use StdsemFilterTrait;
|
||||
|
||||
protected function initStdsem()
|
||||
{
|
||||
return [
|
||||
'children' => [
|
||||
'interessenten',
|
||||
'bewerber',
|
||||
'aufgenommen',
|
||||
'warteliste',
|
||||
'absage',
|
||||
'filterIncoming' => 'incoming'
|
||||
],
|
||||
'identifiers' => ['studiensemester_kurzbz'],
|
||||
'build' => 'getStdsem'
|
||||
];
|
||||
}
|
||||
|
||||
protected function getStdsem($vars, $pathTemplate, $linkTemplate)
|
||||
{
|
||||
// TODO(chris): permission on stg
|
||||
// TODO(chris): check vars
|
||||
|
||||
$number_displayed_past_studiensemester = null;
|
||||
|
||||
$this->_ci->load->model('system/Variable_model', 'VariableModel');
|
||||
|
||||
$result = $this->_ci->VariableModel->getVariables(getAuthUID(), ['number_displayed_past_studiensemester']);
|
||||
if (isError($result))
|
||||
return [];
|
||||
|
||||
$data = getData($result);
|
||||
if ($data && isset($data['number_displayed_past_studiensemester'])) {
|
||||
$number_displayed_past_studiensemester = $data['number_displayed_past_studiensemester'];
|
||||
} else {
|
||||
$this->_ci->load->config('stv');
|
||||
$number_displayed_past_studiensemester = $this->_ci->config->item('number_displayed_past_studiensemester_default');
|
||||
}
|
||||
|
||||
$this->_ci->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
$this->_ci->StudiensemesterModel->addPlusMinus(null, $number_displayed_past_studiensemester);
|
||||
|
||||
$this->_ci->StudiensemesterModel->addSelect("studiensemester_kurzbz AS name");
|
||||
$this->_ci->StudiensemesterModel->addSelect("FORMAT(" . $this->_ci->StudiensemesterModel->escape($pathTemplate) . ", studiensemester_kurzbz) AS path", false);
|
||||
$this->_ci->StudiensemesterModel->addSelect("FORMAT(" . $this->_ci->StudiensemesterModel->escape($linkTemplate) . ", studiensemester_kurzbz) AS link", false);
|
||||
$this->_ci->StudiensemesterModel->addSelect($this->_ci->StudiensemesterModel->escape($vars['studiengang_kz']) . " AS stg_kz", false);
|
||||
|
||||
$this->_ci->StudiensemesterModel->addOrder('ende');
|
||||
|
||||
$result = $this->_ci->StudiensemesterModel->load();
|
||||
|
||||
return getData($result) ?: [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?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 . 'traits/menu/Stg/Prestudent/StdsemTrait.php');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
trait PrestudentTrait
|
||||
{
|
||||
use StdsemTrait;
|
||||
|
||||
protected function initPrestudent()
|
||||
{
|
||||
$name = 'Prestudent'; // TODO(chris): translate
|
||||
|
||||
return [
|
||||
'children' => [ 'stdsem' ],
|
||||
'name' => $name,
|
||||
'vars' => [
|
||||
'no_sem_reload' => true
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?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');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
trait GroupTrait
|
||||
{
|
||||
protected function initGroup()
|
||||
{
|
||||
return [
|
||||
'identifiers' => ['gruppe_kurzbz'],
|
||||
'build' => 'getGroup'
|
||||
];
|
||||
}
|
||||
|
||||
protected function getGroup($vars, $pathTemplate, $linkTemplate)
|
||||
{
|
||||
// TODO(chris): permission on stg
|
||||
// TODO(chris): check vars
|
||||
|
||||
$this->_ci->load->model('organisation/Gruppe_model', 'GruppeModel');
|
||||
|
||||
$this->_ci->GruppeModel->addDistinct();
|
||||
$this->_ci->GruppeModel->addSelect("FORMAT(" . $this->_ci->GruppeModel->escape($pathTemplate) . ", gruppe_kurzbz) AS path", false);
|
||||
$this->_ci->GruppeModel->addSelect("FORMAT(" . $this->_ci->GruppeModel->escape($linkTemplate) . ", gruppe_kurzbz) AS link", false);
|
||||
$this->_ci->GruppeModel->addSelect("CONCAT(gruppe_kurzbz, ' (', bezeichnung, ')') AS name", false);
|
||||
$this->_ci->GruppeModel->addSelect("TRUE AS leaf", false);
|
||||
|
||||
$this->_ci->GruppeModel->addSelect('sort');
|
||||
$this->_ci->GruppeModel->addSelect('gruppe_kurzbz');
|
||||
$this->_ci->GruppeModel->addSelect($this->_ci->GruppeModel->escape($vars['studiengang_kz']) . '::integer AS stg_kz', false);
|
||||
$this->_ci->GruppeModel->addSelect("ARRAY['link-strict', 'student-collection'] AS droplink");
|
||||
|
||||
$this->_ci->GruppeModel->addOrder('sort');
|
||||
$this->_ci->GruppeModel->addOrder('gruppe_kurzbz');
|
||||
|
||||
$where = [
|
||||
'studiengang_kz' => $vars['studiengang_kz'],
|
||||
'semester' => $vars['semester'],
|
||||
'lehre' => true,
|
||||
'sichtbar' => true,
|
||||
'aktiv' => true,
|
||||
'direktinskription' => false
|
||||
];
|
||||
|
||||
if (isset($vars['org_form']))
|
||||
$where['orgform_kurzbz'] = $vars['org_form'];
|
||||
|
||||
$result = $this->_ci->GruppeModel->loadWhere($where);
|
||||
|
||||
return getData($result) ?: [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?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');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
trait VerbandsGroupTrait
|
||||
{
|
||||
protected function initVerbandsGroup()
|
||||
{
|
||||
return [
|
||||
'identifiers' => ['group'],
|
||||
'build' => 'getVerbandsGroup'
|
||||
];
|
||||
}
|
||||
|
||||
protected function getVerbandsGroup($vars, $pathTemplate, $linkTemplate)
|
||||
{
|
||||
// TODO(chris): permission on stg
|
||||
// TODO(chris): check vars
|
||||
|
||||
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
|
||||
$this->_ci->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz');
|
||||
|
||||
$this->_ci->StudiengangModel->addDistinct();
|
||||
$this->_ci->StudiengangModel->addSelect("FORMAT(" . $this->_ci->StudiengangModel->escape($pathTemplate) . ", gruppe) AS path", false);
|
||||
$this->_ci->StudiengangModel->addSelect("FORMAT(" . $this->_ci->StudiengangModel->escape($linkTemplate) . ", gruppe) AS link", false);
|
||||
$this->_ci->StudiengangModel->addSelect("CONCAT(UPPER(CONCAT(typ, kurzbz)), '-', semester, verband, gruppe, (SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END FROM public.tbl_lehrverband WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester AND verband=v.verband AND gruppe=v.gruppe ORDER BY gruppe LIMIT 1)) AS name", false);
|
||||
$this->_ci->StudiengangModel->addSelect("TRUE AS leaf", false);
|
||||
|
||||
$this->_ci->StudiengangModel->addSelect('v.semester');
|
||||
$this->_ci->StudiengangModel->addSelect('v.verband');
|
||||
$this->_ci->StudiengangModel->addSelect('gruppe');
|
||||
$this->_ci->StudiengangModel->addSelect($this->_ci->StudiengangModel->escape($vars['studiengang_kz']) . '::integer AS stg_kz', false);
|
||||
$this->_ci->StudiengangModel->addSelect("ARRAY['link-strict', 'student-collection'] AS droplink");
|
||||
|
||||
$this->_ci->StudiengangModel->addOrder('gruppe');
|
||||
|
||||
$where = [
|
||||
'v.studiengang_kz' => $vars['studiengang_kz'],
|
||||
'v.semester' => $vars['semester'],
|
||||
'v.verband' => $vars['verband'],
|
||||
'v.gruppe !=' => '',
|
||||
'v.aktiv' => true
|
||||
];
|
||||
|
||||
if (isset($vars['org_form']) && $vars['semester']) // NOTE(chris): on semester 0 show all?
|
||||
$where['v.orgform_kurzbz'] = $vars['org_form'];
|
||||
|
||||
$result = $this->_ci->StudiengangModel->loadWhere($where);
|
||||
|
||||
return getData($result) ?: [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?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 . 'traits/menu/Stg/Semester/Verband/VerbandsGroupTrait.php');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
trait VerbandTrait
|
||||
{
|
||||
use VerbandsGroupTrait;
|
||||
|
||||
protected function initVerband()
|
||||
{
|
||||
return [
|
||||
'children' => ['VerbandsGroup' => 'group'],
|
||||
'identifiers' => ['verband'],
|
||||
'build' => 'getVerband'
|
||||
];
|
||||
}
|
||||
|
||||
protected function getVerband($vars, $pathTemplate, $linkTemplate)
|
||||
{
|
||||
// TODO(chris): permission on stg
|
||||
// TODO(chris): check vars
|
||||
|
||||
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
|
||||
$this->_ci->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz');
|
||||
|
||||
$this->_ci->StudiengangModel->addSelect("FORMAT(" . $this->_ci->StudiengangModel->escape($pathTemplate) . ", verband) AS path", false);
|
||||
$this->_ci->StudiengangModel->addSelect("FORMAT(" . $this->_ci->StudiengangModel->escape($linkTemplate) . ", verband) AS link", false);
|
||||
$this->_ci->StudiengangModel->addSelect("CONCAT(UPPER(CONCAT(typ, kurzbz)), '-', semester, verband, (SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END FROM public.tbl_lehrverband WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester AND verband=v.verband ORDER BY gruppe LIMIT 1)) AS name", false);
|
||||
$this->_ci->StudiengangModel->addSelect("CASE WHEN MAX(gruppe)='' OR MAX(gruppe)=' ' THEN TRUE ELSE FALSE END AS leaf");
|
||||
|
||||
$this->_ci->StudiengangModel->addSelect($this->_ci->StudiengangModel->escape($vars['semester']) . ' AS semester');
|
||||
$this->_ci->StudiengangModel->addSelect('verband');
|
||||
$this->_ci->StudiengangModel->addSelect($this->_ci->StudiengangModel->escape($vars['studiengang_kz']) . '::integer AS stg_kz', false);
|
||||
$this->_ci->StudiengangModel->addSelect("ARRAY['link-strict', 'student-collection'] AS droplink");
|
||||
|
||||
$this->_ci->StudiengangModel->addOrder('verband');
|
||||
|
||||
$this->_ci->StudiengangModel->addGroupBy('path, link, name, verband');
|
||||
|
||||
$where = [
|
||||
'v.studiengang_kz' => $vars['studiengang_kz'],
|
||||
'v.semester' => $vars['semester'],
|
||||
'v.verband !=' => '',
|
||||
'v.aktiv' => true
|
||||
];
|
||||
|
||||
if (isset($vars['org_form']) && $vars['semester']) // NOTE(chris): on semester 0 show all?
|
||||
$where['v.orgform_kurzbz'] = $vars['org_form'];
|
||||
|
||||
$result = $this->_ci->StudiengangModel->loadWhere($where);
|
||||
|
||||
return getData($result) ?: [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?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 . 'traits/menu/Stg/Semester/GroupTrait.php');
|
||||
require_once(APPPATH . 'traits/menu/Stg/Semester/VerbandTrait.php');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
trait SemesterTrait
|
||||
{
|
||||
use GroupTrait, VerbandTrait;
|
||||
|
||||
protected function initSemester()
|
||||
{
|
||||
return [
|
||||
'children' => ['group', 'verband'],
|
||||
'identifiers' => ['semester'],
|
||||
'build' => 'getSemester'
|
||||
];
|
||||
}
|
||||
|
||||
protected function getSemester($vars, $pathTemplate, $linkTemplate)
|
||||
{
|
||||
// TODO(chris): permission on stg
|
||||
// TODO(chris): check vars
|
||||
|
||||
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
|
||||
$this->_ci->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz');
|
||||
|
||||
$this->_ci->StudiengangModel->addDistinct();
|
||||
$this->_ci->StudiengangModel->addSelect("FORMAT(" . $this->_ci->StudiengangModel->escape($pathTemplate) . ", semester) AS path", false);
|
||||
$this->_ci->StudiengangModel->addSelect("FORMAT(" . $this->_ci->StudiengangModel->escape($linkTemplate) . ", semester) AS link", false);
|
||||
$this->_ci->StudiengangModel->addSelect("CONCAT(
|
||||
UPPER(CONCAT(typ, kurzbz)),
|
||||
'-',
|
||||
semester,
|
||||
(
|
||||
SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END
|
||||
FROM public.tbl_lehrverband
|
||||
WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester
|
||||
ORDER BY verband, gruppe LIMIT 1
|
||||
)
|
||||
) AS name", false);
|
||||
|
||||
$this->_ci->StudiengangModel->addSelect('semester');
|
||||
$this->_ci->StudiengangModel->addSelect($this->_ci->StudiengangModel->escape($vars['studiengang_kz']) . '::integer AS stg_kz', false);
|
||||
$this->_ci->StudiengangModel->addSelect("ARRAY['link-strict', 'student-collection'] AS droplink");
|
||||
|
||||
$this->_ci->StudiengangModel->addOrder('semester');
|
||||
|
||||
if (isset($vars['org_form'])) {
|
||||
$this->_ci->StudiengangModel->addSelect("v.orgform_kurzbz");
|
||||
$this->_ci->StudiengangModel->db->group_start();
|
||||
$this->_ci->StudiengangModel->db->where('v.semester', 0);
|
||||
$this->_ci->StudiengangModel->db->or_where('v.orgform_kurzbz', $vars['org_form']);
|
||||
$this->_ci->StudiengangModel->db->group_end();
|
||||
}
|
||||
|
||||
$result = $this->_ci->StudiengangModel->loadWhere([
|
||||
'v.studiengang_kz' => $vars['studiengang_kz'],
|
||||
'v.aktiv' => true
|
||||
]);
|
||||
|
||||
return getData($result) ?: [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?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 . 'traits/menu/Stg/PrestudentTrait.php');
|
||||
require_once(APPPATH . 'traits/menu/Stg/SemesterTrait.php');
|
||||
require_once(APPPATH . 'traits/menu/Stg/OrgformTrait.php');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
trait StgTrait
|
||||
{
|
||||
use OrgformTrait;
|
||||
|
||||
protected function initStg()
|
||||
{
|
||||
// TODO(chris): like this or with functions???
|
||||
return [
|
||||
// children as assoc array to rename them
|
||||
'children' => ['prestudent', 'semester', 'orgform'],
|
||||
#'identifiers' => 'getIdentifiersStg',
|
||||
'identifiers' => ['studiengang_kz'],
|
||||
'build' => 'getStg'
|
||||
];
|
||||
}
|
||||
|
||||
protected function getStg($vars, $pathTemplate, $linkTemplate)
|
||||
{
|
||||
$stgs = $this->_ci->permissionlib->getSTG_isEntitledFor('admin') ?: [];
|
||||
$stgs = array_merge($stgs, $this->_ci->permissionlib->getSTG_isEntitledFor('assistenz') ?: []);
|
||||
|
||||
if (!$stgs)
|
||||
return [];
|
||||
|
||||
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
|
||||
$this->_ci->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz');
|
||||
|
||||
$this->_ci->StudiengangModel->addDistinct();
|
||||
$this->_ci->StudiengangModel->addSelect("FORMAT(" . $this->_ci->StudiengangModel->escape($pathTemplate) . ", v.studiengang_kz) AS path");
|
||||
$this->_ci->StudiengangModel->addSelect("FORMAT(" . $this->_ci->StudiengangModel->escape($linkTemplate) . ", v.studiengang_kz) AS link");
|
||||
$this->_ci->StudiengangModel->addSelect(
|
||||
"CONCAT(kurzbzlang, ' (', UPPER(CONCAT(typ, kurzbz)), ') - ', tbl_studiengang.bezeichnung) AS name",
|
||||
false
|
||||
);
|
||||
$this->_ci->StudiengangModel->addSelect("studiengang_kz AS title");
|
||||
$this->_ci->StudiengangModel->addSelect("studiengang_kz AS search");
|
||||
$this->_ci->StudiengangModel->addSelect('erhalter_kz');
|
||||
$this->_ci->StudiengangModel->addSelect('typ');
|
||||
$this->_ci->StudiengangModel->addSelect('kurzbz');
|
||||
$this->_ci->StudiengangModel->addSelect('studiengang_kz');
|
||||
$this->_ci->StudiengangModel->addSelect('studiengang_kz AS stg_kz');
|
||||
|
||||
$this->_ci->StudiengangModel->addOrder('erhalter_kz');
|
||||
$this->_ci->StudiengangModel->addOrder('typ');
|
||||
$this->_ci->StudiengangModel->addOrder('kurzbz');
|
||||
|
||||
$this->_ci->StudiengangModel->db->where_in('studiengang_kz', $stgs);
|
||||
|
||||
$result = $this->_ci->StudiengangModel->loadWhere(['v.aktiv' => true]);
|
||||
|
||||
return getData($result) ?: [];
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2025 fhcomplete.org
|
||||
* 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
|
||||
@@ -16,15 +16,13 @@
|
||||
*/
|
||||
|
||||
export default {
|
||||
get(path) {
|
||||
let url = 'api/frontend/v1/stv/verband';
|
||||
if (path)
|
||||
url += '/' + path;
|
||||
get(config, path = '') {
|
||||
return {
|
||||
method: 'get',
|
||||
url
|
||||
url: '/api/frontend/v1/menu/' + config + '/' + path
|
||||
};
|
||||
},
|
||||
// TODO(chris): handle favorites per config
|
||||
favorites: {
|
||||
get() {
|
||||
return {
|
||||
@@ -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,
|
||||
|
||||
@@ -0,0 +1,362 @@
|
||||
import MenuEntry from './Menu/Entry.js';
|
||||
|
||||
import dragClick from '../../directives/dragClick.js';
|
||||
|
||||
import ApiMenu from '../../api/factory/menu.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
PvTreetable: primevue.treetable,
|
||||
PvColumn: primevue.column,
|
||||
MenuEntry
|
||||
},
|
||||
directives: {
|
||||
dragClick
|
||||
},
|
||||
emits: [
|
||||
'selectEntry',
|
||||
'drop'
|
||||
],
|
||||
props: {
|
||||
config: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
preselectedKey: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: true,
|
||||
nodes: [],
|
||||
selectedKey: [],
|
||||
expandedKeys: {},
|
||||
filters: {}, // TODO(chris): filter only 1st level?
|
||||
favorites: {on: false, list: []}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
filteredNodes() {
|
||||
if (this.favorites.on)
|
||||
return this.nodes.filter(node => this.favorites.list.includes(node.data.path));
|
||||
|
||||
return this.nodes;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
preselectedKey(newVal, oldVal) {
|
||||
if (newVal !== oldVal) {
|
||||
this.setPreselection();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
reloadNodesWithProp(prop, nodes = undefined) {
|
||||
if (!nodes)
|
||||
nodes = this.nodes;
|
||||
|
||||
nodes.forEach(node => {
|
||||
if (node.data[prop]) {
|
||||
// reload
|
||||
delete node.children;
|
||||
this.onExpandTreeNode(node);
|
||||
} else if (node.children) {
|
||||
this.reloadNodesWithProp(prop, node.children);
|
||||
}
|
||||
});
|
||||
},
|
||||
findNodeByKey(key, arr) {
|
||||
if (!arr)
|
||||
arr = this.nodes;
|
||||
let res = arr.filter(n => n.key == key);
|
||||
if (res.length)
|
||||
return res.pop();
|
||||
res = arr.map(n => n.children ? this.findNodeByKey(key, n.children) : null).filter(a => a);
|
||||
if (res.length)
|
||||
return res.pop();
|
||||
return null;
|
||||
},
|
||||
async onExpandTreeNode(node) {
|
||||
if (!node.children) {
|
||||
if (node.data.path) {
|
||||
/**
|
||||
* NOTE(chris): activeEl is for keyboard navigation to
|
||||
* prevent the focus jumping down to the next parent
|
||||
* instead of the current submenu entry (which is not yet
|
||||
* loaded)
|
||||
*/
|
||||
let activeEl = null;
|
||||
this.$nextTick(() => {
|
||||
this.$nextTick(() => {
|
||||
activeEl = document.activeElement;
|
||||
});
|
||||
});
|
||||
this.loading = true;
|
||||
|
||||
return this.$api
|
||||
.call(ApiMenu.get(this.config, node.data.path))
|
||||
.then(result => {
|
||||
const subNodes = result.data.map(this.mapResultToTreeData);
|
||||
const realNode = this.findNodeByKey(node.key);
|
||||
if (realNode)
|
||||
realNode.children = subNodes;
|
||||
else
|
||||
node.children = subNodes; // NOTE(chris): fallback should never be the case
|
||||
|
||||
this.$nextTick(() => {
|
||||
if (activeEl != document.activeElement)
|
||||
return;
|
||||
|
||||
let treeitem = this.$refs.tree.$el.querySelector('[data-tree-item-key="' + node.key + '"]');
|
||||
if (!treeitem)
|
||||
return;
|
||||
|
||||
treeitem = treeitem.closest('[role="row"]');
|
||||
|
||||
if (!treeitem)
|
||||
return;
|
||||
|
||||
treeitem.dispatchEvent(new KeyboardEvent('keydown', {
|
||||
code: 'ArrowDown',
|
||||
key: 'ArrowDown'
|
||||
}));
|
||||
});
|
||||
|
||||
this.loading = false;
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
}
|
||||
}
|
||||
},
|
||||
onSelectTreeNode(node) {
|
||||
this.$emit('selectEntry', node.data);
|
||||
},
|
||||
mapNodesToNoSemReloadNodes(result, node) {
|
||||
if (node.data.no_sem_reload)
|
||||
result.push(node);
|
||||
if (node.children)
|
||||
result = node.children.reduce(this.mapNodesToNoSemReloadNodes, result);
|
||||
return result;
|
||||
},
|
||||
mapResultToTreeData(el) {
|
||||
const cp = {
|
||||
key: ("" + el.path).replace(/\//g, '-'),
|
||||
data: el,
|
||||
label: el.name // TODO(chris): phrase
|
||||
};
|
||||
|
||||
if (el.children)
|
||||
cp.children = el.children.map(this.mapResultToTreeData);
|
||||
else
|
||||
cp.leaf = el.leaf || false;
|
||||
|
||||
return cp;
|
||||
},
|
||||
async setPreselection()
|
||||
{
|
||||
if (!this.preselectedKey)
|
||||
{
|
||||
this.selectedKey = null;
|
||||
return;
|
||||
}
|
||||
|
||||
let rawKey = this.preselectedKey
|
||||
|
||||
if (!rawKey || typeof rawKey !== 'string')
|
||||
return;
|
||||
|
||||
const parts = this.preselectedKey.split('/');
|
||||
let currentKey = parts[0];
|
||||
let currentNode = this.findNodeByKey(currentKey);
|
||||
|
||||
if (!currentNode)
|
||||
return;
|
||||
|
||||
if(this.selectedKey)
|
||||
{
|
||||
const currentSelectedKey = Object.keys(this.selectedKey).find(Boolean);
|
||||
if (currentSelectedKey) {
|
||||
if (currentSelectedKey == currentKey)
|
||||
return;
|
||||
/**
|
||||
* Do not select a new entry if the current is a child of the new one.
|
||||
* This happens if a child entry of a new stg is selected and the router
|
||||
* tries to select the stg root entry (because subtrees do not have
|
||||
* routes yet)
|
||||
*/
|
||||
const isChild = this.findNodeByKey(
|
||||
currentSelectedKey,
|
||||
currentNode.children || []
|
||||
);
|
||||
if (isChild)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 1; i < parts.length; i++)
|
||||
{
|
||||
this.expandedKeys[currentNode.key] = true;
|
||||
|
||||
await this.onExpandTreeNode(currentNode);
|
||||
|
||||
currentKey += '-' + parts[i];
|
||||
currentNode = this.findNodeByKey(currentKey);
|
||||
|
||||
if (!currentNode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.selectedKey = {[currentNode.key]: true};
|
||||
this.onSelectTreeNode(currentNode);
|
||||
},
|
||||
async toggleTreeNode(node) {
|
||||
if (this.expandedKeys[node.key]) {
|
||||
delete this.expandedKeys[node.key];
|
||||
} else if (!node.leaf) {
|
||||
await this.onExpandTreeNode(node);
|
||||
this.expandedKeys[node.key] = true;
|
||||
}
|
||||
},
|
||||
filterFav() {
|
||||
this.favorites.on = !this.favorites.on;
|
||||
this.$api
|
||||
.call(ApiMenu.favorites.set(
|
||||
JSON.stringify(this.favorites)
|
||||
));
|
||||
},
|
||||
markFav(key) {
|
||||
let index = this.favorites.list.indexOf(key.data.path + '');
|
||||
|
||||
if (index != -1) {
|
||||
this.favorites.list.splice(index, 1);
|
||||
} else {
|
||||
this.favorites.list.push(key.data.path + '');
|
||||
}
|
||||
|
||||
this.$api
|
||||
.call(ApiMenu.favorites.set(
|
||||
JSON.stringify(this.favorites)
|
||||
));
|
||||
},
|
||||
unsetFavFocus(e) {
|
||||
if (e.target.dataset?.linkFavAdd !== undefined) {
|
||||
e.target.tabIndex = -1;
|
||||
} else {
|
||||
let items = e.target.querySelectorAll('[data-link-fav-add]:not([tabindex="-1"])');
|
||||
items.forEach(el => el.tabIndex = document.activeElement == el ? 0 : -1);
|
||||
}
|
||||
},
|
||||
setFavFocus(e) {
|
||||
if (e.target.dataset?.linkFavAdd !== undefined) {
|
||||
e.target.tabIndex = 0;
|
||||
} else {
|
||||
let items = e.target.querySelectorAll('[data-link-fav-add][tabindex="-1"]');
|
||||
items.forEach(el => el.tabIndex = 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$api
|
||||
.call(ApiMenu.get(this.config))
|
||||
.then(result => {
|
||||
this.nodes = result.data.map(el => {
|
||||
el.root = true;
|
||||
return this.mapResultToTreeData(el);
|
||||
});
|
||||
this.setPreselection();
|
||||
this.loading = false;
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
|
||||
this.$api
|
||||
.call(ApiMenu.favorites.get())
|
||||
.then(result => {
|
||||
if (result.data) {
|
||||
this.favorites = JSON.parse(result.data);
|
||||
}
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
template: /* html */`
|
||||
<pv-treetable
|
||||
ref="tree"
|
||||
v-model:expanded-keys="expandedKeys"
|
||||
v-model:selection-keys="selectedKey"
|
||||
class="menu p-treetable-sm"
|
||||
:value="filteredNodes"
|
||||
selection-mode="single"
|
||||
scrollable
|
||||
scroll-height="flex"
|
||||
:filters="filters"
|
||||
@node-expand="onExpandTreeNode"
|
||||
@node-select="onSelectTreeNode"
|
||||
@focusin="setFavFocus"
|
||||
@focusout="unsetFavFocus"
|
||||
>
|
||||
<pv-column
|
||||
field="name"
|
||||
expander
|
||||
class="text-break"
|
||||
>
|
||||
<template #header>
|
||||
<div class="text-right">
|
||||
<div class="p-input-icon-left">
|
||||
<i class="pi pi-search"></i>
|
||||
<input
|
||||
type="text"
|
||||
v-model="filters['global']"
|
||||
class="form-control ps-5"
|
||||
placeholder="Search"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #body="{ node }">
|
||||
<menu-entry
|
||||
:node="node"
|
||||
:data-tree-item-key="node.key"
|
||||
v-drag-click="() => toggleTreeNode(node)"
|
||||
@drop="$emit('drop', $event)"
|
||||
/>
|
||||
</template>
|
||||
</pv-column>
|
||||
<pv-column
|
||||
field="fav"
|
||||
class="flex-shrink-0 flex-grow-0"
|
||||
header-class="flex-shrink-0 flex-grow-0"
|
||||
>
|
||||
<template #header>
|
||||
<a
|
||||
v-if="favorites.on || favorites.list.length"
|
||||
href="#"
|
||||
@click.prevent="filterFav"
|
||||
>
|
||||
<i
|
||||
:class="favorites.on ? 'fa-solid' : 'fa-regular'"
|
||||
class="fa-star"
|
||||
></i>
|
||||
</a>
|
||||
</template>
|
||||
<template #body="{ node }">
|
||||
<a
|
||||
v-if="node.data.root"
|
||||
href="#"
|
||||
tabindex="-1"
|
||||
data-link-fav-add
|
||||
@click.prevent="markFav(node)"
|
||||
@keydown.enter.stop.prevent="markFav(node)"
|
||||
>
|
||||
<i
|
||||
:class="favorites.list.includes(node.data.path + '') ? 'fa-solid' : 'fa-regular'"
|
||||
class="fa-star"
|
||||
></i>
|
||||
</a>
|
||||
</template>
|
||||
</pv-column>
|
||||
<pv-column field="search" class="d-none"></pv-column>
|
||||
</pv-treetable>`
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
import drop from '../../../directives/drop.js';
|
||||
|
||||
export default {
|
||||
directives: {
|
||||
drop
|
||||
},
|
||||
emits: [
|
||||
'drop'
|
||||
],
|
||||
props: {
|
||||
node: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
name() {
|
||||
if (Array.isArray(this.node.data.name))
|
||||
return this.$p.t(this.node.data.name);
|
||||
|
||||
return this.node.data.name;
|
||||
},
|
||||
title() {
|
||||
if (!this.node.data.title)
|
||||
return this.name;
|
||||
|
||||
if (Array.isArray(this.node.data.title))
|
||||
return this.$p.t(this.node.data.title);
|
||||
|
||||
return this.node.data.title;
|
||||
},
|
||||
dropConfig() {
|
||||
if (!this.node.data?.droplink)
|
||||
return null;
|
||||
|
||||
const allowed = [ ...this.node.data.droplink ];
|
||||
const effect = allowed.shift();
|
||||
|
||||
return { effect, allowed };
|
||||
}
|
||||
},
|
||||
template: /* html */`
|
||||
<span
|
||||
class="menu-entry d-flex align-items-center w-100 h-100"
|
||||
:title="title"
|
||||
v-drop:[dropConfig]="(evt, data) => $emit('drop', { drop: node.data, drag: data })"
|
||||
>
|
||||
{{ name }}
|
||||
</span>`
|
||||
};
|
||||
@@ -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: []
|
||||
}
|
||||
},
|
||||
@@ -273,10 +271,10 @@ export default {
|
||||
},
|
||||
onSelectVerband({ link, studiengang_kz, semester, orgform_kurzbz }) {
|
||||
let urlpath = String(link);
|
||||
if (!urlpath.match(/\/prestudent/))
|
||||
/*if (!urlpath.match(/\/prestudent/))
|
||||
{
|
||||
urlpath = 'CURRENT_SEMESTER' + '/' + urlpath;
|
||||
}
|
||||
}*/
|
||||
this.$refs.stvList.updateUrl(ApiStv.students.verband(urlpath));
|
||||
|
||||
this.studiengangKz = studiengang_kz;
|
||||
@@ -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">
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
import drop from '../../../directives/drop.js';
|
||||
import dragClick from '../../../directives/dragClick.js';
|
||||
import BaseMenu from '../../Base/Menu.js';
|
||||
|
||||
import ApiStvGroups from '../../../api/factory/stv/group.js';
|
||||
import ApiStvDetails from '../../../api/factory/stv/details.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
PvTreetable: primevue.treetable,
|
||||
PvColumn: primevue.column
|
||||
},
|
||||
directives: {
|
||||
drop,
|
||||
dragClick
|
||||
BaseMenu
|
||||
},
|
||||
inject: {
|
||||
$reloadList: {
|
||||
@@ -33,230 +27,26 @@ export default {
|
||||
'selectVerband'
|
||||
],
|
||||
props: {
|
||||
endpoint: {
|
||||
type: Object,
|
||||
required: true,
|
||||
menu: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
preselectedKey: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: true,
|
||||
nodes: [],
|
||||
selectedKey: [],
|
||||
expandedKeys: {},
|
||||
filters: {}, // TODO(chris): filter only 1st level?
|
||||
favorites: {on: false, list: []}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
filteredNodes() {
|
||||
if (this.favorites.on)
|
||||
return this.nodes.filter(node => this.favorites.list.includes(node.key));
|
||||
|
||||
return this.nodes;
|
||||
},
|
||||
noSemReloadNodes() {
|
||||
return this.nodes.reduce(this.mapNodesToNoSemReloadNodes, []);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'preselectedKey': function (newVal, oldVal) {
|
||||
if (newVal !== oldVal) {
|
||||
this.setPreselection();
|
||||
}
|
||||
},
|
||||
'appConfig.number_displayed_past_studiensemester'(newVal, oldVal) {
|
||||
if (oldVal !== undefined) {
|
||||
this.noSemReloadNodes.forEach(node => {
|
||||
delete node.children;
|
||||
this.onExpandTreeNode(node);
|
||||
});
|
||||
if (oldVal !== undefined && this.$refs.menu) {
|
||||
this.$refs.menu.reloadNodesWithProp('no_sem_reload');
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
findNodeByKey(key, arr) {
|
||||
if (!arr)
|
||||
arr = this.nodes;
|
||||
let res = arr.filter(n => n.key == key);
|
||||
if (res.length)
|
||||
return res.pop();
|
||||
res = arr.map(n => n.children ? this.findNodeByKey(key, n.children) : null).filter(a => a);
|
||||
if (res.length)
|
||||
return res.pop();
|
||||
return null;
|
||||
},
|
||||
async onExpandTreeNode(node) {
|
||||
if (!node.children) {
|
||||
if (node.data.link) {
|
||||
let activeEl = null;
|
||||
this.$nextTick(() => {
|
||||
this.$nextTick(() => {
|
||||
activeEl = document.activeElement;
|
||||
});
|
||||
});
|
||||
this.loading = true;
|
||||
|
||||
return this.$api
|
||||
.call(this.endpoint.get(node.data.link))
|
||||
.then(result => result.data)
|
||||
.then(result => {
|
||||
const subNodes = result.map(this.mapResultToTreeData);
|
||||
const realNode = this.findNodeByKey(node.key);
|
||||
if (realNode)
|
||||
realNode.children = subNodes;
|
||||
else
|
||||
node.children = subNodes; // NOTE(chris): fallback should never be the case
|
||||
|
||||
let treeitem = this.$refs.tree.$el.querySelector('[data-tree-item-key="' + node.key + '"]');
|
||||
treeitem = treeitem.closest('[role="row"]');
|
||||
|
||||
this.$nextTick(() => {
|
||||
if (activeEl == document.activeElement)
|
||||
treeitem.dispatchEvent(new KeyboardEvent('keydown', {
|
||||
code: 'ArrowDown',
|
||||
key: 'ArrowDown'
|
||||
}));
|
||||
});
|
||||
|
||||
this.loading = false;
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
}
|
||||
}
|
||||
},
|
||||
onSelectTreeNode(node) {
|
||||
if (node.data.link)
|
||||
this.$emit('selectVerband', {link: node.data.link, studiengang_kz: node.data.stg_kz, semester: node.data.semester, orgform_kurzbz: node.data.orgform_kurzbz});
|
||||
},
|
||||
mapNodesToNoSemReloadNodes(result, node) {
|
||||
if (node.data.no_sem_reload)
|
||||
result.push(node);
|
||||
if (node.children)
|
||||
result = node.children.reduce(this.mapNodesToNoSemReloadNodes, result);
|
||||
return result;
|
||||
},
|
||||
mapResultToTreeData(el) {
|
||||
const cp = {
|
||||
key: ("" + el.link).replace('/', '-'),
|
||||
data: el,
|
||||
label: el.name
|
||||
};
|
||||
|
||||
if (el.children)
|
||||
cp.children = el.children.map(this.mapResultToTreeData);
|
||||
else
|
||||
cp.leaf = el.leaf || false;
|
||||
|
||||
return cp;
|
||||
},
|
||||
filterFav() {
|
||||
this.favorites.on = !this.favorites.on;
|
||||
this.$api
|
||||
.call(this.endpoint.favorites.set(
|
||||
JSON.stringify(this.favorites)
|
||||
));
|
||||
},
|
||||
markFav(key) {
|
||||
let index = this.favorites.list.indexOf(key.data.link + '');
|
||||
|
||||
if (index != -1) {
|
||||
this.favorites.list.splice(index, 1);
|
||||
} else {
|
||||
this.favorites.list.push(key.data.link + '');
|
||||
}
|
||||
|
||||
this.$api
|
||||
.call(this.endpoint.favorites.set(
|
||||
JSON.stringify(this.favorites)
|
||||
));
|
||||
},
|
||||
unsetFavFocus(e) {
|
||||
if (e.target.dataset?.linkFavAdd !== undefined) {
|
||||
e.target.tabIndex = -1;
|
||||
} else {
|
||||
let items = e.target.querySelectorAll('[data-link-fav-add]:not([tabindex="-1"])');
|
||||
items.forEach(el => el.tabIndex = document.activeElement == el ? 0 : -1);
|
||||
}
|
||||
},
|
||||
setFavFocus(e) {
|
||||
if (e.target.dataset?.linkFavAdd !== undefined) {
|
||||
e.target.tabIndex = 0;
|
||||
} else {
|
||||
let items = e.target.querySelectorAll('[data-link-fav-add][tabindex="-1"]');
|
||||
items.forEach(el => el.tabIndex = 0);
|
||||
}
|
||||
},
|
||||
async setPreselection()
|
||||
{
|
||||
if (!this.preselectedKey)
|
||||
{
|
||||
this.selectedKey = null;
|
||||
return;
|
||||
}
|
||||
|
||||
let rawKey = this.preselectedKey
|
||||
|
||||
if (!rawKey || typeof rawKey !== 'string')
|
||||
return;
|
||||
|
||||
const parts = this.preselectedKey.split('/');
|
||||
let currentKey = parts[0];
|
||||
let currentNode = this.findNodeByKey(currentKey);
|
||||
|
||||
if (!currentNode)
|
||||
return;
|
||||
|
||||
if(this.selectedKey)
|
||||
{
|
||||
const currentSelectedKey = Object.keys(this.selectedKey).find(Boolean);
|
||||
if (currentSelectedKey) {
|
||||
if (currentSelectedKey == currentKey)
|
||||
return;
|
||||
/**
|
||||
* Do not select a new entry if the current is a child of the new one.
|
||||
* This happens if a child entry of a new stg is selected and the router
|
||||
* tries to select the stg root entry (because subtrees do not have
|
||||
* routes yet)
|
||||
*/
|
||||
const isChild = this.findNodeByKey(
|
||||
currentSelectedKey,
|
||||
currentNode.children || []
|
||||
);
|
||||
if (isChild)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 1; i < parts.length; i++)
|
||||
{
|
||||
this.expandedKeys[currentNode.key] = true;
|
||||
|
||||
await this.onExpandTreeNode(currentNode);
|
||||
|
||||
currentKey += '-' + parts[i];
|
||||
currentNode = this.findNodeByKey(currentKey);
|
||||
|
||||
if (!currentNode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.selectedKey = {[currentNode.key]: true};
|
||||
this.onSelectTreeNode(currentNode);
|
||||
},
|
||||
async toggleTreeNode(node) {
|
||||
if (this.expandedKeys[node.key]) {
|
||||
delete this.expandedKeys[node.key];
|
||||
} else if (!node.leaf) {
|
||||
await this.onExpandTreeNode(node);
|
||||
this.expandedKeys[node.key] = true;
|
||||
}
|
||||
if (node.link)
|
||||
this.$emit('selectVerband', {link: node.link, studiengang_kz: node.stg_kz, semester: node.semester, orgform_kurzbz: node.orgform_kurzbz});
|
||||
},
|
||||
getStudentAjaxId(student) {
|
||||
let res = student.id;
|
||||
@@ -264,23 +54,22 @@ export default {
|
||||
res += ' (' + student.vorname + ' ' + student.nachname + ')';
|
||||
return res;
|
||||
},
|
||||
dropStudents(node, students) {
|
||||
const data = node.data;
|
||||
|
||||
onDrop({ drag, drop }) {
|
||||
let endpoint;
|
||||
if (data.gruppe_kurzbz) {
|
||||
endpoint = students.map(student => [
|
||||
|
||||
if (drop.gruppe_kurzbz) {
|
||||
endpoint = drag.map(student => [
|
||||
this.getStudentAjaxId(student),
|
||||
ApiStvGroups.add(
|
||||
student.id,
|
||||
data.gruppe_kurzbz,
|
||||
drop.gruppe_kurzbz,
|
||||
this.currentSemester
|
||||
)
|
||||
]);
|
||||
} else {
|
||||
const { semester, verband, gruppe } = data;
|
||||
const { semester, verband, gruppe } = drop;
|
||||
const params = { semester, verband, gruppe };
|
||||
endpoint = students.map(student => [
|
||||
endpoint = drag.map(student => [
|
||||
this.getStudentAjaxId(student),
|
||||
ApiStvDetails.saveStudent(
|
||||
student.id,
|
||||
@@ -296,117 +85,14 @@ export default {
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$api
|
||||
.call(this.endpoint.get())
|
||||
.then(result => {
|
||||
this.nodes = result.data.map(el => {
|
||||
el.root = true;
|
||||
return this.mapResultToTreeData(el);
|
||||
});
|
||||
this.setPreselection();
|
||||
this.loading = false;
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
|
||||
this.$api
|
||||
.call(this.endpoint.favorites.get())
|
||||
.then(result => {
|
||||
if (result.data) {
|
||||
this.favorites = JSON.parse(result.data);
|
||||
}
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
template: /* html */`
|
||||
<div class="overflow-auto" tabindex="-1">
|
||||
<pv-treetable
|
||||
ref="tree"
|
||||
class="stv-verband p-treetable-sm"
|
||||
:value="filteredNodes"
|
||||
@node-expand="onExpandTreeNode"
|
||||
selection-mode="single"
|
||||
v-model:expanded-keys="expandedKeys"
|
||||
v-model:selection-keys="selectedKey"
|
||||
@node-select="onSelectTreeNode"
|
||||
scrollable
|
||||
scroll-height="flex"
|
||||
@focusin="setFavFocus"
|
||||
@focusout="unsetFavFocus"
|
||||
:filters="filters"
|
||||
>
|
||||
<pv-column
|
||||
field="name"
|
||||
expander
|
||||
class="text-break"
|
||||
>
|
||||
<template #header>
|
||||
<div class="text-right">
|
||||
<div class="p-input-icon-left">
|
||||
<i class="pi pi-search"></i>
|
||||
<input
|
||||
type="text"
|
||||
v-model="filters['global']"
|
||||
class="form-control ps-5"
|
||||
placeholder="Search"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #body="{ node }">
|
||||
<span
|
||||
v-if="['semester', 'verband', 'gruppe', 'gruppe_kurzbz'].some(key => node.data.hasOwnProperty(key))"
|
||||
:data-tree-item-key="node.key"
|
||||
:title="node.data.studiengang_kz"
|
||||
v-drag-click="() => toggleTreeNode(node)"
|
||||
v-drop:link-strict.student-collection="(evt, students) => dropStudents(node, students)"
|
||||
>
|
||||
{{ node.data.name }}
|
||||
</span>
|
||||
<span
|
||||
v-else
|
||||
:data-tree-item-key="node.key"
|
||||
:title="node.data.studiengang_kz"
|
||||
v-drag-click="() => toggleTreeNode(node)"
|
||||
>
|
||||
{{ node.data.name }}
|
||||
</span>
|
||||
</template>
|
||||
</pv-column>
|
||||
<pv-column
|
||||
field="fav"
|
||||
class="flex-shrink-0 flex-grow-0"
|
||||
header-class="flex-shrink-0 flex-grow-0"
|
||||
>
|
||||
<template #header>
|
||||
<a
|
||||
v-if="favorites.on || favorites.list.length"
|
||||
href="#"
|
||||
@click.prevent="filterFav"
|
||||
>
|
||||
<i
|
||||
:class="favorites.on ? 'fa-solid' : 'fa-regular'"
|
||||
class="fa-star"
|
||||
></i>
|
||||
</a>
|
||||
</template>
|
||||
<template #body="{ node }">
|
||||
<a
|
||||
v-if="node.data.root"
|
||||
href="#"
|
||||
tabindex="-1"
|
||||
data-link-fav-add
|
||||
@click.prevent="markFav(node)"
|
||||
@keydown.enter.stop.prevent="markFav(node)"
|
||||
>
|
||||
<i
|
||||
:class="favorites.list.includes(node.data.link + '') ? 'fa-solid' : 'fa-regular'"
|
||||
class="fa-star"
|
||||
></i>
|
||||
</a>
|
||||
</template>
|
||||
</pv-column>
|
||||
<pv-column field="studiengang_kz" class="d-none"></pv-column>
|
||||
</pv-treetable>
|
||||
<base-menu
|
||||
ref="menu"
|
||||
:config="menu"
|
||||
:preselected-key="preselectedKey"
|
||||
@select-entry="onSelectTreeNode"
|
||||
@drop="onDrop"
|
||||
/>
|
||||
</div>`
|
||||
};
|
||||
|
||||
@@ -9,6 +9,26 @@ const EFFECTS = [
|
||||
|
||||
export default {
|
||||
mounted(el, binding) {
|
||||
if (!binding.arg) {
|
||||
binding.arg = 'none';
|
||||
} else if (typeof binding.arg === 'object' && !Array.isArray(binding.arg)) {
|
||||
// NOTE(chris): allow object as arg and map it to arg and
|
||||
// modifiers to allow dynamic modifiers.
|
||||
if (binding.arg.allowed) {
|
||||
binding.modifiers = binding.arg.allowed.reduce((a, c) => {
|
||||
a[c] = true;
|
||||
return a;
|
||||
}, {});
|
||||
}
|
||||
if (!binding.arg.effect)
|
||||
binding.arg.effect = 'none';
|
||||
|
||||
if (binding.arg.strict)
|
||||
binding.arg = binding.arg.effect + '-strict';
|
||||
else
|
||||
binding.arg = binding.arg.effect;
|
||||
}
|
||||
|
||||
const allowedTypes = Object.keys(binding.modifiers);
|
||||
allowedTypes.forEach(type => {
|
||||
if (type.substr(-11) == '-collection') {
|
||||
|
||||
Reference in New Issue
Block a user