Commit c1be5540 authored by Benni Mack's avatar Benni Mack
Browse files

[BUGFIX] Fix Drag+Drop in Page Module in Workspaces

When using Drag+Drop in Page Module a different
functionality is used than using Clipboard (Move+Paste)
while moving a record in the page module.

This results in a different behaviour when dealing in Workspaces.

The patch uses the same "cmd" instead of "data"
for DataHandler now for Drag+Drop than in Clipboard.

Resolves: #92849
Releases: master, 10.4
Change-Id: Idb8566b166a18c514d149e53699489b7b9eb9247
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69137

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Richard Haeser's avatarRichard Haeser <richard@richardhaeser.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 73d836c0
......@@ -200,30 +200,24 @@ class DragDrop {
if (targetPid !== 0) {
colPos = newColumn;
}
parameters.cmd = {tt_content: {}};
parameters.data = {tt_content: {}};
const copyAction = (evt && (<JQueryInputEventObject>evt.originalEvent).ctrlKey || $droppableElement.hasClass('t3js-paste-copy'));
if (copyAction) {
parameters.cmd.tt_content[contentElementUid] = {
copy: {
action: 'paste',
target: targetPid,
update: {
colPos: colPos,
sys_language_uid: language,
},
},
};
} else {
parameters.data.tt_content[contentElementUid] = {
colPos: colPos,
sys_language_uid: language,
};
parameters.cmd.tt_content[contentElementUid] = {move: targetPid};
}
const isCopyAction = (evt && (<JQueryInputEventObject>evt.originalEvent).ctrlKey || $droppableElement.hasClass('t3js-paste-copy'));
const datahandlerCommand = isCopyAction ? 'copy' : 'move';
parameters.cmd = {
tt_content: {
[contentElementUid]: {
[datahandlerCommand]: {
action: 'paste',
target: targetPid,
update: {
colPos: colPos,
sys_language_uid: language,
},
}
}
}
};
DragDrop.ajaxAction($droppableElement, $draggableElement, parameters, copyAction).then((): void => {
DragDrop.ajaxAction($droppableElement, $draggableElement, parameters, isCopyAction).then((): void => {
const $languageDescriber = $(`.t3-page-column-lang-name[data-language-uid="${language}"]`);
if ($languageDescriber.length === 0) {
return;
......@@ -248,10 +242,10 @@ class DragDrop {
* @param {JQuery} $droppableElement
* @param {JQuery} $draggableElement
* @param {Parameters} parameters
* @param {boolean} copyAction
* @param {boolean} isCopyAction
* @private
*/
public static ajaxAction($droppableElement: JQuery, $draggableElement: JQuery, parameters: Parameters, copyAction: boolean): Promise<any> {
public static ajaxAction($droppableElement: JQuery, $draggableElement: JQuery, parameters: Parameters, isCopyAction: boolean): Promise<any> {
return DataHandler.process(parameters).then((result: ResponseInterface): void => {
if (result.hasErrors) {
throw result.messages;
......@@ -265,7 +259,7 @@ class DragDrop {
$draggableElement.detach().css({top: 0, left: 0})
.insertAfter($droppableElement.closest(DragDrop.contentIdentifier));
}
if (copyAction) {
if (isCopyAction) {
self.location.reload();
}
});
......
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","jquery","../AjaxDataHandler","../Icons","jquery-ui/droppable"],(function(e,t,a,n,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),a=__importDefault(a);class s{static initialize(){a.default(s.contentIdentifier).draggable({handle:s.dragHeaderIdentifier,scope:"tt_content",cursor:"move",distance:20,revert:"invalid",zIndex:100,start:e=>{s.onDragStart(a.default(e.target))},stop:e=>{s.onDragStop(a.default(e.target))}}),a.default(s.dropZoneIdentifier).droppable({accept:this.contentIdentifier,scope:"tt_content",tolerance:"pointer",over:(e,t)=>{s.onDropHoverOver(a.default(t.draggable),a.default(e.target))},out:(e,t)=>{s.onDropHoverOut(a.default(t.draggable),a.default(e.target))},drop:(e,t)=>{s.onDrop(a.default(t.draggable),a.default(e.target),e)}})}static onDragStart(e){s.originalStyles=e.get(0).style.cssText,e.children(s.dragIdentifier).addClass("dragitem-shadow"),e.append('<div class="ui-draggable-copy-message">'+TYPO3.lang["dragdrop.copy.message"]+"</div>"),e.children(s.dropZoneIdentifier).addClass("drag-start"),e.closest(s.columnIdentifier).removeClass("active"),e.find(s.dropZoneIdentifier).hide(),a.default(s.dropZoneIdentifier).each((e,t)=>{const n=a.default(t);n.parent().find(".t3js-toggle-new-content-element-wizard").length?n.addClass(s.validDropZoneClass):n.closest(s.contentIdentifier).find("> "+s.addContentIdentifier+", > > "+s.addContentIdentifier).show()})}static onDragStop(e){e.children(s.dragIdentifier).removeClass("dragitem-shadow"),e.children(s.dropZoneIdentifier).removeClass("drag-start"),e.closest(s.columnIdentifier).addClass("active"),e.find(s.dropZoneIdentifier).show(),e.find(".ui-draggable-copy-message").remove(),e.get(0).style.cssText=s.originalStyles,a.default(s.dropZoneIdentifier+"."+s.validDropZoneClass).removeClass(s.validDropZoneClass)}static onDropHoverOver(e,t){t.hasClass(s.validDropZoneClass)&&t.addClass(s.dropPossibleHoverClass)}static onDropHoverOut(e,t){t.removeClass(s.dropPossibleHoverClass)}static onDrop(e,t,n){const r=s.getColumnPositionForElement(t);t.removeClass(s.dropPossibleHoverClass);const d=parseInt(e.data("uid"),10);if("number"==typeof d&&d>0){let i={};const l=t.closest(s.contentIdentifier).data("uid");let c=0;c=void 0===l?parseInt(n.target.offsetParent.getAttribute("data-page"),10):0-parseInt(l,10);let g=parseInt(e.data("language-uid"),10);-1!==g&&(g=parseInt(t.closest("[data-language-uid]").data("language-uid"),10));let p=0;0!==c&&(p=r),i.cmd={tt_content:{}},i.data={tt_content:{}};const f=n&&n.originalEvent.ctrlKey||t.hasClass("t3js-paste-copy");f?i.cmd.tt_content[d]={copy:{action:"paste",target:c,update:{colPos:p,sys_language_uid:g}}}:(i.data.tt_content[d]={colPos:p,sys_language_uid:g},i.cmd.tt_content[d]={move:c}),s.ajaxAction(t,e,i,f).then(()=>{const t=a.default(`.t3-page-column-lang-name[data-language-uid="${g}"]`);if(0===t.length)return;const n=t.data("flagIdentifier"),s=t.data("languageTitle");e.find(".t3js-language-title").text(s),o.getIcon(n,o.sizes.small).then(t=>{e.find(".t3js-flag").attr("title",s).html(t)})})}}static ajaxAction(e,t,a,o){return n.process(a).then(a=>{if(a.hasErrors)throw a.messages;e.parent().hasClass(s.contentIdentifier.substring(1))?t.detach().css({top:0,left:0}).insertAfter(e.closest(s.contentIdentifier)):t.detach().css({top:0,left:0}).insertAfter(e.closest(s.dropZoneIdentifier)),o&&self.location.reload()})}static getColumnPositionForElement(e){const t=e.closest("[data-colpos]");return!(!t.length||"undefined"===t.data("colpos"))&&t.data("colpos")}}s.contentIdentifier=".t3js-page-ce",s.dragIdentifier=".t3-page-ce-dragitem",s.dragHeaderIdentifier=".t3js-page-ce-draghandle",s.dropZoneIdentifier=".t3js-page-ce-dropzone-available",s.columnIdentifier=".t3js-page-column",s.validDropZoneClass="active",s.dropPossibleHoverClass="t3-page-ce-dropzone-possible",s.addContentIdentifier=".t3js-page-new-ce",s.originalStyles="",t.default=s,a.default(s.initialize)}));
\ No newline at end of file
var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","jquery","../AjaxDataHandler","../Icons","jquery-ui/droppable"],(function(e,t,a,o,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),a=__importDefault(a);class s{static initialize(){a.default(s.contentIdentifier).draggable({handle:s.dragHeaderIdentifier,scope:"tt_content",cursor:"move",distance:20,revert:"invalid",zIndex:100,start:e=>{s.onDragStart(a.default(e.target))},stop:e=>{s.onDragStop(a.default(e.target))}}),a.default(s.dropZoneIdentifier).droppable({accept:this.contentIdentifier,scope:"tt_content",tolerance:"pointer",over:(e,t)=>{s.onDropHoverOver(a.default(t.draggable),a.default(e.target))},out:(e,t)=>{s.onDropHoverOut(a.default(t.draggable),a.default(e.target))},drop:(e,t)=>{s.onDrop(a.default(t.draggable),a.default(e.target),e)}})}static onDragStart(e){s.originalStyles=e.get(0).style.cssText,e.children(s.dragIdentifier).addClass("dragitem-shadow"),e.append('<div class="ui-draggable-copy-message">'+TYPO3.lang["dragdrop.copy.message"]+"</div>"),e.children(s.dropZoneIdentifier).addClass("drag-start"),e.closest(s.columnIdentifier).removeClass("active"),e.find(s.dropZoneIdentifier).hide(),a.default(s.dropZoneIdentifier).each((e,t)=>{const o=a.default(t);o.parent().find(".t3js-toggle-new-content-element-wizard").length?o.addClass(s.validDropZoneClass):o.closest(s.contentIdentifier).find("> "+s.addContentIdentifier+", > > "+s.addContentIdentifier).show()})}static onDragStop(e){e.children(s.dragIdentifier).removeClass("dragitem-shadow"),e.children(s.dropZoneIdentifier).removeClass("drag-start"),e.closest(s.columnIdentifier).addClass("active"),e.find(s.dropZoneIdentifier).show(),e.find(".ui-draggable-copy-message").remove(),e.get(0).style.cssText=s.originalStyles,a.default(s.dropZoneIdentifier+"."+s.validDropZoneClass).removeClass(s.validDropZoneClass)}static onDropHoverOver(e,t){t.hasClass(s.validDropZoneClass)&&t.addClass(s.dropPossibleHoverClass)}static onDropHoverOut(e,t){t.removeClass(s.dropPossibleHoverClass)}static onDrop(e,t,o){const r=s.getColumnPositionForElement(t);t.removeClass(s.dropPossibleHoverClass);const d=parseInt(e.data("uid"),10);if("number"==typeof d&&d>0){let i={};const l=t.closest(s.contentIdentifier).data("uid");let c=0;c=void 0===l?parseInt(o.target.offsetParent.getAttribute("data-page"),10):0-parseInt(l,10);let g=parseInt(e.data("language-uid"),10);-1!==g&&(g=parseInt(t.closest("[data-language-uid]").data("language-uid"),10));let p=0;0!==c&&(p=r);const f=o&&o.originalEvent.ctrlKey||t.hasClass("t3js-paste-copy"),u=f?"copy":"move";i.cmd={tt_content:{[d]:{[u]:{action:"paste",target:c,update:{colPos:p,sys_language_uid:g}}}}},s.ajaxAction(t,e,i,f).then(()=>{const t=a.default(`.t3-page-column-lang-name[data-language-uid="${g}"]`);if(0===t.length)return;const o=t.data("flagIdentifier"),s=t.data("languageTitle");e.find(".t3js-language-title").text(s),n.getIcon(o,n.sizes.small).then(t=>{e.find(".t3js-flag").attr("title",s).html(t)})})}}static ajaxAction(e,t,a,n){return o.process(a).then(a=>{if(a.hasErrors)throw a.messages;e.parent().hasClass(s.contentIdentifier.substring(1))?t.detach().css({top:0,left:0}).insertAfter(e.closest(s.contentIdentifier)):t.detach().css({top:0,left:0}).insertAfter(e.closest(s.dropZoneIdentifier)),n&&self.location.reload()})}static getColumnPositionForElement(e){const t=e.closest("[data-colpos]");return!(!t.length||"undefined"===t.data("colpos"))&&t.data("colpos")}}s.contentIdentifier=".t3js-page-ce",s.dragIdentifier=".t3-page-ce-dragitem",s.dragHeaderIdentifier=".t3js-page-ce-draghandle",s.dropZoneIdentifier=".t3js-page-ce-dropzone-available",s.columnIdentifier=".t3js-page-column",s.validDropZoneClass="active",s.dropPossibleHoverClass="t3-page-ce-dropzone-possible",s.addContentIdentifier=".t3js-page-new-ce",s.originalStyles="",t.default=s,a.default(s.initialize)}));
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment