Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions Resources/Public/JavaScript/paste-reference-drag-drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,9 @@ DragDrop.default = {

$(DragDrop.default.dropZoneIdentifier).not(DragDrop.default.ownDropZone).each(function () {
$(this).addClass(DragDrop.default.validDropZoneClass);
if (($(this).not(disabledDropZones).length
|| siblingsDropZones.length
) &&
$(this).parent().find('.icon-actions-add').length
if (
($(this).not(disabledDropZones).length || siblingsDropZones.length)
&& $(this).parent().find('.icon-actions-add').length
) {
$(this).addClass(DragDrop.default.validDropZoneClass);
} else {
Expand Down Expand Up @@ -173,6 +172,7 @@ DragDrop.default = {
*/
onDrop: function ($draggableElement, $droppableElement, evt, reference) {
const newColumn = DragDrop.default.getColumnPositionForElement($droppableElement) ?? 0;
const containerParent = DragDrop.default.getContainerParentForElement($droppableElement) ?? 0;

$droppableElement.removeClass(DragDrop.default.dropPossibleHoverClass);
const $pasteAction = typeof $draggableElement === 'number' || typeof $draggableElement === 'undefined';
Expand Down Expand Up @@ -261,6 +261,9 @@ DragDrop.default = {
if (evt === 'copyFromAnotherPage') {
parameters['CB'] = {setCopyMode: 1};
}
if (containerParent) {
parameters['cmd']['tt_content'][contentElementUid]['copy']['update']['tx_container_parent'] = containerParent;
}
// fire the request, and show a message if it has failed
// This is adding a copy from another page "to this [selected] place".
AjaxDataHandler.process(parameters).then(function (result) {
Expand Down Expand Up @@ -290,6 +293,9 @@ DragDrop.default = {
}
}
};
if (containerParent) {
parameters['cmd']['tt_content'][contentElementUid]['move']['update']['tx_container_parent'] = containerParent;
}
// fire the request, and show a message if it has failed
AjaxDataHandler.process(parameters).then(function (result) {
if (!result.hasErrors) {
Expand Down Expand Up @@ -323,6 +329,20 @@ DragDrop.default = {
} else {
return false;
}
},

/**
* returns the next "upper" container parent parameter inside the code
* @param $element
* @return int|boolean the containerParent
*/
getContainerParentForElement: function ($element) {
const $gridContainer = $element.closest('[data-tx-container-parent]');
if ($gridContainer.length && $gridContainer.data('txContainerParent') !== 'undefined') {
return $gridContainer.data('txContainerParent');
} else {
return false;
}
}
}

Expand Down
Loading