Commit c3504f8d authored by Benni Mack's avatar Benni Mack Committed by Oliver Bartsch
Browse files

[BUGFIX] Re-add language flag for each CE in Page Module

Due to some setups within e.g. shortcut elements did not have
a proper information anymore when used in language mode and mixed
setups.

Resolves: #95324
Related: #95302
Releases: master
Change-Id: Ic2022ab113c2ec0f75fb05d5c1a34be39387ec87
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/71212

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Jonas Eberle's avatarJonas Eberle <flightvision@googlemail.com>
Tested-by: Rachel Foucard's avatarRachel Foucard <rfoucard@w-seils.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Jonas Eberle's avatarJonas Eberle <flightvision@googlemail.com>
Reviewed-by: Rachel Foucard's avatarRachel Foucard <rfoucard@w-seils.com>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent 85a8761e
......@@ -217,7 +217,20 @@ class DragDrop {
}
};
DragDrop.ajaxAction($droppableElement, $draggableElement, parameters, isCopyAction);
DragDrop.ajaxAction($droppableElement, $draggableElement, parameters, isCopyAction).then((): void => {
const $languageDescriber = $(`.t3-page-column-lang-name[data-language-uid="${language}"]`);
if ($languageDescriber.length === 0) {
return;
}
const newFlagIdentifier = $languageDescriber.data('flagIdentifier');
const newLanguageTitle = $languageDescriber.data('languageTitle');
Icons.getIcon(newFlagIdentifier, Icons.sizes.small).then((markup: string): void => {
const $flagIcon = $draggableElement.find('.t3js-flag');
$flagIcon.attr('title', newLanguageTitle).html(markup);
});
});
}
}
......
......@@ -24,6 +24,7 @@ use TYPO3\CMS\Backend\View\PageLayoutContext;
use TYPO3\CMS\Backend\View\PageLayoutView;
use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -163,6 +164,11 @@ class GridColumnItem extends AbstractGridObject
return implode(' ', $icons);
}
public function getSiteLanguage(): SiteLanguage
{
return $this->context->getSiteLanguage((int)$this->getRecord()['sys_language_uid']);
}
public function getRecord(): array
{
return $this->record;
......
<div class="t3-page-ce-header row m-0 g-0 {f:if(condition: '{allowEditContent} && {item.dragAndDropAllowed}', then: 't3-page-ce-header-draggable t3js-page-ce-draghandle')}">
<div class="col t3-page-ce-header-icons-left">
{item.icons -> f:format.raw()}
<f:if condition="{item.record.sys_language_uid} == -1">
<core:icon identifier="flags-multiple" />
</f:if>
<span class="t3js-flag" title="{item.siteLanguage.title}"><core:icon identifier="{item.siteLanguage.flagIdentifier}" /></span>
</div>
<div class="col-auto align-self-end t3-page-ce-header-icons-right">
<f:if condition="{item.editable} && {allowEditContent}">
......
......@@ -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","jquery-ui/droppable"],(function(e,t,a,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 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,a){const o=s.getColumnPositionForElement(t);t.removeClass(s.dropPossibleHoverClass);const r=parseInt(e.data("uid"),10);if("number"==typeof r&&r>0){let n={};const d=t.closest(s.contentIdentifier).data("uid");let i=0;i=void 0===d?parseInt(a.target.offsetParent.getAttribute("data-page"),10):0-parseInt(d,10);let l=parseInt(e.data("language-uid"),10);-1!==l&&(l=parseInt(t.closest("[data-language-uid]").data("language-uid"),10));let c=0;0!==i&&(c=o);const p=a&&a.originalEvent.ctrlKey||t.hasClass("t3js-paste-copy"),g=p?"copy":"move";n.cmd={tt_content:{[r]:{[g]:{action:"paste",target:i,update:{colPos:c,sys_language_uid:l}}}}},s.ajaxAction(t,e,n,p)}}static ajaxAction(e,t,a,r){const n=Object.keys(a.cmd).shift(),d=parseInt(Object.keys(a.cmd[n]).shift(),10),i={component:"dragdrop",action:r?"copy":"move",table:n,uid:d};return o.process(a,i).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)),r&&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 p=parseInt(e.data("language-uid"),10);-1!==p&&(p=parseInt(t.closest("[data-language-uid]").data("language-uid"),10));let g=0;0!==c&&(g=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:g,sys_language_uid:p}}}}},s.ajaxAction(t,e,i,f).then(()=>{const t=a.default(`.t3-page-column-lang-name[data-language-uid="${p}"]`);if(0===t.length)return;const o=t.data("flagIdentifier"),s=t.data("languageTitle");n.getIcon(o,n.sizes.small).then(t=>{e.find(".t3js-flag").attr("title",s).html(t)})})}}static ajaxAction(e,t,a,n){const r=Object.keys(a.cmd).shift(),d=parseInt(Object.keys(a.cmd[r]).shift(),10),i={component:"dragdrop",action:n?"copy":"move",table:r,uid:d};return o.process(a,i).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
Markdown is supported
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