Skip to content
Snippets Groups Projects
Commit 6bb7cf96 authored by Murtaza Sultani's avatar Murtaza Sultani
Browse files

Store tile layout state in user config

parent 37ffd27f
No related branches found
No related tags found
No related merge requests found
...@@ -328,25 +328,29 @@ class CategoriesController extends BookableController { ...@@ -328,25 +328,29 @@ class CategoriesController extends BookableController {
*/ */
public function buildSidebar(): void public function buildSidebar(): void
{ {
$user_id = User::findCurrent()->user_id;
$actions = new ActionsWidget(); $actions = new ActionsWidget();
$actions->setTitle('Ansichten'); $actions->setTitle('Ansichten');
if (Request::option('view')) { if (Request::option('layout')) {
$_SESSION['Bookable']['categories_view'] = Request::option('view'); $layout = Request::option('layout') === 'card' ? 1 : 0;
UserConfig::get($user_id)->store('BOOKABLE_TILE_LAYOUT', $layout);
} }
if (Request::option('view') === 'card' $this->tile_layout = UserConfig::get($user_id)->BOOKABLE_TILE_LAYOUT;
|| (!empty($_SESSION['Bookable']['categories_view']) && $_SESSION['Bookable']['categories_view'] === 'card')) {
if ($this->tile_layout) {
$actions->addLink( $actions->addLink(
_('Listenansicht'), _('Listenansicht'),
URLHelper::getURL('', ['view' => 'list', 'search_keyword' => Request::get('search_keyword')]), URLHelper::getURL('', ['layout' => 'list', 'search_keyword' => Request::get('search_keyword')]),
Icon::create('view-list') Icon::create('view-list')
); );
} else { } else {
$actions->addLink( $actions->addLink(
_('Kachelansicht'), _('Kachelansicht'),
URLHelper::getURL('', ['view' => 'card', 'search_keyword' => Request::get('search_keyword')]), URLHelper::getURL('', ['layout' => 'card', 'search_keyword' => Request::get('search_keyword')]),
Icon::create('block-gallery') Icon::create('block-gallery')
); );
} }
......
<?php
final class AddLogActions extends Migration
{
public function up()
{
StudipLog::registerActionPlugin(
'BOOKABLE_BOOKING_STATUS',
'Der Buchungsstand Änderung',
'%user ändert/setzt Buchung(ID: %affected) im %sem(%coaffected). %info',
Bookable::class
);
}
public function down()
{
StudipLog::unregisterAction('BOOKABLE_BOOKING_STATUS');
}
}
<?php
final class AddUserConfig extends Migration
{
public function up()
{
DBManager::get()->execute(
"INSERT IGNORE INTO `config` VALUES (:field, :value, :type, :range, :section, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :description)",
[
'field' => 'BOOKABLE_TILE_LAYOUT',
'value' => 1,
'type' => 'boolean',
'range' => 'user',
'section' => 'Bookable',
'description' => 'Konfiguration der Ansicht der Kategorien'
]
);
}
public function down()
{
$sql = "DELETE `config`, `config_values` FROM `config`
LEFT JOIN `config_values` USING (`field`)
WHERE `field` = :field";
DBManager::get()->execute(
$sql,
['field' => 'BOOKABLE_TILE_LAYOUT']
);
}
}
...@@ -4,11 +4,12 @@ ...@@ -4,11 +4,12 @@
* @var Bookable\Models\BookableCategory[] $categories * @var Bookable\Models\BookableCategory[] $categories
* @var Bookable $plugin * @var Bookable $plugin
* @var bool $is_admin * @var bool $is_admin
* @var bool $tile_layout
*/ */
?> ?>
<div class="bookable "> <div class="bookable ">
<? if (Request::get('view') === 'card' || (!empty($_SESSION['Bookable']['categories_view']) && $_SESSION['Bookable']['categories_view'] === 'card')) : ?> <? if ($tile_layout) : ?>
<ul class="categories-card-container use-utility-classes"> <ul class="categories-card-container use-utility-classes">
<? foreach ($categories as $category): ?> <? foreach ($categories as $category): ?>
<li> <li>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment