@@ -57,6 +57,13 @@ final class EnhancedChoiceTypeExtension extends AbstractTypeExtension
|
||||
$extendedOptions['data-disable-search'] = 1;
|
||||
}
|
||||
|
||||
// there is a very weird logic in vendor/symfony/twig-bridge/Resources/views/Form/form_div_layout.html.twig
|
||||
// in block "block choice_widget_collapsed" that resets "{% set required = false %}", so we fake it into the select
|
||||
if (true === $options['required'] && (!\array_key_exists('size', $options['attr']) || $options['attr']['size'] <= 1)) {
|
||||
$extendedOptions['required'] = 'required';
|
||||
$extendedOptions['placeholder'] = '';
|
||||
}
|
||||
|
||||
$view->vars['attr'] = array_merge($view->vars['attr'], $extendedOptions);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ class ProjectEditForm extends AbstractType
|
||||
$customer = null;
|
||||
$isNew = false;
|
||||
$options['currency'] = null;
|
||||
$customerOptions = [];
|
||||
|
||||
if (isset($options['data'])) {
|
||||
/** @var Project $entry */
|
||||
@@ -40,6 +41,11 @@ class ProjectEditForm extends AbstractType
|
||||
if (null !== $entry->getCustomer()) {
|
||||
$customer = $entry->getCustomer();
|
||||
$options['currency'] = $customer->getCurrency();
|
||||
|
||||
if (!$customer->isVisible()) {
|
||||
// force visibility, see https://github.com/kimai/kimai/issues/3985
|
||||
$customerOptions['pre_select_customer'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,11 +89,11 @@ class ProjectEditForm extends AbstractType
|
||||
'required' => false,
|
||||
'force_time' => 'end',
|
||||
]))
|
||||
->add('customer', CustomerType::class, [
|
||||
->add('customer', CustomerType::class, array_merge([
|
||||
'placeholder' => ($isNew && null === $customer) ? '' : false,
|
||||
'customers' => $customer,
|
||||
'query_builder_for_user' => true,
|
||||
])
|
||||
], $customerOptions))
|
||||
->add('globalActivities', YesNoType::class, [
|
||||
'label' => 'globalActivities',
|
||||
'help' => 'help.globalActivities'
|
||||
|
||||
@@ -133,19 +133,13 @@ trait ToolbarFormTrait
|
||||
protected function addVisibilityChoice(FormBuilderInterface $builder, string $label = 'visible'): void
|
||||
{
|
||||
$builder->add('visibility', VisibilityType::class, [
|
||||
'required' => false,
|
||||
'placeholder' => null,
|
||||
'label' => $label,
|
||||
'search' => false
|
||||
]);
|
||||
}
|
||||
|
||||
protected function addPageSizeChoice(FormBuilderInterface $builder): void
|
||||
{
|
||||
$builder->add('pageSize', PageSizeType::class, [
|
||||
'required' => false,
|
||||
'search' => false
|
||||
]);
|
||||
$builder->add('pageSize', PageSizeType::class);
|
||||
}
|
||||
|
||||
protected function addUserRoleChoice(FormBuilderInterface $builder): void
|
||||
@@ -332,7 +326,6 @@ trait ToolbarFormTrait
|
||||
'asc' => BaseQuery::ORDER_ASC,
|
||||
'desc' => BaseQuery::ORDER_DESC
|
||||
],
|
||||
'search' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -346,7 +339,6 @@ trait ToolbarFormTrait
|
||||
$builder->add('orderBy', ChoiceType::class, [
|
||||
'label' => 'orderBy',
|
||||
'choices' => $all,
|
||||
'search' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -367,9 +359,6 @@ trait ToolbarFormTrait
|
||||
{
|
||||
$builder->add('state', ChoiceType::class, [
|
||||
'label' => 'entryState',
|
||||
'required' => false,
|
||||
'placeholder' => null,
|
||||
'search' => false,
|
||||
'choices' => [
|
||||
'all' => TimesheetQuery::STATE_ALL,
|
||||
'entryState.running' => TimesheetQuery::STATE_RUNNING,
|
||||
@@ -382,9 +371,6 @@ trait ToolbarFormTrait
|
||||
{
|
||||
$builder->add('exported', ChoiceType::class, [
|
||||
'label' => 'exported',
|
||||
'required' => false,
|
||||
'placeholder' => null,
|
||||
'search' => false,
|
||||
'choices' => [
|
||||
'all' => TimesheetQuery::STATE_ALL,
|
||||
'yes' => TimesheetQuery::STATE_EXPORTED,
|
||||
@@ -395,10 +381,6 @@ trait ToolbarFormTrait
|
||||
|
||||
protected function addBillableChoice(FormBuilderInterface $builder): void
|
||||
{
|
||||
$builder->add('billable', BillableSearchType::class, [
|
||||
'required' => false,
|
||||
'placeholder' => null,
|
||||
'search' => false,
|
||||
]);
|
||||
$builder->add('billable', BillableSearchType::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,11 +63,17 @@ final class CustomerType extends AbstractType
|
||||
'ignore_customer' => null,
|
||||
// @var Customer|Customer[]|null
|
||||
'customers' => null,
|
||||
'pre_select_customer' => false,
|
||||
]);
|
||||
|
||||
$resolver->setDefault('query_builder', function (Options $options) {
|
||||
return function (CustomerRepository $repo) use ($options) {
|
||||
$query = new CustomerFormTypeQuery($options['customers']);
|
||||
|
||||
if (true === $options['pre_select_customer']) {
|
||||
$query->setAllowCustomerPreselect(true);
|
||||
}
|
||||
|
||||
if (true === $options['query_builder_for_user']) {
|
||||
$query->setUser($options['user']);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ final class InvoiceCalculatorType extends AbstractType
|
||||
return $renderer;
|
||||
},
|
||||
'translation_domain' => 'invoice-calculator',
|
||||
'search' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ final class InvoiceRendererType extends AbstractType
|
||||
};
|
||||
},
|
||||
'translation_domain' => 'invoice-renderer',
|
||||
'search' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ final class SkinType extends AbstractType
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'search' => false,
|
||||
'required' => true,
|
||||
'choices' => self::THEMES,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user