From b3bed062a0b38f930a5bc73b500fbcdd71bbc375 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Wed, 12 Oct 2022 12:44:48 +0000 Subject: [PATCH] remove configuration MY_COURSES_ALLOW_TILED_DISPLAY, fixes #1654 Closes #1654 Merge request studip/studip!1065 --- app/controllers/my_courses.php | 28 ++++++++----------- ...move_allow_tiled_display_configuration.php | 26 +++++++++++++++++ resources/vue/components/MyCourses.vue | 5 +--- resources/vue/store/MyCoursesStore.js | 5 ---- 4 files changed, 39 insertions(+), 25 deletions(-) create mode 100644 db/migrations/5.3.4_remove_allow_tiled_display_configuration.php diff --git a/app/controllers/my_courses.php b/app/controllers/my_courses.php index da321071253..3071e8c2405 100644 --- a/app/controllers/my_courses.php +++ b/app/controllers/my_courses.php @@ -192,9 +192,8 @@ class MyCoursesController extends AuthenticatedController 'allow_dozent_visibility' => Config::get()->ALLOW_DOZENT_VISIBILITY, 'open_groups' => $GLOBALS['user']->cfg->MY_COURSES_OPEN_GROUPS, 'sem_number' => Config::get()->IMPORTANT_SEMNUMBER, - 'allow_tiled_display' => Config::get()->MY_COURSES_ALLOW_TILED_DISPLAY, - 'display_type' => Config::get()->MY_COURSES_ALLOW_TILED_DISPLAY && $GLOBALS['user']->cfg->MY_COURSES_TILED_DISPLAY ? 'tiles' : 'tables', - 'responsive_type' => Config::get()->MY_COURSES_ALLOW_TILED_DISPLAY && $GLOBALS['user']->cfg->MY_COURSES_TILED_DISPLAY_RESPONSIVE ? 'tiles' : 'tables', + 'display_type' => $GLOBALS['user']->cfg->MY_COURSES_TILED_DISPLAY ? 'tiles' : 'tables', + 'responsive_type' => $GLOBALS['user']->cfg->MY_COURSES_TILED_DISPLAY_RESPONSIVE ? 'tiles' : 'tables', 'navigation_show_only_new' => $GLOBALS['user']->cfg->MY_COURSES_SHOW_NEW_ICONS_ONLY, 'group_by' => $this->getGroupField(), ], @@ -904,19 +903,16 @@ class MyCoursesController extends AuthenticatedController $this->setGroupingSelector($group_field); - if (Config::get()->MY_COURSES_ALLOW_TILED_DISPLAY) { - $views = $sidebar->addWidget(new ViewsWidget()); - $views->id = 'tiled-courses-sidebar-switch'; - $views->addLink( - _('Tabellarische Ansicht'), - '#' - )->setActive(!$GLOBALS['user']->cfg->MY_COURSES_TILED_DISPLAY); - $views->addLink( - _('Kachelansicht'), - '#' - )->setActive($GLOBALS['user']->cfg->MY_COURSES_TILED_DISPLAY); - - } + $views = $sidebar->addWidget(new ViewsWidget()); + $views->id = 'tiled-courses-sidebar-switch'; + $views->addLink( + _('Tabellarische Ansicht'), + '#tabular' + )->setActive(!$GLOBALS['user']->cfg->MY_COURSES_TILED_DISPLAY); + $views->addLink( + _('Kachelansicht'), + '#tiles' + )->setActive($GLOBALS['user']->cfg->MY_COURSES_TILED_DISPLAY); $options = $sidebar->addWidget(new OptionsWidget()); $options->id = 'tiled-courses-new-contents-toggle'; diff --git a/db/migrations/5.3.4_remove_allow_tiled_display_configuration.php b/db/migrations/5.3.4_remove_allow_tiled_display_configuration.php new file mode 100644 index 00000000000..6aa898a4ea6 --- /dev/null +++ b/db/migrations/5.3.4_remove_allow_tiled_display_configuration.php @@ -0,0 +1,26 @@ +<?php +final class RemoveAllowTiledDisplayConfiguration extends Migration +{ + protected function up() + { + $query = "DELETE config, config_values + FROM `config` + LEFT JOIN `config_values` USING(`field`) + WHERE `field` = 'MY_COURSES_ALLOW_TILED_DISPLAY'"; + DBManager::get()->exec($query); + } + + protected function down() + { + $query = "INSERT IGNORE INTO `config` ( + `field`, `value`, `type`, `range`, + `section`, `description`, + `mkdate`, `chdate` + ) VALUES ( + 'MY_COURSES_ALLOW_TILED_DISPLAY', '0', 'boolean', 'global', + 'MeineVeranstaltungen', 'Soll die Kachelansicht unter \"Meine Veranstaltungen\" aktiviert werden?', + UNIX_TIMESTAMP(), UNIX_TIMESTAMP() + )"; + DBManager::get()->exec($query); + } +} diff --git a/resources/vue/components/MyCourses.vue b/resources/vue/components/MyCourses.vue index c458f220b0a..3e99ad79f79 100644 --- a/resources/vue/components/MyCourses.vue +++ b/resources/vue/components/MyCourses.vue @@ -21,7 +21,7 @@ </studip-message-box> <component v-else :is="displayComponent" :icon-size="iconSize"></component> - <MountingPortal v-if="allowTiled" mount-to="#tiled-courses-sidebar-switch .sidebar-widget-content .widget-list" name="sidebar-switch"> + <MountingPortal mount-to="#tiled-courses-sidebar-switch .sidebar-widget-content .widget-list" name="sidebar-switch"> <my-courses-sidebar-switch></my-courses-sidebar-switch> </MountingPortal> @@ -49,9 +49,6 @@ export default { MyCoursesNewContentToggle, }, computed: { - allowTiled () { - return this.getConfig('allow_tiled_display'); - }, displayComponent () { return this.displayedType === 'tiles' ? MyCoursesTiles diff --git a/resources/vue/store/MyCoursesStore.js b/resources/vue/store/MyCoursesStore.js index a2aa2cd6ce2..a0900404e44 100644 --- a/resources/vue/store/MyCoursesStore.js +++ b/resources/vue/store/MyCoursesStore.js @@ -1,9 +1,4 @@ const configMapping = { - allow_tiled_display: value => { - return { - MY_COURSES_ALLOW_TILED_DISPLAY: value, - } - }, display_type: value => { return { MY_COURSES_TILED_DISPLAY: value === 'tiles', -- GitLab