Allow to configure the global theme using the WebUI

This commit is contained in:
Jan Böhmer 2024-06-24 21:40:37 +02:00
parent 3e657a7cac
commit f88584e1ca
5 changed files with 16 additions and 6 deletions

View file

@ -7,7 +7,6 @@ twig:
globals:
default_currency: '%partdb.default_currency%'
global_theme: '%partdb.global_theme%'
allow_email_pw_reset: '%partdb.users.email_pw_reset%'
locale_menu: '%partdb.locale_menu%'
attachment_manager: '@App\Services\Attachments\AttachmentManager'

View file

@ -11,7 +11,6 @@ parameters:
# This is used as workaround for places where we can not access the settings directly (like the 2FA application names)
partdb.title: '%env(string:settings:customization:instanceName)%' # The title shown inside of Part-DB (e.g. in the navbar and on homepage)
partdb.default_currency: '%env(string:BASE_CURRENCY)%' # The currency that is used inside the DB (and is assumed when no currency is set). This can not be changed later, so be sure to set it the currency used in your country
partdb.global_theme: '' # The theme to use globally (see public/build/themes/ for choices, use name without .css). Set to '' for default bootstrap theme
partdb.locale_menu: ['en', 'de', 'it', 'fr', 'ru', 'ja', 'cs', 'da', 'zh'] # The languages that are shown in user drop down menu
partdb.enforce_change_comments_for: '%env(csv:ENFORCE_CHANGE_COMMENTS_FOR)%' # The actions for which a change comment is required (e.g. "part_edit", "part_create", etc.). If this is empty, change comments are not required at all.

View file

@ -24,6 +24,8 @@ declare(strict_types=1);
namespace App\Settings\SystemSettings;
use App\Form\Type\RichTextEditorType;
use App\Form\Type\ThemeChoiceType;
use App\Validator\Constraints\ValidTheme;
use Jbtronics\SettingsBundle\Metadata\EnvVarMode;
use Jbtronics\SettingsBundle\Settings\Settings;
use Jbtronics\SettingsBundle\Settings\SettingsParameter;
@ -48,4 +50,10 @@ class CustomizationSettings
)]
public ?string $banner = null;
#[SettingsParameter(
label: new TM("settings.system.customization.theme"),
formType: ThemeChoiceType::class, formOptions: ['placeholder' => false]
)]
#[ValidTheme]
public string $theme = 'bootstrap';
}

View file

@ -40,14 +40,12 @@
{% if not app.user.theme is defined %}
{% set theme = global_theme %}
{% if app.user.theme is not defined or app.user.theme is null %}
{% set theme = settings_instance('customization').theme %}
{% else %}
{% set theme = app.user.theme %}
{% endif %}
{% if theme and theme in available_themes and encore_entry_exists('theme_' ~ theme) %}
{{ encore_entry_link_tags('theme_' ~ theme) }}
{% else %}

View file

@ -12467,5 +12467,11 @@ Please note, that you can not impersonate a disabled user. If you try you will g
<target>Save removed data in log entries on element deletion</target>
</segment>
</unit>
<unit id="8665ItM" name="settings.system.customization.theme">
<segment>
<source>settings.system.customization.theme</source>
<target>Global theme</target>
</segment>
</unit>
</file>
</xliff>