From a653ba90919b3a9633c1593a34b8611efe67b093 Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Mon, 12 Aug 2024 09:32:16 +0000
Subject: [PATCH] jump to, open and mark module as selected after storing
 changes, fixes #4473

Closes #4473

Merge request studip/studip!3261
---
 app/controllers/module/module.php  | 3 ++-
 app/views/module/module/module.php | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/app/controllers/module/module.php b/app/controllers/module/module.php
index 854b0453610..10674d07dc9 100644
--- a/app/controllers/module/module.php
+++ b/app/controllers/module/module.php
@@ -101,6 +101,7 @@ class Module_ModuleController extends MVVController
         $this->count = Modul::getCount($this->filter);
         $this->show_sidebar_search = true;
         $this->show_sidebar_filter = true;
+        $this->modul_id = Request::option('modul_id');
         $this->setSidebar();
     }
 
@@ -323,7 +324,7 @@ class Module_ModuleController extends MVVController
                         $success_message,
                         htmlReady($this->modul->getDisplayName())
                     ));
-                    $this->redirect($this->indexURL());
+                    $this->redirect($this->indexURL(['modul_id' => $this->modul->id]) . "#modul_{$this->modul->id}");
                     return;
                 }
             }
diff --git a/app/views/module/module/module.php b/app/views/module/module/module.php
index 271e3f9d432..d6cda88fdf1 100644
--- a/app/views/module/module/module.php
+++ b/app/views/module/module/module.php
@@ -1,9 +1,9 @@
 <? foreach ($module as $modul) : ?>
     <? $perm = MvvPerm::get($modul) ?>
-    <tbody class="<?= ($modul->count_modulteile ? '' : 'empty ') ?><?= ($modul_id === $modul->getId() ? 'not-collapsed' : 'collapsed') ?>">
+    <tbody class="<?= $modul->count_modulteile ? '' : 'empty ' ?><?= $modul_id === $modul->getId() ? 'not-collapsed' : 'collapsed' ?>">
         <? $ampel_icon = $GLOBALS['MVV_STUDIENGANG']['STATUS']['values'][$modul->stat]['icon'] ?>
         <? $ampelstatus = $GLOBALS['MVV_STUDIENGANG']['STATUS']['values'][$modul->stat]['name'] ?>
-        <tr class="header-row" id="modul_<?= $modul->getId() ?>">
+        <tr class="header-row <?= $modul_id === $modul->getId() ? 'selected' : '' ?>" id="modul_<?= $modul->getId() ?>">
             <? if ($modul->count_modulteile) : ?>
                 <td style="white-space:nowrap;" class="toggle-indicator">
                     <? $details_action = $details_action ?? 'details'; ?>
-- 
GitLab