support custom fields in timesheet batch update (#2043)
This commit is contained in:
@@ -47,7 +47,7 @@ export default class KimaiDateRangePicker extends KimaiPlugin {
|
|||||||
showDropdowns: true,
|
showDropdowns: true,
|
||||||
autoUpdateInput: false,
|
autoUpdateInput: false,
|
||||||
autoApply: false,
|
autoApply: false,
|
||||||
linkedCalendars: false,
|
linkedCalendars: true,
|
||||||
locale: {
|
locale: {
|
||||||
separator: separator,
|
separator: separator,
|
||||||
format: localeFormat,
|
format: localeFormat,
|
||||||
|
|||||||
@@ -26,3 +26,4 @@
|
|||||||
@import 'autocomplete';
|
@import 'autocomplete';
|
||||||
@import 'selectpicker';
|
@import 'selectpicker';
|
||||||
@import 'reporting';
|
@import 'reporting';
|
||||||
|
@import 'forms';
|
||||||
|
|||||||
8
assets/sass/forms.scss
Normal file
8
assets/sass/forms.scss
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
/* Currently only used in batch-update form for timesheets, to highlight sections of combined fields */
|
||||||
|
form fieldset {
|
||||||
|
border-radius: $box-border-radius;
|
||||||
|
padding: 10px;
|
||||||
|
&:hover {
|
||||||
|
background-color: $highlight-bg;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,8 +7,11 @@
|
|||||||
|
|
||||||
@import "~bootstrap-sass/assets/stylesheets/bootstrap/variables";
|
@import "~bootstrap-sass/assets/stylesheets/bootstrap/variables";
|
||||||
|
|
||||||
|
/* For highlighting rows, fieldsets and so on */
|
||||||
|
$highlight-bg: #f5f5f5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple one to one clone of /node_modules/admin-lte/build/less/variables.less
|
* BELOW: A simple one to one clone of /node_modules/admin-lte/build/less/variables.less
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// COLORS
|
// COLORS
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -5,10 +5,10 @@
|
|||||||
"build/runtime.098eaae1.js",
|
"build/runtime.098eaae1.js",
|
||||||
"build/0.79dbdbb9.js",
|
"build/0.79dbdbb9.js",
|
||||||
"build/1.32489d92.js",
|
"build/1.32489d92.js",
|
||||||
"build/app.76d084be.js"
|
"build/app.4754599e.js"
|
||||||
],
|
],
|
||||||
"css": [
|
"css": [
|
||||||
"build/app.c511f79e.css"
|
"build/app.0325b7e0.css"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"invoice": {
|
"invoice": {
|
||||||
@@ -53,8 +53,8 @@
|
|||||||
"build/runtime.098eaae1.js": "sha384-xNNrNinl64G3nCUrIskgSjU0mUXXCB9lj6XCSInBTwxSKXk8uTMafnLHtdWdIGtd",
|
"build/runtime.098eaae1.js": "sha384-xNNrNinl64G3nCUrIskgSjU0mUXXCB9lj6XCSInBTwxSKXk8uTMafnLHtdWdIGtd",
|
||||||
"build/0.79dbdbb9.js": "sha384-U2Ao0ORAZ8PCeDmyRsqQFET3hc7pfUBimq0PrqFdG4/s0Bdi+qBj4TJK3o70bCd5",
|
"build/0.79dbdbb9.js": "sha384-U2Ao0ORAZ8PCeDmyRsqQFET3hc7pfUBimq0PrqFdG4/s0Bdi+qBj4TJK3o70bCd5",
|
||||||
"build/1.32489d92.js": "sha384-wVkjh5FzjFhMV4S4uNP23E/OLBOf+Zi7t3lpm9eWzoMr/tm2pydT+q0Op1XHuoUP",
|
"build/1.32489d92.js": "sha384-wVkjh5FzjFhMV4S4uNP23E/OLBOf+Zi7t3lpm9eWzoMr/tm2pydT+q0Op1XHuoUP",
|
||||||
"build/app.76d084be.js": "sha384-yM6ASc4oYtMiSBKYvWtHo0JVPwn8nn+uNKoOVucyiscoBnPnxAo1wQm1novmO0Zf",
|
"build/app.4754599e.js": "sha384-6/aM4p2+WAPkoB8d7U8hGF6wa/lRw6iaJo/azDIqxzaI/LX+mHi49J3En5BPfdRL",
|
||||||
"build/app.c511f79e.css": "sha384-nNQjHz/ANcTsbW+KXD3MQPQw3mvCV8QpDhcLXByo2HQL2wx4CjmlWatCGd9+yDwN",
|
"build/app.0325b7e0.css": "sha384-+e2X/+hgWNDL4q30jFlPjC+jD61G/j9nsyn+KO57Pakrq5XH5sjMuamVPtwgnDlG",
|
||||||
"build/invoice.74279541.js": "sha384-2BXic5Sgorf2tXai6zSAN4wLY2dbg06L03/xMKW6itMcszvtnRArKzfBh6DNcF3f",
|
"build/invoice.74279541.js": "sha384-2BXic5Sgorf2tXai6zSAN4wLY2dbg06L03/xMKW6itMcszvtnRArKzfBh6DNcF3f",
|
||||||
"build/invoice.13d8ef4e.css": "sha384-B6RN/wZJToSBCZk2JeLokIqWEhbh+Eb9arYbt9dM+YoC2Z6PnCeTwTqSGyexWWJh",
|
"build/invoice.13d8ef4e.css": "sha384-B6RN/wZJToSBCZk2JeLokIqWEhbh+Eb9arYbt9dM+YoC2Z6PnCeTwTqSGyexWWJh",
|
||||||
"build/invoice-pdf.0efd7a97.js": "sha384-bSdIeRCtEJiYYuc2reb0e5CpJ1Kbd1lQNEkElMTiq1SX0IINzdwJJYf6WnCcHrNC",
|
"build/invoice-pdf.0efd7a97.js": "sha384-bSdIeRCtEJiYYuc2reb0e5CpJ1Kbd1lQNEkElMTiq1SX0IINzdwJJYf6WnCcHrNC",
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
"build/0.79dbdbb9.js": "build/0.79dbdbb9.js",
|
"build/0.79dbdbb9.js": "build/0.79dbdbb9.js",
|
||||||
"build/1.32489d92.js": "build/1.32489d92.js",
|
"build/1.32489d92.js": "build/1.32489d92.js",
|
||||||
"build/2.7ab75d0a.js": "build/2.7ab75d0a.js",
|
"build/2.7ab75d0a.js": "build/2.7ab75d0a.js",
|
||||||
"build/app.css": "build/app.c511f79e.css",
|
"build/app.css": "build/app.0325b7e0.css",
|
||||||
"build/app.js": "build/app.76d084be.js",
|
"build/app.js": "build/app.4754599e.js",
|
||||||
"build/calendar.css": "build/calendar.1408f57e.css",
|
"build/calendar.css": "build/calendar.1408f57e.css",
|
||||||
"build/calendar.js": "build/calendar.f458a712.js",
|
"build/calendar.js": "build/calendar.f458a712.js",
|
||||||
"build/chart.js": "build/chart.34d60a88.js",
|
"build/chart.js": "build/chart.34d60a88.js",
|
||||||
|
|||||||
@@ -270,6 +270,15 @@ abstract class TimesheetAbstractController extends AbstractController
|
|||||||
$dto->setEntities($form->getData()->getEntities());
|
$dto->setEntities($form->getData()->getEntities());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// using a new timesheet to make sure we ONLY use meta-fields which are registered via events
|
||||||
|
$fake = new Timesheet();
|
||||||
|
$event = new TimesheetMetaDefinitionEvent($fake);
|
||||||
|
$this->dispatcher->dispatch($event);
|
||||||
|
|
||||||
|
foreach ($fake->getMetaFields() as $field) {
|
||||||
|
$dto->setMetaField(clone $field);
|
||||||
|
}
|
||||||
|
|
||||||
$form = $this->getMultiUpdateForm($dto);
|
$form = $this->getMultiUpdateForm($dto);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
@@ -342,6 +351,17 @@ abstract class TimesheetAbstractController extends AbstractController
|
|||||||
$timesheet->setHourlyRate($dto->getHourlyRate());
|
$timesheet->setHourlyRate($dto->getHourlyRate());
|
||||||
$execute = true;
|
$execute = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($dto->getUpdateMeta() as $metaName) {
|
||||||
|
if (null !== ($metaField = $dto->getMetaField($metaName))) {
|
||||||
|
if (null !== ($timesheetMeta = $timesheet->getMetaField($metaName))) {
|
||||||
|
$timesheetMeta->setValue($metaField->getValue());
|
||||||
|
} else {
|
||||||
|
$timesheet->setMetaField(clone $metaField);
|
||||||
|
}
|
||||||
|
$execute = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($execute) {
|
if ($execute) {
|
||||||
|
|||||||
@@ -48,10 +48,6 @@ final class EnhancedChoiceTypeExtension extends AbstractTypeExtension
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($view->vars['attr'])) {
|
|
||||||
$view->vars['attr'] = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$extendedOptions = ['class' => 'selectpicker'];
|
$extendedOptions = ['class' => 'selectpicker'];
|
||||||
|
|
||||||
if (false !== $options['width']) {
|
if (false !== $options['width']) {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ use App\Form\Type\InvoiceRendererType;
|
|||||||
use App\Form\Type\LanguageType;
|
use App\Form\Type\LanguageType;
|
||||||
use App\Form\Type\YesNoType;
|
use App\Form\Type\YesNoType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
@@ -62,16 +63,16 @@ class InvoiceTemplateForm extends AbstractType
|
|||||||
'label' => 'label.invoice_bank_account',
|
'label' => 'label.invoice_bank_account',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
])
|
])
|
||||||
->add('dueDays', TextType::class, [
|
->add('dueDays', IntegerType::class, [
|
||||||
'label' => 'label.due_days',
|
'label' => 'label.due_days',
|
||||||
])
|
])
|
||||||
->add('vat', NumberType::class, [
|
->add('vat', NumberType::class, [
|
||||||
'label' => 'label.vat',
|
'label' => 'label.vat',
|
||||||
'scale' => 2,
|
'scale' => 2,
|
||||||
])
|
])
|
||||||
->add('renderer', InvoiceRendererType::class, [])
|
->add('renderer', InvoiceRendererType::class)
|
||||||
->add('calculator', InvoiceCalculatorType::class, [])
|
->add('calculator', InvoiceCalculatorType::class)
|
||||||
->add('numberGenerator', InvoiceNumberGeneratorType::class, [])
|
->add('numberGenerator', InvoiceNumberGeneratorType::class)
|
||||||
->add('language', LanguageType::class, [
|
->add('language', LanguageType::class, [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use App\Form\Type\ActivityType;
|
|||||||
use App\Form\Type\CustomerType;
|
use App\Form\Type\CustomerType;
|
||||||
use App\Form\Type\FixedRateType;
|
use App\Form\Type\FixedRateType;
|
||||||
use App\Form\Type\HourlyRateType;
|
use App\Form\Type\HourlyRateType;
|
||||||
|
use App\Form\Type\MetaFieldsCollectionType;
|
||||||
use App\Form\Type\ProjectType;
|
use App\Form\Type\ProjectType;
|
||||||
use App\Form\Type\TagsType;
|
use App\Form\Type\TagsType;
|
||||||
use App\Form\Type\UserType;
|
use App\Form\Type\UserType;
|
||||||
@@ -60,6 +61,7 @@ class TimesheetMultiUpdate extends AbstractType
|
|||||||
$project = null;
|
$project = null;
|
||||||
$customer = null;
|
$customer = null;
|
||||||
$currency = null;
|
$currency = null;
|
||||||
|
$entry = null;
|
||||||
$customerCount = $this->customers->countCustomer(true);
|
$customerCount = $this->customers->countCustomer(true);
|
||||||
|
|
||||||
if (isset($options['data'])) {
|
if (isset($options['data'])) {
|
||||||
@@ -119,6 +121,7 @@ class TimesheetMultiUpdate extends AbstractType
|
|||||||
);
|
);
|
||||||
|
|
||||||
// replaces the project select after submission, to make sure only projects for the selected customer are displayed
|
// replaces the project select after submission, to make sure only projects for the selected customer are displayed
|
||||||
|
// TODO replace me with FormTrait
|
||||||
$builder->addEventListener(
|
$builder->addEventListener(
|
||||||
FormEvents::PRE_SUBMIT,
|
FormEvents::PRE_SUBMIT,
|
||||||
function (FormEvent $event) use ($builder, $project, $customer) {
|
function (FormEvent $event) use ($builder, $project, $customer) {
|
||||||
@@ -146,12 +149,14 @@ class TimesheetMultiUpdate extends AbstractType
|
|||||||
'required' => false,
|
'required' => false,
|
||||||
'placeholder' => '',
|
'placeholder' => '',
|
||||||
'query_builder' => function (ActivityRepository $repo) use ($activity, $project) {
|
'query_builder' => function (ActivityRepository $repo) use ($activity, $project) {
|
||||||
|
// TODO respect user (team permission)
|
||||||
return $repo->getQueryBuilderForFormType(new ActivityFormTypeQuery($activity, $project));
|
return $repo->getQueryBuilderForFormType(new ActivityFormTypeQuery($activity, $project));
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
;
|
;
|
||||||
|
|
||||||
// replaces the activity select after submission, to make sure only activities for the selected project are displayed
|
// replaces the activity select after submission, to make sure only activities for the selected project are displayed
|
||||||
|
// TODO replace me with FormTrait
|
||||||
$builder->addEventListener(
|
$builder->addEventListener(
|
||||||
FormEvents::PRE_SUBMIT,
|
FormEvents::PRE_SUBMIT,
|
||||||
function (FormEvent $event) use ($activity) {
|
function (FormEvent $event) use ($activity) {
|
||||||
@@ -164,6 +169,7 @@ class TimesheetMultiUpdate extends AbstractType
|
|||||||
'required' => false,
|
'required' => false,
|
||||||
'placeholder' => '',
|
'placeholder' => '',
|
||||||
'query_builder' => function (ActivityRepository $repo) use ($data, $activity) {
|
'query_builder' => function (ActivityRepository $repo) use ($data, $activity) {
|
||||||
|
// TODO respect user (team permission)
|
||||||
return $repo->getQueryBuilderForFormType(new ActivityFormTypeQuery($activity, $data['project']));
|
return $repo->getQueryBuilderForFormType(new ActivityFormTypeQuery($activity, $data['project']));
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -215,6 +221,25 @@ class TimesheetMultiUpdate extends AbstractType
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// meta fields only if at least one exists
|
||||||
|
if ($entry !== null && $entry->getMetaFields()->count() > 0) {
|
||||||
|
$builder->add('metaFields', MetaFieldsCollectionType::class);
|
||||||
|
|
||||||
|
$choices = [];
|
||||||
|
foreach ($entry->getMetaFields() as $field) {
|
||||||
|
$name = $field->getName();
|
||||||
|
$label = $entry->getMetaField($name)->getLabel();
|
||||||
|
$choices[$label] = $name;
|
||||||
|
}
|
||||||
|
$builder->add('updateMeta', ChoiceType::class, [
|
||||||
|
'choices' => $choices,
|
||||||
|
'multiple' => true,
|
||||||
|
'expanded' => true,
|
||||||
|
'label' => 'label.batch_meta_fields',
|
||||||
|
'help' => 'help.batch_meta_fields',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
$builder->add('entities', HiddenType::class, [
|
$builder->add('entities', HiddenType::class, [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -11,15 +11,19 @@ namespace App\Form\MultiUpdate;
|
|||||||
|
|
||||||
use App\Entity\Activity;
|
use App\Entity\Activity;
|
||||||
use App\Entity\Customer;
|
use App\Entity\Customer;
|
||||||
|
use App\Entity\EntityWithMetaFields;
|
||||||
|
use App\Entity\MetaTableTypeInterface;
|
||||||
use App\Entity\Project;
|
use App\Entity\Project;
|
||||||
use App\Entity\Tag;
|
use App\Entity\Tag;
|
||||||
|
use App\Entity\TimesheetMeta;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @App\Validator\Constraints\TimesheetMultiUpdate
|
* @App\Validator\Constraints\TimesheetMultiUpdate
|
||||||
*/
|
*/
|
||||||
class TimesheetMultiUpdateDTO extends MultiUpdateTableDTO
|
class TimesheetMultiUpdateDTO extends MultiUpdateTableDTO implements EntityWithMetaFields
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Tag[]|ArrayCollection|iterable
|
* @var Tag[]|ArrayCollection|iterable
|
||||||
@@ -61,6 +65,19 @@ class TimesheetMultiUpdateDTO extends MultiUpdateTableDTO
|
|||||||
* @var float|null
|
* @var float|null
|
||||||
*/
|
*/
|
||||||
private $hourlyRate = null;
|
private $hourlyRate = null;
|
||||||
|
/**
|
||||||
|
* @var TimesheetMeta[]|Collection
|
||||||
|
*/
|
||||||
|
private $meta;
|
||||||
|
/**
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
private $updateMeta = [];
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->meta = new ArrayCollection();
|
||||||
|
}
|
||||||
|
|
||||||
public function getCustomer(): ?Customer
|
public function getCustomer(): ?Customer
|
||||||
{
|
{
|
||||||
@@ -184,4 +201,52 @@ class TimesheetMultiUpdateDTO extends MultiUpdateTableDTO
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return TimesheetMeta[]|Collection
|
||||||
|
*/
|
||||||
|
public function getMetaFields(): Collection
|
||||||
|
{
|
||||||
|
return $this->meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMetaField(string $name): ?MetaTableTypeInterface
|
||||||
|
{
|
||||||
|
foreach ($this->meta as $field) {
|
||||||
|
if (strtolower($field->getName()) === strtolower($name)) {
|
||||||
|
return $field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMetaField(MetaTableTypeInterface $meta): EntityWithMetaFields
|
||||||
|
{
|
||||||
|
$this->updateMeta[$meta->getName()] = $meta->getName();
|
||||||
|
if (null === ($current = $this->getMetaField($meta->getName()))) {
|
||||||
|
$this->meta->add($meta);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
$current->merge($meta);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUpdateMeta(array $names): EntityWithMetaFields
|
||||||
|
{
|
||||||
|
$this->updateMeta = $names;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function getUpdateMeta(): array
|
||||||
|
{
|
||||||
|
return $this->updateMeta;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,12 +146,23 @@ abstract class AbstractToolbarForm extends AbstractType
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addDateRangeChoice(FormBuilderInterface $builder, $allowEmpty = true, $required = false)
|
protected function addDateRange(FormBuilderInterface $builder, array $options, $allowEmpty = true, $required = false)
|
||||||
{
|
{
|
||||||
$builder->add('daterange', DateRangeType::class, [
|
$params = [
|
||||||
'required' => $required,
|
'required' => $required,
|
||||||
'allow_empty' => $allowEmpty,
|
'allow_empty' => $allowEmpty,
|
||||||
]);
|
];
|
||||||
|
|
||||||
|
if (\array_key_exists('timezone', $options)) {
|
||||||
|
$params['timezone'] = $options['timezone'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$builder->add('daterange', DateRangeType::class, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function addDateRangeChoice(FormBuilderInterface $builder, $allowEmpty = true, $required = false)
|
||||||
|
{
|
||||||
|
$this->addDateRange($builder, [], $allowEmpty, $required);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addProjectChoice(FormBuilderInterface $builder, array $options = [], bool $multiCustomer = false, bool $multiActivity = false)
|
protected function addProjectChoice(FormBuilderInterface $builder, array $options = [], bool $multiCustomer = false, bool $multiActivity = false)
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ use App\Timesheet\UserDateTimeFactory;
|
|||||||
use App\Utils\LocaleSettings;
|
use App\Utils\LocaleSettings;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,20 +22,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
*/
|
*/
|
||||||
class DatePickerType extends AbstractType
|
class DatePickerType extends AbstractType
|
||||||
{
|
{
|
||||||
/**
|
private $localeSettings;
|
||||||
* @var LocaleSettings
|
private $dateTime;
|
||||||
*/
|
|
||||||
protected $localeSettings;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var UserDateTimeFactory
|
|
||||||
*/
|
|
||||||
protected $dateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param LocaleSettings $localeSettings
|
|
||||||
* @param UserDateTimeFactory $dateTime
|
|
||||||
*/
|
|
||||||
public function __construct(LocaleSettings $localeSettings, UserDateTimeFactory $dateTime)
|
public function __construct(LocaleSettings $localeSettings, UserDateTimeFactory $dateTime)
|
||||||
{
|
{
|
||||||
$this->localeSettings = $localeSettings;
|
$this->localeSettings = $localeSettings;
|
||||||
@@ -58,14 +48,16 @@ class DatePickerType extends AbstractType
|
|||||||
'model_timezone' => $timezone,
|
'model_timezone' => $timezone,
|
||||||
'view_timezone' => $timezone,
|
'view_timezone' => $timezone,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
$resolver->setDefault('attr', function (Options $options) {
|
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||||
return [
|
{
|
||||||
'autocomplete' => 'off',
|
$view->vars['attr'] = array_merge($view->vars['attr'], [
|
||||||
'placeholder' => $options['format'],
|
'data-datepickerenable' => 'on',
|
||||||
'data-format' => $options['format_picker'],
|
'autocomplete' => 'off',
|
||||||
];
|
'placeholder' => strtoupper($options['format']),
|
||||||
});
|
'data-format' => $options['format_picker'],
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ use Symfony\Component\Form\CallbackTransformer;
|
|||||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
@@ -30,16 +32,12 @@ class DateRangeType extends AbstractType
|
|||||||
/**
|
/**
|
||||||
* @var LocaleSettings
|
* @var LocaleSettings
|
||||||
*/
|
*/
|
||||||
protected $localeSettings;
|
private $localeSettings;
|
||||||
/**
|
/**
|
||||||
* @var UserDateTimeFactory
|
* @var UserDateTimeFactory
|
||||||
*/
|
*/
|
||||||
protected $dateFactory;
|
private $dateFactory;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param LocaleSettings $localeSettings
|
|
||||||
* @param UserDateTimeFactory $dateTime
|
|
||||||
*/
|
|
||||||
public function __construct(LocaleSettings $localeSettings, UserDateTimeFactory $dateTime)
|
public function __construct(LocaleSettings $localeSettings, UserDateTimeFactory $dateTime)
|
||||||
{
|
{
|
||||||
$this->localeSettings = $localeSettings;
|
$this->localeSettings = $localeSettings;
|
||||||
@@ -55,23 +53,23 @@ class DateRangeType extends AbstractType
|
|||||||
$dateFormat = $this->localeSettings->getDateFormat();
|
$dateFormat = $this->localeSettings->getDateFormat();
|
||||||
|
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'model_timezone' => null,
|
'timezone' => date_default_timezone_get(),
|
||||||
'view_timezone' => null,
|
|
||||||
'label' => 'label.daterange',
|
'label' => 'label.daterange',
|
||||||
'format' => $dateFormat,
|
'format' => $dateFormat,
|
||||||
'separator' => self::DATE_SPACER,
|
'separator' => self::DATE_SPACER,
|
||||||
'format_picker' => $pickerFormat,
|
'format_picker' => $pickerFormat,
|
||||||
'allow_empty' => true,
|
'allow_empty' => true,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
$resolver->setDefault('attr', function (Options $options) {
|
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||||
return [
|
{
|
||||||
'autocomplete' => 'off',
|
$view->vars['attr'] = array_merge($view->vars['attr'], [
|
||||||
'placeholder' => $options['format_picker'] . $options['separator'] . $options['format_picker'],
|
'autocomplete' => 'off',
|
||||||
'data-format' => $options['format_picker'],
|
'placeholder' => strtoupper($options['format_picker']) . $options['separator'] . strtoupper($options['format_picker']),
|
||||||
'data-separator' => $options['separator'],
|
'data-format' => $options['format_picker'],
|
||||||
];
|
'data-separator' => $options['separator'],
|
||||||
});
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -129,6 +127,8 @@ class DateRangeType extends AbstractType
|
|||||||
$formatDate = $options['format'];
|
$formatDate = $options['format'];
|
||||||
$separator = $options['separator'];
|
$separator = $options['separator'];
|
||||||
$allowEmpty = $options['allow_empty'];
|
$allowEmpty = $options['allow_empty'];
|
||||||
|
//$timezone = new \DateTimeZone($options['timezone']);
|
||||||
|
$timezone = $this->dateFactory->getTimezone();
|
||||||
$pattern = $this->formatToPattern($formatDate, $separator);
|
$pattern = $this->formatToPattern($formatDate, $separator);
|
||||||
|
|
||||||
$builder->addModelTransformer(new CallbackTransformer(
|
$builder->addModelTransformer(new CallbackTransformer(
|
||||||
@@ -152,7 +152,7 @@ class DateRangeType extends AbstractType
|
|||||||
|
|
||||||
return $display;
|
return $display;
|
||||||
},
|
},
|
||||||
function ($dates) use ($formatDate, $pattern, $separator, $allowEmpty) {
|
function ($dates) use ($formatDate, $pattern, $separator, $allowEmpty, $timezone) {
|
||||||
$range = new DateRange();
|
$range = new DateRange();
|
||||||
|
|
||||||
if (empty($dates) && $allowEmpty) {
|
if (empty($dates) && $allowEmpty) {
|
||||||
@@ -171,13 +171,13 @@ class DateRangeType extends AbstractType
|
|||||||
throw new TransformationFailedException('Invalid date range given');
|
throw new TransformationFailedException('Invalid date range given');
|
||||||
}
|
}
|
||||||
|
|
||||||
$begin = \DateTime::createFromFormat($formatDate, $values[0], $this->dateFactory->getTimezone());
|
$begin = \DateTime::createFromFormat($formatDate, $values[0], $timezone);
|
||||||
if ($begin === false) {
|
if ($begin === false) {
|
||||||
throw new TransformationFailedException('Invalid begin date given');
|
throw new TransformationFailedException('Invalid begin date given');
|
||||||
}
|
}
|
||||||
$range->setBegin($begin);
|
$range->setBegin($begin);
|
||||||
|
|
||||||
$end = \DateTime::createFromFormat($formatDate, $values[1], $this->dateFactory->getTimezone());
|
$end = \DateTime::createFromFormat($formatDate, $values[1], $timezone);
|
||||||
if ($end === false) {
|
if ($end === false) {
|
||||||
throw new TransformationFailedException('Invalid end date given');
|
throw new TransformationFailedException('Invalid end date given');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ use App\Timesheet\UserDateTimeFactory;
|
|||||||
use App\Utils\LocaleSettings;
|
use App\Utils\LocaleSettings;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
|
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,22 +62,17 @@ class DateTimePickerType extends AbstractType
|
|||||||
'with_seconds' => false,
|
'with_seconds' => false,
|
||||||
'model_timezone' => $timezone,
|
'model_timezone' => $timezone,
|
||||||
'view_timezone' => $timezone,
|
'view_timezone' => $timezone,
|
||||||
'autofocus' => false,
|
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
$resolver->setDefault('attr', function (Options $options) {
|
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||||
$values = [
|
{
|
||||||
'data-datetimepicker' => 'on',
|
$view->vars['attr'] = array_merge($view->vars['attr'], [
|
||||||
'autocomplete' => 'off',
|
'data-datetimepicker' => 'on',
|
||||||
'placeholder' => $options['format'],
|
'autocomplete' => 'off',
|
||||||
'data-format' => $options['format_picker'],
|
'placeholder' => strtoupper($options['format']),
|
||||||
];
|
'data-format' => $options['format_picker'],
|
||||||
if ($options['autofocus']) {
|
]);
|
||||||
$values['autofocus'] = 'autofocus';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $values;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,19 +11,15 @@ namespace App\Form\Type;
|
|||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use Symfony\Component\Form\FormView;
|
||||||
|
|
||||||
class DayTimeType extends AbstractType
|
class DayTimeType extends AbstractType
|
||||||
{
|
{
|
||||||
/**
|
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$view->vars['attr'] = array_merge($view->vars['attr'], [
|
||||||
'attr' => [
|
'placeholder' => 'hh:mm'
|
||||||
'placeholder' => 'hh:mm'
|
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,11 +42,20 @@ class EntityMetaDefinitionType extends AbstractType
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$attr = ['data-name' => $definition->getName()];
|
||||||
|
$options = $definition->getOptions();
|
||||||
|
|
||||||
|
if (\array_key_exists('attr', $options)) {
|
||||||
|
$attr = array_merge($attr, $options['attr']);
|
||||||
|
unset($options['attr']);
|
||||||
|
}
|
||||||
|
|
||||||
$event->getForm()->add('value', $definition->getType(), array_merge([
|
$event->getForm()->add('value', $definition->getType(), array_merge([
|
||||||
'label' => $definition->getLabel(),
|
'label' => $definition->getLabel(),
|
||||||
'constraints' => $definition->getConstraints(),
|
'constraints' => $definition->getConstraints(),
|
||||||
'required' => $definition->isRequired(),
|
'required' => $definition->isRequired(),
|
||||||
], $definition->getOptions()));
|
'attr' => $attr,
|
||||||
|
], $options));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer;
|
|||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
|
|
||||||
@@ -32,10 +34,6 @@ class TagsInputType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
private $router;
|
private $router;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param TagArrayToStringTransformer $transformer
|
|
||||||
* @param UrlGeneratorInterface $router
|
|
||||||
*/
|
|
||||||
public function __construct(TagArrayToStringTransformer $transformer, UrlGeneratorInterface $router)
|
public function __construct(TagArrayToStringTransformer $transformer, UrlGeneratorInterface $router)
|
||||||
{
|
{
|
||||||
$this->transformer = $transformer;
|
$this->transformer = $transformer;
|
||||||
@@ -58,17 +56,20 @@ class TagsInputType extends AbstractType
|
|||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
// documentation is for NelmioApiDocBundle
|
|
||||||
'documentation' => [
|
'documentation' => [
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => 'Comma separated list of tags',
|
'description' => 'Comma separated list of tags',
|
||||||
],
|
],
|
||||||
'label' => 'label.tag',
|
'label' => 'label.tag',
|
||||||
'attr' => [
|
]);
|
||||||
'data-autocomplete-url' => $this->router->generate('get_tags'),
|
}
|
||||||
'class' => 'js-autocomplete',
|
|
||||||
'autocomplete' => 'off',
|
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||||
]
|
{
|
||||||
|
$view->vars['attr'] = array_merge($view->vars['attr'], [
|
||||||
|
'data-autocomplete-url' => $this->router->generate('get_tags'),
|
||||||
|
'class' => 'js-autocomplete',
|
||||||
|
'autocomplete' => 'off',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,18 +21,23 @@
|
|||||||
{% endblock daterange_widget %}
|
{% endblock daterange_widget %}
|
||||||
|
|
||||||
{% block datetime_widget -%}
|
{% block datetime_widget -%}
|
||||||
{%- if widget == 'single_text' -%}
|
<div class="input-group">
|
||||||
<div class="input-group">
|
<div class="input-group-addon">
|
||||||
<div class="input-group-addon">
|
<a href="#" onclick="if (!$('#{{ id }}').is(':disabled')) { $('#{{ id }}').val(moment().format('{{ attr['data-format'] }}')).change(); }return false;"><i class="{{ 'calendar'|icon }}"></i></a>
|
||||||
<a href="#" onclick="$('#{{ id }}').val(moment().format('{{ attr['data-format'] }}')).trigger('change')"><i class="fa fa-calendar-alt"></i></a>
|
|
||||||
</div>
|
|
||||||
{{ block('form_widget_simple') }}
|
|
||||||
</div>
|
</div>
|
||||||
{%- else -%}
|
|
||||||
{{ block('form_widget_simple') }}
|
{{ block('form_widget_simple') }}
|
||||||
{%- endif -%}
|
</div>
|
||||||
{%- endblock datetime_widget %}
|
{%- endblock datetime_widget %}
|
||||||
|
|
||||||
|
{% block date_widget -%}
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-addon">
|
||||||
|
<a href="#" onclick="if (!$('#{{ id }}').is(':disabled')) { $('#{{ id }}').val(moment().format('{{ attr['data-format'] }}')).change(); }return false;"><i class="{{ 'calendar'|icon }}"></i></a>
|
||||||
|
</div>
|
||||||
|
{{ block('form_widget_simple') }}
|
||||||
|
</div>
|
||||||
|
{%- endblock date_widget %}
|
||||||
|
|
||||||
{% block text_widget -%}
|
{% block text_widget -%}
|
||||||
{% if icon is not empty %}
|
{% if icon is not empty %}
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
|
|||||||
@@ -8,6 +8,120 @@
|
|||||||
'form': form,
|
'form': form,
|
||||||
} %}
|
} %}
|
||||||
{% embed formEditTemplate with formOptions %}
|
{% embed formEditTemplate with formOptions %}
|
||||||
|
{% block form_body %}
|
||||||
|
<fieldset>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ form_row(form.customer) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ form_row(form.project) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ form_row(form.activity) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
{{ form_row(form.replaceTags) }}
|
||||||
|
{{ form_row(form.tags) }}
|
||||||
|
</fieldset>
|
||||||
|
{% if form.user is defined %}
|
||||||
|
<fieldset>
|
||||||
|
{{ form_row(form.user) }}
|
||||||
|
</fieldset>
|
||||||
|
{% endif %}
|
||||||
|
{% if form.exported is defined %}
|
||||||
|
<fieldset>
|
||||||
|
{{ form_row(form.exported) }}
|
||||||
|
</fieldset>
|
||||||
|
{% endif %}
|
||||||
|
{% if form.recalculateRates is defined %}
|
||||||
|
<fieldset>
|
||||||
|
{{ form_row(form.recalculateRates) }}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.fixedRate) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.hourlyRate) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
{% endif %}
|
||||||
|
{% if form.metaFields is defined %}
|
||||||
|
<fieldset>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.updateMeta) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.metaFields) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
{% endembed %}
|
{% endembed %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block javascripts %}
|
||||||
|
{{ parent() }}
|
||||||
|
<script type="text/javascript">
|
||||||
|
window.addEventListener('load', function() {
|
||||||
|
{% if form.recalculateRates is defined %}
|
||||||
|
document.getElementById('{{ form.recalculateRates.vars.id }}').onchange = function() {
|
||||||
|
if (this.checked) {
|
||||||
|
document.getElementById('{{ form.fixedRate.vars.id }}').setAttribute('disabled', 'disabled');
|
||||||
|
document.getElementById('{{ form.hourlyRate.vars.id }}').setAttribute('disabled', 'disabled');
|
||||||
|
} else {
|
||||||
|
document.getElementById('{{ form.fixedRate.vars.id }}').removeAttribute('disabled');
|
||||||
|
document.getElementById('{{ form.hourlyRate.vars.id }}').removeAttribute('disabled');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
{% endif %}
|
||||||
|
{% if form.metaFields is defined %}
|
||||||
|
var allElements = document.getElementsByName('{{ form.vars.name }}')[0].elements;
|
||||||
|
for (var i = 0; i < allElements.length; ++i) {
|
||||||
|
var el = allElements[i];
|
||||||
|
var elAttr = el.getAttribute('name');
|
||||||
|
if (elAttr === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (elAttr.indexOf('{{ form.metaFields.vars.full_name }}') !== -1) {
|
||||||
|
{# disable all custom fields, each one has to be activated before it can be used #}
|
||||||
|
el.setAttribute('disabled', 'disabled');
|
||||||
|
} else if (elAttr.indexOf('{{ form.updateMeta.vars.full_name }}') !== -1) {
|
||||||
|
el.checked = false;
|
||||||
|
el.onclick = function() {
|
||||||
|
var searchElements = document.getElementsByName('{{ form.vars.name }}')[0].elements;
|
||||||
|
var metaCheckbox = this;
|
||||||
|
var metaName = metaCheckbox.value;
|
||||||
|
for (var s = 0; s < searchElements.length; ++s) {
|
||||||
|
var current = searchElements[s];
|
||||||
|
var currentAttr = current.getAttribute('name');
|
||||||
|
if (currentAttr === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (currentAttr.indexOf('{{ form.metaFields.vars.full_name }}') === -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (current.dataset.name === undefined || current.dataset.name !== metaName) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (metaCheckbox.checked) {
|
||||||
|
current.removeAttribute('disabled');
|
||||||
|
} else {
|
||||||
|
current.setAttribute('disabled', 'disabled');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ use App\Entity\Activity;
|
|||||||
use App\Entity\Customer;
|
use App\Entity\Customer;
|
||||||
use App\Entity\Project;
|
use App\Entity\Project;
|
||||||
use App\Entity\Timesheet;
|
use App\Entity\Timesheet;
|
||||||
|
use App\Entity\TimesheetMeta;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Form\MultiUpdate\TimesheetMultiUpdateDTO;
|
use App\Form\MultiUpdate\TimesheetMultiUpdateDTO;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,6 +40,9 @@ class TimesheetMultiUpdateDTOTest extends TestCase
|
|||||||
self::assertFalse($sut->isReplaceTags());
|
self::assertFalse($sut->isReplaceTags());
|
||||||
self::assertNull($sut->getFixedRate());
|
self::assertNull($sut->getFixedRate());
|
||||||
self::assertNull($sut->getHourlyRate());
|
self::assertNull($sut->getHourlyRate());
|
||||||
|
self::assertInstanceOf(Collection::class, $sut->getMetaFields());
|
||||||
|
self::assertEmpty($sut->getMetaFields());
|
||||||
|
self::assertEquals([], $sut->getUpdateMeta());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetterAndGetter()
|
public function testSetterAndGetter()
|
||||||
@@ -97,5 +102,28 @@ class TimesheetMultiUpdateDTOTest extends TestCase
|
|||||||
|
|
||||||
self::assertInstanceOf(TimesheetMultiUpdateDTO::class, $sut->setHourlyRate(123.45));
|
self::assertInstanceOf(TimesheetMultiUpdateDTO::class, $sut->setHourlyRate(123.45));
|
||||||
self::assertEquals(123.45, $sut->getHourlyRate());
|
self::assertEquals(123.45, $sut->getHourlyRate());
|
||||||
|
|
||||||
|
self::assertInstanceOf(TimesheetMultiUpdateDTO::class, $sut->setUpdateMeta(['foo', 'bar']));
|
||||||
|
self::assertEquals(['foo', 'bar'], $sut->getUpdateMeta());
|
||||||
|
|
||||||
|
$meta = new TimesheetMeta();
|
||||||
|
$meta->setName('foo')->setValue('bar')->setType('hello');
|
||||||
|
self::assertInstanceOf(TimesheetMultiUpdateDTO::class, $sut->setMetaField($meta));
|
||||||
|
self::assertSame($meta, $sut->getMetaField('foo'));
|
||||||
|
self::assertEquals('bar', $sut->getMetaField('foo')->getValue());
|
||||||
|
self::assertEquals('hello', $sut->getMetaField('foo')->getType());
|
||||||
|
self::assertEquals(1, $sut->getMetaFields()->count());
|
||||||
|
|
||||||
|
$meta2 = new TimesheetMeta();
|
||||||
|
$meta2->setName('foo')->setValue('hello')->setType('world');
|
||||||
|
self::assertInstanceOf(TimesheetMultiUpdateDTO::class, $sut->setMetaField($meta2));
|
||||||
|
self::assertSame($meta, $sut->getMetaField('foo'));
|
||||||
|
self::assertEquals('bar', $sut->getMetaField('foo')->getValue());
|
||||||
|
self::assertEquals('world', $sut->getMetaField('foo')->getType());
|
||||||
|
self::assertEquals(1, $sut->getMetaFields()->count());
|
||||||
|
|
||||||
|
$meta2->setName('foo2')->setValue('hello')->setType('world');
|
||||||
|
self::assertInstanceOf(TimesheetMultiUpdateDTO::class, $sut->setMetaField($meta2));
|
||||||
|
self::assertEquals(2, $sut->getMetaFields()->count());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1110,6 +1110,14 @@
|
|||||||
<source>label.globalsOnly</source>
|
<source>label.globalsOnly</source>
|
||||||
<target>Nur globale</target>
|
<target>Nur globale</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="label.batch_meta_fields">
|
||||||
|
<source>label.batch_meta_fields</source>
|
||||||
|
<target>Zusätzliche Felder</target>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="help.batch_meta_fields">
|
||||||
|
<source>help.batch_meta_fields</source>
|
||||||
|
<target>Felder die aktualisiert werden sollen, müssen zunächst durch einen Klick auf die zugehörige Checkbox freigeschaltet werden.</target>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
|||||||
@@ -1132,6 +1132,14 @@
|
|||||||
<source>label.globalsOnly</source>
|
<source>label.globalsOnly</source>
|
||||||
<target>Only global</target>
|
<target>Only global</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="label.batch_meta_fields">
|
||||||
|
<source>label.batch_meta_fields</source>
|
||||||
|
<target>Additional fields</target>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="help.batch_meta_fields">
|
||||||
|
<source>help.batch_meta_fields</source>
|
||||||
|
<target>Fields that are to be updated must first be activated by clicking on the associated checkbox.</target>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
|||||||
Reference in New Issue
Block a user