beta test: added quick search box for customers, projects and activities (#392)

This commit is contained in:
Kevin Papst
2018-11-06 23:35:09 +01:00
committed by GitHub
parent db7de3aac1
commit bae24dd0ec
7 changed files with 122 additions and 43 deletions

View File

@@ -35,47 +35,57 @@ class AppExtension extends Extension implements PrependExtensionInterface
$container->setParameter('kimai.languages', $config['languages']);
$container->setParameter('kimai.calendar', $config['calendar']);
$container->setParameter('kimai.theme', $config['theme']);
$container->setParameter('kimai.dashboard', $config['dashboard']);
$container->setParameter('kimai.widgets', $config['widgets']);
$container->setParameter('kimai.invoice.documents', $config['invoice']['documents']);
$container->setParameter('kimai.defaults', $config['defaults']);
$this->createUserParameter($config, $container);
$this->createTimesheetParameter($config, $container);
$this->createThemeParameter($config['theme'], $container);
$this->createUserParameter($config['user'], $container);
$this->createTimesheetParameter($config['timesheet'], $container);
}
/**
* @param array $config
* @param ContainerBuilder $container
*/
public function createUserParameter(array $config, ContainerBuilder $container)
protected function createThemeParameter(array $config, ContainerBuilder $container)
{
if (!$config['user']['registration']) {
$container->setParameter('kimai.theme', $config);
$container->setParameter('kimai.theme.select_type', $config['select_type']);
}
/**
* @param array $config
* @param ContainerBuilder $container
*/
protected function createUserParameter(array $config, ContainerBuilder $container)
{
if (!$config['registration']) {
$routes = $container->getParameter('admin_lte_theme.routes');
$routes['adminlte_registration'] = null;
$container->setParameter('admin_lte_theme.routes', $routes);
}
if (!$config['user']['password_reset']) {
if (!$config['password_reset']) {
$routes = $container->getParameter('admin_lte_theme.routes');
$routes['adminlte_password_reset'] = null;
$container->setParameter('admin_lte_theme.routes', $routes);
}
$container->setParameter('kimai.fosuser', $config['user']);
$container->setParameter('kimai.fosuser', $config);
}
/**
* @param array $config
* @param ContainerBuilder $container
*/
public function createTimesheetParameter(array $config, ContainerBuilder $container)
protected function createTimesheetParameter(array $config, ContainerBuilder $container)
{
$container->setParameter('kimai.timesheet.rates', $config['timesheet']['rates']);
$container->setParameter('kimai.timesheet.rounding', $config['timesheet']['rounding']);
$container->setParameter('kimai.timesheet.duration_only', $config['timesheet']['duration_only']);
$container->setParameter('kimai.timesheet.markdown', $config['timesheet']['markdown_content']);
$container->setParameter('kimai.timesheet.rates', $config['rates']);
$container->setParameter('kimai.timesheet.rounding', $config['rounding']);
$container->setParameter('kimai.timesheet.duration_only', $config['duration_only']);
$container->setParameter('kimai.timesheet.markdown', $config['markdown_content']);
}
/**

View File

@@ -215,6 +215,9 @@ class Configuration implements ConfigurationInterface
->scalarNode('box_color')
->defaultValue('green')
->end()
->scalarNode('select_type')
->defaultNull()
->end()
->end()
;

View File

@@ -0,0 +1,65 @@
<?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\Extension;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
/**
* Converts normal select boxes into javascript enhanced versions.
*/
class EnhancedChoiceTypeExtension extends AbstractTypeExtension
{
public const TYPE_SELECTPICKER = 'selectpicker';
/**
* @var string|null
*/
protected $type = null;
/**
* @param null|string $type
*/
public function __construct(?string $type)
{
$this->type = $type;
}
/**
* @return string
*/
public function getExtendedType()
{
return EntityType::class;
}
/**
* @param FormView $view
* @param FormInterface $form
* @param array $options
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
if ($this->type !== self::TYPE_SELECTPICKER) {
return;
}
if (!isset($view->vars['attr'])) {
$view->vars['attr'] = [];
}
$view->vars['attr'] = array_merge(
$view->vars['attr'],
['class' => 'selectpicker', 'data-live-search' => true, 'data-width' => '100%']
);
}
}