added project detail report (#2651)

- avatars via css only
- random colors for entities
- improves print view
- added colors for teams
- added color to tag
This commit is contained in:
Kevin Papst
2021-07-06 22:01:20 +02:00
committed by GitHub
parent cc6031bfde
commit 9ddb87a6fd
122 changed files with 2736 additions and 1549 deletions

View File

@@ -17,8 +17,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class ActivityTeamPermissionForm extends AbstractType
{
use EntityFormTrait;
/**
* {@inheritdoc}
*/

51
src/Form/ColorTrait.php Normal file
View File

@@ -0,0 +1,51 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Form;
use App\Form\Type\ColorChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
trait ColorTrait
{
protected function addColor(FormBuilderInterface $builder): void
{
$builder
->add('color', ColorChoiceType::class, [
'required' => false,
])
;
// this code exists only for backward compatibility
$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function (FormEvent $event) {
if (!$event->getForm()->getConfig()->hasOption('choices')) {
return;
}
$data = $event->getData();
$choices = $event->getForm()->getConfig()->getOption('choices');
if (\is_object($data) && method_exists($data, 'getColor')) {
$color = $data->getColor();
if (!empty($color) && array_search($color, $choices) === false) {
$choices[$color] = $color;
}
}
$event->getForm()->add('color', ColorChoiceType::class, [
'required' => false,
'choices' => $choices,
]);
}
);
}
}

View File

@@ -17,8 +17,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class CustomerTeamPermissionForm extends AbstractType
{
use EntityFormTrait;
/**
* {@inheritdoc}
*/

View File

@@ -9,18 +9,17 @@
namespace App\Form;
use App\Form\Type\ColorChoiceType;
use App\Form\Type\DurationType;
use App\Form\Type\MetaFieldsCollectionType;
use App\Form\Type\YesNoType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
trait EntityFormTrait
{
use ColorTrait;
public function addCommonFields(FormBuilderInterface $builder, array $options): void
{
$this->addColor($builder);
@@ -50,39 +49,10 @@ trait EntityFormTrait
]);
}
public function addColor(FormBuilderInterface $builder): void
{
$builder
->add('color', ColorChoiceType::class, [
'required' => false,
])
;
// this code exists only for backward compatibility
$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function (FormEvent $event) use ($builder) {
if (!$builder->get('color')->hasOption('choices')) {
return;
}
$data = $event->getData();
$choices = $builder->get('color')->getOption('choices');
if (\is_object($data) && method_exists($data, 'getColor')) {
$color = $data->getColor();
if (!empty($color) && array_search($color, $choices) === false) {
$choices[$color] = $color;
}
}
$event->getForm()->add('color', ColorChoiceType::class, [
'required' => false,
'choices' => $choices,
]);
}
);
}
/**
* @deprecated since 1.15
* @param FormBuilderInterface $builder
*/
public function addCreateMore(FormBuilderInterface $builder): void
{
$builder->add('create_more', CheckboxType::class, [

View File

@@ -17,8 +17,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class ProjectTeamPermissionForm extends AbstractType
{
use EntityFormTrait;
/**
* {@inheritdoc}
*/

View File

@@ -10,7 +10,6 @@
namespace App\Form;
use App\Entity\Tag;
use App\Form\Type\ColorPickerType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -18,6 +17,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class TagEditForm extends AbstractType
{
use ColorTrait;
/**
* {@inheritdoc}
*/
@@ -34,7 +35,8 @@ class TagEditForm extends AbstractType
'description' => 'The tag name (forbidden character: comma)',
],
])
->add('color', ColorPickerType::class);
;
$this->addColor($builder);
}
/**

View File

@@ -18,6 +18,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class TeamEditForm extends AbstractType
{
use ColorTrait;
/**
* {@inheritdoc}
*/
@@ -37,7 +39,9 @@ class TeamEditForm extends AbstractType
'type' => 'string',
'description' => 'Name of the team',
],
])
]);
$this->addColor($builder);
$builder
->add('teamlead', UserType::class, [
'label' => 'label.teamlead',
'multiple' => false,

View File

@@ -67,6 +67,7 @@ class ProjectType extends AbstractType
'activity_select' => 'activity',
'activity_visibility' => ActivityQuery::SHOW_VISIBLE,
'ignore_date' => false,
'join_customer' => false,
]);
$resolver->setDefault('query_builder', function (Options $options) {
@@ -78,6 +79,9 @@ class ProjectType extends AbstractType
if (true === $options['ignore_date']) {
$query->setIgnoreDate(true);
}
if (true === $options['join_customer']) {
$query->setWithCustomer(true);
}
return $repo->getQueryBuilderForFormType($query);
};

View File

@@ -9,6 +9,7 @@
namespace App\Form;
use App\Configuration\SystemConfiguration;
use App\Entity\User;
use App\Form\Type\AvatarType;
use App\Form\Type\LanguageType;
@@ -25,6 +26,15 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
class UserEditType extends AbstractType
{
use ColorTrait;
private $configuration;
public function __construct(SystemConfiguration $configuration)
{
$this->configuration = $configuration;
}
/**
* {@inheritdoc}
*/
@@ -39,9 +49,17 @@ class UserEditType extends AbstractType
'label' => 'label.title',
'required' => false,
])
->add('avatar', AvatarType::class, [
;
if ($this->configuration->isThemeAllowAvatarUrls()) {
$builder->add('avatar', AvatarType::class, [
'required' => false,
])
]);
}
$this->addColor($builder);
$builder
->add('email', EmailType::class, [
'label' => 'label.email',
])