diff --git a/src/Calendar/CalendarService.php b/src/Calendar/CalendarService.php
index 52c7e536..093eab78 100644
--- a/src/Calendar/CalendarService.php
+++ b/src/Calendar/CalendarService.php
@@ -67,8 +67,9 @@ final class CalendarService
$entries = [];
$colorHelper = new Color();
+ $copy = $this->configuration->isCalendarDragAndDropCopyData();
foreach ($recentActivity->getRecentActivities() as $timesheet) {
- $entries[] = new TimesheetEntry($timesheet, $colorHelper->getTimesheetColor($timesheet));
+ $entries[] = new TimesheetEntry($timesheet, $colorHelper->getTimesheetColor($timesheet), $copy);
}
$event->addSource(new RecentActivitiesSource($entries));
diff --git a/src/Calendar/TimesheetEntry.php b/src/Calendar/TimesheetEntry.php
index 1ff55e75..e2220f7f 100644
--- a/src/Calendar/TimesheetEntry.php
+++ b/src/Calendar/TimesheetEntry.php
@@ -13,6 +13,9 @@ use App\Entity\Activity;
use App\Entity\Project;
use App\Entity\Timesheet;
+/**
+ * @internal
+ */
final class TimesheetEntry implements DragAndDropEntry
{
/**
@@ -23,27 +26,31 @@ final class TimesheetEntry implements DragAndDropEntry
* @var string
*/
private $color;
+ /**
+ * @var bool
+ */
+ private $copy;
- public function __construct(Timesheet $timesheet, string $color)
+ public function __construct(Timesheet $timesheet, string $color, bool $copy = false)
{
$this->timesheet = $timesheet;
$this->color = $color;
+ $this->copy = $copy;
}
public function getData(): array
{
- $tags = null;
- if (!empty($this->timesheet->getTagsAsArray())) {
- $tags = implode(',', $this->timesheet->getTagsAsArray());
- }
-
- return [
- // restarting a timesheet should not copy the description - @version 1.21
- //'description' => $this->timesheet->getDescription(),
+ $data = [
'activity' => $this->timesheet->getActivity() !== null ? $this->timesheet->getActivity()->getId() : null,
'project' => $this->timesheet->getProject() !== null ? $this->timesheet->getProject()->getId() : null,
- 'tags' => $tags,
];
+
+ if ($this->copy) {
+ $data['description'] = $this->timesheet->getDescription();
+ $data['tags'] = implode(',', $this->timesheet->getTagsAsArray());
+ }
+
+ return $data;
}
public function getTitle(): string
diff --git a/src/Configuration/SystemConfiguration.php b/src/Configuration/SystemConfiguration.php
index 04b4a361..cf593780 100644
--- a/src/Configuration/SystemConfiguration.php
+++ b/src/Configuration/SystemConfiguration.php
@@ -180,6 +180,11 @@ class SystemConfiguration implements SystemBundleConfiguration
return (int) $this->find('calendar.dragdrop_amount');
}
+ public function isCalendarDragAndDropCopyData(): bool
+ {
+ return (bool) $this->find('calendar.dragdrop_data');
+ }
+
// ========== Customer configurations ==========
public function getCustomerDefaultTimezone(): ?string
diff --git a/src/Controller/SystemConfigurationController.php b/src/Controller/SystemConfigurationController.php
index f4312904..900e47c5 100644
--- a/src/Controller/SystemConfigurationController.php
+++ b/src/Controller/SystemConfigurationController.php
@@ -650,6 +650,10 @@ final class SystemConfigurationController extends AbstractController
->setTranslationDomain('system-configuration')
->setType(IntegerType::class)
->setConstraints([new Range(['min' => 0, 'max' => 20]), new NotNull()]),
+ (new Configuration())
+ ->setName('calendar.dragdrop_data')
+ ->setTranslationDomain('system-configuration')
+ ->setType(CheckboxType::class),
(new Configuration())
->setName('calendar.title_pattern')
->setTranslationDomain('system-configuration')
diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php
index f75f7dfb..4fd842b5 100644
--- a/src/DependencyInjection/Configuration.php
+++ b/src/DependencyInjection/Configuration.php
@@ -438,6 +438,7 @@ class Configuration implements ConfigurationInterface
->thenInvalid('The dragdrop_amount must be between 0 and 20')
->end()
->end()
+ ->booleanNode('dragdrop_data')->defaultFalse()->end()
->enumNode('title_pattern')
->values(['{activity}', '{project}', '{customer}', '{description}'])
->defaultValue('{activity}')
diff --git a/tests/Calendar/TimesheetEntryTest.php b/tests/Calendar/TimesheetEntryTest.php
index 85bac071..6806c9ca 100644
--- a/tests/Calendar/TimesheetEntryTest.php
+++ b/tests/Calendar/TimesheetEntryTest.php
@@ -37,7 +37,6 @@ class TimesheetEntryTest extends TestCase
$expectedData = [
'activity' => null,
'project' => null,
- 'tags' => 'bulb,action test',
];
$sut = new TimesheetEntry($timesheet, '#cccccc');
@@ -48,6 +47,17 @@ class TimesheetEntryTest extends TestCase
$this->assertSame($activity, $sut->getActivity());
$this->assertEquals('dd_timesheet', $sut->getBlockName());
$this->assertEquals($expectedData, $sut->getData());
+
+ $expectedData = [
+ 'activity' => null,
+ 'project' => null,
+ 'tags' => 'bulb,action test',
+ 'description' => 'hello foo bar',
+ ];
+
+ $sut = new TimesheetEntry($timesheet, '#cccccc', true);
+
+ $this->assertEquals($expectedData, $sut->getData());
}
public function testEmpty()
@@ -57,7 +67,6 @@ class TimesheetEntryTest extends TestCase
$expectedData = [
'activity' => null,
'project' => null,
- 'tags' => null,
];
$sut = new TimesheetEntry($timesheet, '#ddd');
diff --git a/tests/DependencyInjection/AppExtensionTest.php b/tests/DependencyInjection/AppExtensionTest.php
index 94b9e0b6..80445367 100644
--- a/tests/DependencyInjection/AppExtensionTest.php
+++ b/tests/DependencyInjection/AppExtensionTest.php
@@ -131,6 +131,7 @@ class AppExtensionTest extends TestCase
],
'weekends' => true,
'dragdrop_amount' => 10,
+ 'dragdrop_data' => false,
'title_pattern' => '{activity}',
],
'kimai.dashboard' => [],
diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php
index b8da8e5b..2b25e9a4 100644
--- a/tests/DependencyInjection/ConfigurationTest.php
+++ b/tests/DependencyInjection/ConfigurationTest.php
@@ -361,6 +361,7 @@ class ConfigurationTest extends TestCase
],
'weekends' => true,
'dragdrop_amount' => 10,
+ 'dragdrop_data' => false,
'title_pattern' => '{activity}',
],
'theme' => [
diff --git a/translations/system-configuration.de.xlf b/translations/system-configuration.de.xlf
index b4208bde..9d5d488a 100644
--- a/translations/system-configuration.de.xlf
+++ b/translations/system-configuration.de.xlf
@@ -310,6 +310,10 @@
label.calendar.dragdrop_amount
Anzahl an Einträgen für Drag&Drop (0 = deaktiviert)
+
+ label.calendar.dragdrop_data
+ Kopiert Daten beim Hinzufügen via Drag & Drop
+
label.calendar.title_pattern
Darstellung der Titel von Kalendereinträgen
diff --git a/translations/system-configuration.en.xlf b/translations/system-configuration.en.xlf
index b36d6d72..3b289c4e 100644
--- a/translations/system-configuration.en.xlf
+++ b/translations/system-configuration.en.xlf
@@ -310,6 +310,10 @@
label.calendar.dragdrop_amount
Amount of entries for drag&drop (0 = deactivated)
+
+ label.calendar.dragdrop_data
+ Copies data when adding via drag & drop
+
label.calendar.title_pattern
Display of the titles of calendar entries