Skip to content
Snippets Groups Projects
Commit fbd911a6 authored by Kevin Ditscheid's avatar Kevin Ditscheid
Browse files

[BUGFIX] Fix the pagetree page selection

parent cc59e317
No related branches found
No related tags found
1 merge request!12Feature upgrade to9 lts
......@@ -32,9 +32,11 @@ use SGalinski\SgJobs\Service\BackendService;
use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
......@@ -80,6 +82,20 @@ class BackendController extends ActionController {
$this->jobRepository = $jobRepository;
}
/**
* @param ViewInterface $view
*/
public function initializeView(ViewInterface $view) {
parent::initializeView($view);
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addJsInlineCode('typo3_version', 'TYPO3.version='
. VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getCurrentTypo3Version())
. ';');
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
$pageRenderer->loadExtJS();
}
}
/**
* Show all job offers and options to manage them
*
......
......@@ -4,7 +4,8 @@
<f:be.container
includeRequireJsModules="{
0: 'TYPO3/CMS/Backend/ContextMenu',
1: 'TYPO3/CMS/Backend/Tooltip'}">
1: 'TYPO3/CMS/Backend/Tooltip',
2: 'TYPO3/CMS/SgJobs/Backend/SgJobs'}">
<div class="module" data-module-id="" data-module-name="">
<div class="module-docheader t3js-module-docheader">
<div class="module-docheader-bar module-docheader-bar-navigation t3js-module-docheader-bar t3js-module-docheader-bar-navigation">
......
......@@ -11,7 +11,7 @@
<f:for each="{pages}" as="page">
<tr data-uid="{page.uid}">
<td nowrap="nowrap" class="col-title">
<f:link.action action="index" additionalParams="{id: page.uid}">
<f:link.action class="sg-jobs_pageswitch" action="index" additionalParams="{id: page.uid}" additionalAttributes="{data-page: page.uid, data-path: page.path}">
<core:iconForRecord table="pages" row="{page}" />
{page._thePathFull}
</f:link.action>
......
/*
*
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
*/
define([
'jquery',
'TYPO3/CMS/Backend/ModuleMenu',
'TYPO3/CMS/Backend/Viewport'
], function ($, ModuleMenu, Viewport) {
var SgJobs = {
init: function() {
$('.sg-jobs_pageswitch').on('click', function(event) {
event.preventDefault();
SgJobs.goTo('web_SgJobsBackend', event.target.dataset.page, event.target.dataset.path);
});
},
/**
* Switch the page and select it in the pagetree
*
* @param module
* @param id
* @param path
*/
goTo: function(module, id, path) {
if (TYPO3.version < 9000000) {
var tree = top.Ext.getCmp('typo3-pagetree');
if (tree) {
tree.activeTree.selectPath(path);
} else if (top.nav) {
top.nav.invokePageId(id, function(path) {
var callback = top.Ext.createDelegate(top.nav.mainTree.selectPath, top.nav.mainTree);
callback.apply(this, arguments);
var node = top.nav.getSelected();
if (node) {
top.TYPO3.Components.PageTree.Actions.singleClick(node, top.TYPO3.Components.PageTree.Tree);
}
});
}
parent.TYPO3.ModuleMenu.App.showModule(module, 'id=' + id);
} else {
var pageTreeNodes = Viewport.NavigationContainer.PageTree.instance.nodes;
for (var nodeIndex in pageTreeNodes) {
if (pageTreeNodes.hasOwnProperty(nodeIndex) && pageTreeNodes[nodeIndex].identifier === parseInt(id)) {
Viewport.NavigationContainer.PageTree.selectNode(pageTreeNodes[nodeIndex]);
break;
}
}
ModuleMenu.App.showModule(module, 'id=' + id);
}
}
};
TYPO3.SgJobs = SgJobs;
SgJobs.init();
return SgJobs;
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment