diff --git a/Classes/EditingPanel/FrontendEditingPanel.php b/Classes/EditingPanel/FrontendEditingPanel.php index 8a94765e..175545c8 100644 --- a/Classes/EditingPanel/FrontendEditingPanel.php +++ b/Classes/EditingPanel/FrontendEditingPanel.php @@ -185,6 +185,7 @@ public function editIcons( $content = $wrapperService->wrapContentWithDropzone( $table, (int)$editUid, + $dataArr['pid'], $content, (int)$dataArr['colPos'] ); @@ -196,6 +197,7 @@ public function editIcons( $content = $wrapperService->wrapContentWithDropzone( $table, 0, + $dataArr['pid'], $content, (int)$dataArr['colPos'], [], diff --git a/Classes/Hook/FrontendEditingInitializationHook.php b/Classes/Hook/FrontendEditingInitializationHook.php index a48501f6..7d79abfb 100644 --- a/Classes/Hook/FrontendEditingInitializationHook.php +++ b/Classes/Hook/FrontendEditingInitializationHook.php @@ -210,7 +210,9 @@ public function main(array $params, TypoScriptFrontendController $parentObject) $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $endpointUrl = $uriBuilder->buildUriFromRoute( 'ajax_frontendediting_process', - ['page' => $this->typoScriptFrontendController->id] + ); + $ajaxRecordProcessEndpointUrl = $uriBuilder->buildUriFromRoute( + 'ajax_record_process', ); $configurationEndpointUrl = $uriBuilder->buildUriFromRoute( 'ajax_frontendediting_editorconfiguration', @@ -268,6 +270,7 @@ public function main(array $params, TypoScriptFrontendController $parentObject) editorConfigurationUrl: ' . GeneralUtility::quoteJSvalue($configurationEndpointUrl) . ' }); window.F.setEndpointUrl(' . GeneralUtility::quoteJSvalue($endpointUrl) . '); + window.F.setAjaxRecordProcessEndpointUrl(' . GeneralUtility::quoteJSvalue($ajaxRecordProcessEndpointUrl) . '); window.F.setBESessionId(' . GeneralUtility::quoteJSvalue($this->getBeSessionKey()) . '); window.F.setTranslationLabels(' . json_encode($this->getLocalizedFrontendLabels()) . '); window.F.setDisableModalOnNewCe(' . diff --git a/Classes/Service/ContentEditableWrapperService.php b/Classes/Service/ContentEditableWrapperService.php index fbba00e1..5f0e9496 100644 --- a/Classes/Service/ContentEditableWrapperService.php +++ b/Classes/Service/ContentEditableWrapperService.php @@ -209,7 +209,7 @@ public function wrapContent(string $table, int $uid, array $dataArr, string $con $inlineActionTagBuilder = GeneralUtility::makeInstance( TagBuilder::class, 'span', - $this->renderInlineActionIcons($table, $elementIsHidden, $recordTitle) + $this->renderInlineActionIcons($table, $elementIsHidden, $recordTitle, $dataArr['sys_language_uid'] ?? 0) ); $inlineActionTagBuilder->forceClosingTag(true); @@ -217,7 +217,7 @@ public function wrapContent(string $table, int $uid, array $dataArr, string $con 'style' => 'display:none;', 'class' => $class, 'data-table' => $table, - 'data-uid' => (int)$uid, + 'data-uid' => $uid, 'data-hidden' => (int)$elementIsHidden, 'data-cid' => $dataArr['colPos'] ?? 0, 'data-edit-url' => $this->renderEditOnClickReturnUrl($this->renderEditUrl($table, $uid)), @@ -236,6 +236,7 @@ public function wrapContent(string $table, int $uid, array $dataArr, string $con $tagBuilder->addAttributes([ 'class' => 't3-frontend-editing__ce ' . $hiddenElementClassName, 'title' => $recordTitle, + 'data-uid' => $uid, ]); return $tagBuilder->render(); @@ -256,6 +257,7 @@ public function wrapContent(string $table, int $uid, array $dataArr, string $con public function wrapContentWithDropzone( string $table, int $uid, + int $pid, string $content, int $colPos = 0, array $defaultValues = [], @@ -288,12 +290,13 @@ public function wrapContentWithDropzone( 'data-new-url' => $this->renderEditOnClickReturnUrl( $this->renderNewUrl( $table, - (int)$uid, - (int)$colPos, + $uid, + $colPos, $defaultValues ) ), - 'data-moveafter' => (int)$uid, + 'data-moveafter' => $uid, + 'data-pid' => $pid, 'data-colpos' => $colPos, 'data-defvals' => json_encode($defaultValues), ]); @@ -365,13 +368,14 @@ public function wrapContentWithCustomDropzone( * @param string $recordTitle * @return string */ - public function renderInlineActionIcons(string $table, bool $elementIsHidden, string $recordTitle = ''): string + public function renderInlineActionIcons(string $table, bool $elementIsHidden, string $recordTitle = '', int $langUid = 0): string { $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class); $dragAndDropHandleIcon = '' . $this->iconFactory->getIcon('actions-move', Icon::SIZE_SMALL)->render() . ''; diff --git a/Documentation/NewContentElements/Index.rst b/Documentation/NewContentElements/Index.rst index 3bd24734..185f2e85 100644 --- a/Documentation/NewContentElements/Index.rst +++ b/Documentation/NewContentElements/Index.rst @@ -48,6 +48,7 @@ It's possible to add drop zones for new content elements in a custom content ele $content = $wrapperService->wrapContentWithDropzone( 'tt_content', // table name + $uid, // CE uid -1, // page uid, pid $content, 0, // colPos diff --git a/Resources/Public/JavaScript/Crud.js b/Resources/Public/JavaScript/Crud.js index 9c0492d4..ebca1efd 100644 --- a/Resources/Public/JavaScript/Crud.js +++ b/Resources/Public/JavaScript/Crud.js @@ -54,6 +54,7 @@ define([ FrontendEditing.prototype.setBESessionId = setBESessionId; FrontendEditing.prototype.getEndpointUrl = getEndpointUrl; FrontendEditing.prototype.setEndpointUrl = setEndpointUrl; + FrontendEditing.prototype.setAjaxRecordProcessEndpointUrl = setAjaxRecordProcessEndpointUrl; var numberOfRequestsLeft; @@ -71,6 +72,12 @@ define([ this._endpointUrl = url; } + function setAjaxRecordProcessEndpointUrl (url) { + log.log('setAjaxRecordProcessEndpointUrl', url); + + this._ajaxRecordProcessEndpointUrl = url; + } + function getBESessionId () { return F._beSessionId; } @@ -292,36 +299,29 @@ define([ appendTriggers(jqxhr); } - function moveRecord (uid, table, beforeUid, colPos, defVals) { - var moveEndpoint = getEndpointUrl('move'); + function moveRecord (uid, beforeUid, colPos, languageUid) { + var moveEndpoint = F._ajaxRecordProcessEndpointUrl; log.info( - 'move record [moveEndpoint, uid, table, beforeUid, colPos, defVals]', + 'move record [moveEndpoint, uid, beforeUid, colPos, languageUid]', moveEndpoint, uid, - table, beforeUid, colPos, - defVals + languageUid ); this.trigger(F.REQUEST_START); - var data = { - uid: uid, - table: table, - beforeUid: beforeUid, - defVals: defVals - }; - - if (typeof colPos !== 'undefined') { - data.colPos = colPos; - } + moveEndpoint = moveEndpoint + + '&cmd[tt_content][' + uid + '][move][action]=paste' + + '&cmd[tt_content][' + uid + '][move][target]=' + beforeUid + + '&cmd[tt_content][' + uid + '][move][update][colPos]=' + colPos + + '&cmd[tt_content][' + uid + '][move][update][sys_language_uid]=' + languageUid + ; var jqxhr = $.ajax({ - url: moveEndpoint, - method: 'POST', - data: data + url: moveEndpoint }); appendTriggers(jqxhr); diff --git a/Resources/Public/JavaScript/FrontendEditing.js b/Resources/Public/JavaScript/FrontendEditing.js index d9a51673..d923d398 100644 --- a/Resources/Public/JavaScript/FrontendEditing.js +++ b/Resources/Public/JavaScript/FrontendEditing.js @@ -405,6 +405,7 @@ define([ ev.dataTransfer.setData('params', ev.currentTarget.dataset.params); ev.dataTransfer.setData('movable', movable); + ev.dataTransfer.setData('lang', ev.currentTarget.dataset.lang); ev.dataTransfer.setData('movableUid', $dragHandle .parent('span.t3-frontend-editing__inline-actions') .data('uid')); @@ -509,17 +510,25 @@ define([ if (movable === 1) { var $currentTarget = $(ev.currentTarget); var ceUid = parseInt(ev.dataTransfer.getData('movableUid'), 10); + var moveAfter = parseInt($currentTarget.data('moveafter'), 10); + // If the CE is dropped after an exising CE (moveAfter > 0), then 'target' is -uid of the existing CE + // If the CE is dropped as first in a column, then 'target' is the page uid + moveAfter = (moveAfter > 0) ? -moveAfter : parseInt($currentTarget.data('pid'), 10); + var colPos = parseInt($currentTarget.data('colpos'), 10); - var defVals = $currentTarget.data('defvals'); + // If the target drop area is descendant of another CE, then append the uid of this CE + var $parentCE = $currentTarget.closest('.t3-frontend-editing__ce'); + if ($parentCE.length) { + colPos = parseInt($parentCE.data('uid'), 10) + '-' + colPos; + } if (ceUid !== moveAfter) { F.moveContent( ceUid, - 'tt_content', moveAfter, colPos, - defVals + ev.dataTransfer.getData('lang') ); } } else {