Skip to content

Commit

Permalink
Fix copy item in tree view - before wie have a "move" instead of copy
Browse files Browse the repository at this point in the history
  • Loading branch information
zonky2 committed Sep 11, 2024
1 parent 5f6e745 commit ec3806d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Contao/View/Contao2BackendView/ButtonRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
use ContaoCommunityAlliance\DcGeneral\Exception\DcGeneralInvalidArgumentException;
use ContaoCommunityAlliance\DcGeneral\InputProviderInterface;
use ContaoCommunityAlliance\Translator\TranslatorInterface;
use ContaoCommunityAlliance\UrlBuilder\UrlBuilder;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

use function array_filter;
Expand Down Expand Up @@ -232,7 +233,8 @@ private function renderButtonsFor(
if ($this->hasPasteButtons()) {
$urlAfter = $this->addToUrl(sprintf('act=paste&after=%s&', $modelId));
$urlInto = $this->addToUrl(sprintf('act=paste&into=%s&', $modelId));

$urlAfter = UrlBuilder::fromUrl($urlAfter)->unsetQueryParameter('source')->getUrl();
$urlInto = UrlBuilder::fromUrl($urlInto)->unsetQueryParameter('source')->getUrl();

$buttonEvent = new GetPasteButtonEvent($this->environment);
$buttonEvent
Expand Down
5 changes: 4 additions & 1 deletion src/Contao/View/Contao2BackendView/TreeView.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
use ContaoCommunityAlliance\DcGeneral\Panel\SortElementInterface;
use ContaoCommunityAlliance\DcGeneral\SessionStorageInterface;
use ContaoCommunityAlliance\Translator\TranslatorInterface;
use ContaoCommunityAlliance\UrlBuilder\UrlBuilder;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
Expand Down Expand Up @@ -606,9 +607,11 @@ protected function viewTree($collection)
ContaoEvents::BACKEND_ADD_TO_URL
);

$urlInto = UrlBuilder::fromUrl($urlEvent->getUrl())->unsetQueryParameter('source')->getUrl();

$buttonEvent = new GetPasteRootButtonEvent($environment);
$buttonEvent
->setHref($urlEvent->getUrl())
->setHref($urlInto)
->setPasteDisabled(false);

$dispatcher->dispatch($buttonEvent, $buttonEvent::NAME);
Expand Down

0 comments on commit ec3806d

Please sign in to comment.