Implemented different themes for Part-DB.

We use Bootswatch to provide different themed bootstrap CSS.
This commit is contained in:
Jan Böhmer 2019-10-13 17:48:18 +02:00
parent 0ebc5bfdad
commit 0b69de332d
10 changed files with 157 additions and 7 deletions

View file

@ -88,6 +88,10 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/** The User id of the anonymous user */
public const ID_ANONYMOUS = 1;
public const AVAILABLE_THEMES = ['bootstrap', 'cerulean', 'cosmo', 'cyborg', 'darkly', 'flatly', 'journal',
'litera', 'lumen', 'lux', 'materia', 'minty', 'pulse', 'sandstone', 'simplex', 'sketchy', 'slate', 'solar',
'spacelab', 'united', 'yeti'];
/**
* @var Collection|UserAttachment[]
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\UserAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
@ -166,6 +170,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/**
* @var string|null The theme
* @ORM\Column(type="string", name="config_theme", nullable=true)
* @Assert\Choice(choices=User::AVAILABLE_THEMES)
*/
protected $theme = '';

View file

@ -35,6 +35,7 @@ namespace App\Form;
use App\Entity\UserSystem\Group;
use App\Entity\Base\NamedDBElement;
use App\Entity\Base\StructuralDBElement;
use App\Entity\UserSystem\User;
use App\Form\Permissions\PermissionsType;
use App\Form\Permissions\PermissionType;
use App\Form\Type\CurrencyEntityType;
@ -147,6 +148,10 @@ class UserAdminForm extends AbstractType
])
->add('theme', ChoiceType::class, [
'required' => false,
'choices' => User::AVAILABLE_THEMES,
'choice_label' => function ($entity, $key, $value) {
return $value;
},
'placeholder' => $this->trans->trans('user_settings.theme.placeholder'),
'label' => $this->trans->trans('user.theme.label'),
'disabled' => !$this->security->isGranted('change_user_settings', $entity)

View file

@ -75,6 +75,10 @@ class UserSettingsType extends AbstractType
])
->add('theme', ChoiceType::class, [
'required' => false,
'choices' => User::AVAILABLE_THEMES,
'choice_label' => function ($entity, $key, $value) {
return $value;
},
'placeholder' => $this->trans->trans('user_settings.theme.placeholder'),
'label' => $this->trans->trans('user.theme.label'),
])