configurable calendar drag and drop behavior (#3537)

This commit is contained in:
Kevin Papst
2022-09-14 23:29:26 +02:00
committed by GitHub
parent d705287510
commit 283ab80fc7
10 changed files with 50 additions and 13 deletions

View File

@@ -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));

View File

@@ -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