* bump version
* fix translation ids
* added css classes to modify form with custom css
* improve export pdf file names
* respect financial year in new report
* added new InvoiceCalculator: price
* upgrade packages and node-sass to v7
* title pattern for customer, project and activity via API
* support negative money without currency
* fix sub-locale in print export template
* fix overbooking validation for monthly budget
* fix copying entities with different set of custom-fields compared to the current configuration
This commit is contained in:
Kevin Papst
2022-02-25 20:41:56 +01:00
committed by GitHub
parent 34649d809e
commit c0168ecc5b
53 changed files with 1222 additions and 611 deletions

View File

@@ -15,6 +15,8 @@ use App\Repository\ActivityRepository;
use App\Repository\Query\ActivityFormTypeQuery;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -36,7 +38,7 @@ class ActivityType extends AbstractType
$this->configuration = $configuration;
}
public function getChoiceLabel(Activity $activity): string
private function getPattern(): string
{
if ($this->pattern === null) {
$this->pattern = $this->configuration->find('activity.choice_pattern');
@@ -44,12 +46,18 @@ class ActivityType extends AbstractType
if ($this->pattern === null || stripos($this->pattern, '{') === false || stripos($this->pattern, '}') === false) {
$this->pattern = self::PATTERN_NAME;
}
$this->pattern = str_replace(self::PATTERN_SPACER, self::SPACER, $this->pattern);
}
$name = $this->pattern;
return $this->pattern;
}
public function getChoiceLabel(Activity $activity): string
{
$name = $this->getPattern();
$name = str_replace(self::PATTERN_NAME, $activity->getName(), $name);
$name = str_replace(self::PATTERN_COMMENT, $activity->getComment(), $name);
$name = str_replace(self::PATTERN_SPACER, self::SPACER, $name);
$name = ltrim($name, self::SPACER);
$name = rtrim($name, self::SPACER);
@@ -130,6 +138,13 @@ class ActivityType extends AbstractType
});
}
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['attr'] = array_merge($view->vars['attr'], [
'data-option-pattern' => $this->getPattern(),
]);
}
/**
* {@inheritdoc}
*/

View File

@@ -16,6 +16,8 @@ use App\Repository\Query\CustomerFormTypeQuery;
use App\Repository\Query\ProjectQuery;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -39,7 +41,7 @@ class CustomerType extends AbstractType
$this->configuration = $configuration;
}
public function getChoiceLabel(Customer $customer): string
private function getPattern(): string
{
if ($this->pattern === null) {
$this->pattern = $this->configuration->find('customer.choice_pattern');
@@ -47,14 +49,20 @@ class CustomerType extends AbstractType
if ($this->pattern === null || stripos($this->pattern, '{') === false || stripos($this->pattern, '}') === false) {
$this->pattern = self::PATTERN_NAME;
}
$this->pattern = str_replace(self::PATTERN_SPACER, self::SPACER, $this->pattern);
}
$name = $this->pattern;
return $this->pattern;
}
public function getChoiceLabel(Customer $customer): string
{
$name = $this->getPattern();
$name = str_replace(self::PATTERN_NAME, $customer->getName(), $name);
$name = str_replace(self::PATTERN_COMMENT, $customer->getComment(), $name);
$name = str_replace(self::PATTERN_NUMBER, $customer->getNumber(), $name);
$name = str_replace(self::PATTERN_COMPANY, $customer->getCompany() ?? $customer->getName(), $name);
$name = str_replace(self::PATTERN_SPACER, self::SPACER, $name);
$name = ltrim($name, self::SPACER);
$name = rtrim($name, self::SPACER);
@@ -147,6 +155,13 @@ class CustomerType extends AbstractType
});
}
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['attr'] = array_merge($view->vars['attr'], [
'data-option-pattern' => $this->getPattern(),
]);
}
/**
* {@inheritdoc}
*/

View File

@@ -9,8 +9,13 @@
namespace App\Form\Type;
use App\Entity\MetaTableTypeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
@@ -18,6 +23,23 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
class MetaFieldsCollectionType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function (FormEvent $event) {
/** @var ArrayCollection<MetaTableTypeInterface> $collection */
$collection = $event->getData();
foreach ($collection as $collectionItem) {
$collection->removeElement($collectionItem);
$collection->set($collectionItem->getName(), $collectionItem);
}
},
// must be a higher priority then the listener in EntityMetaDefinitionType
100
);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([

View File

@@ -17,6 +17,8 @@ use App\Repository\Query\ProjectFormTypeQuery;
use App\Utils\LocaleSettings;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -45,52 +47,48 @@ class ProjectType extends AbstractType
$this->localeSettings = $localeSettings;
}
public function getChoiceLabel(Project $project): string
private function getPattern(): string
{
if ($this->dateFormat === null) {
$this->dateFormat = $this->localeSettings->getDateFormat();
}
if ($this->pattern === null) {
$this->pattern = $this->configuration->find('project.choice_pattern');
if ($this->pattern === null || stripos($this->pattern, '{') === false || stripos($this->pattern, '}') === false) {
$this->pattern = self::PATTERN_NAME;
}
$this->pattern = str_replace(self::PATTERN_DATERANGE, self::PATTERN_START . '-' . self::PATTERN_END, $this->pattern);
$this->pattern = str_replace(self::PATTERN_SPACER, self::SPACER, $this->pattern);
}
$dateRange = '';
if ($project->getStart() !== null) {
$dateRange = self::PATTERN_START;
}
if ($project->getEnd() !== null) {
if ($dateRange !== '') {
$dateRange .= '-';
}
$dateRange .= self::PATTERN_END;
return $this->pattern;
}
public function getChoiceLabel(Project $project): string
{
if ($this->dateFormat === null) {
$this->dateFormat = $this->localeSettings->getDateFormat();
}
$start = '';
$start = '?';
if ($project->getStart() !== null) {
$start = $project->getStart()->format($this->dateFormat);
}
$end = '';
$end = '?';
if ($project->getEnd() !== null) {
$end = $project->getEnd()->format($this->dateFormat);
}
$name = $this->pattern;
$name = $this->getPattern();
$name = str_replace(self::PATTERN_NAME, $project->getName(), $name);
$name = str_replace(self::PATTERN_COMMENT, $project->getComment(), $name);
$name = str_replace(self::PATTERN_ORDERNUMBER, $project->getOrderNumber(), $name);
$name = str_replace(self::PATTERN_DATERANGE, $dateRange, $name);
$name = str_replace(self::PATTERN_START, $start, $name);
$name = str_replace(self::PATTERN_END, $end, $name);
$name = str_replace(self::PATTERN_SPACER, self::SPACER, $name);
$name = ltrim($name, self::SPACER);
$name = rtrim($name, self::SPACER);
$name = str_replace('- ?-?', '', $name);
if ($name === '' || $name === self::SPACER) {
$name = $project->getName();
@@ -196,6 +194,13 @@ class ProjectType extends AbstractType
});
}
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['attr'] = array_merge($view->vars['attr'], [
'data-option-pattern' => $this->getPattern(),
]);
}
/**
* {@inheritdoc}
*/