[BUGFIX] Empty grid list in frontend workspace preview 05/44305/2
authorOliver Hader <oliver@typo3.org>
Mon, 26 Oct 2015 23:03:36 +0000 (00:03 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Mon, 30 Nov 2015 20:27:24 +0000 (21:27 +0100)
The grid list of the frontend workspace preview stayed empty due to
several JavaScript issues. First one is a CORS thingy with local
document.domain values being set and for the list IFRAME being set
too late (and thus running into CORS error). Besides that the tabs
component is only available in the backend workspace module and
leads to another error if expected and used in the frontend preview.

Resolves: #66169
Releases: master, 6.2
Change-Id: I5bf3dd7760c9382527d85e6e7e8e0ad5dca81c05
Reviewed-on: https://review.typo3.org/44305
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
typo3/sysext/workspaces/Classes/Controller/AbstractController.php
typo3/sysext/workspaces/Classes/Controller/ReviewController.php
typo3/sysext/workspaces/Resources/Private/Templates/Review/SingleIndex.html
typo3/sysext/workspaces/Resources/Public/JavaScript/workspaces.js

index e8e445a..1fc6106 100644 (file)
@@ -37,6 +37,11 @@ class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControl
        protected $pageId;
 
        /**
+        * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
+        */
+       protected $template;
+
+       /**
         * Initializes the controller before invoking an action method.
         *
         * @return void
index 401e459..ac6b958 100644 (file)
@@ -112,11 +112,19 @@ class ReviewController extends \TYPO3\CMS\Workspaces\Controller\AbstractControll
                $activeWorkspace = $GLOBALS['BE_USER']->workspace;
                $wsCur = array($activeWorkspace => TRUE);
                $wsList = array_intersect_key($wsList, $wsCur);
+               $backendDomain = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY');
                $this->view->assign('pageUid', GeneralUtility::_GP('id'));
                $this->view->assign('showGrid', TRUE);
                $this->view->assign('showAllWorkspaceTab', FALSE);
                $this->view->assign('workspaceList', $wsList);
-               $this->view->assign('backendDomain', GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'));
+               $this->view->assign('backendDomain', $backendDomain);
+               // Setting the document.domain early before JavScript
+               // libraries are loaded, try to access top frame reference
+               // and possibly run into some CORS issue
+               $this->pageRenderer->addJsInlineCode(
+                       'backendDomain',
+                       'document.domain = ' . GeneralUtility::quoteJSvalue($backendDomain) . ';'
+               );
                $this->pageRenderer->addInlineSetting('Workspaces', 'singleView', '1');
        }
 
index 4187ced..a76244a 100644 (file)
@@ -1,9 +1,5 @@
 <f:layout name="nodoc" />
 
 <f:section name="main">
-       <script type="text/javascript">
-               document.domain = '{backendDomain}';
-       </script>
-
        <div id="workspacegrid"></div>
 </f:section>
\ No newline at end of file
index 3910d38..750cb8b 100644 (file)
@@ -66,19 +66,23 @@ Ext.onReady(function() {
                directFn : TYPO3.Workspaces.ExtDirect.getWorkspaceInfos
        });
 
-       TYPO3.Workspaces.Tabs = new Ext.Panel({
-               renderTo: 'workspacetabs',
-               autoWidth: true,
-               layout: 'fit',
-               items: [
-                       {
-                               xtype: 'WorkspacesTabPanel',
-                               unstyled: true,
-                               items: TYPO3.settings.Workspaces.workspaceTabs,
-                               activeTab: 'workspace-' + TYPO3.settings.Workspaces.activeWorkspaceId
-                       }
-               ]
-       });
+       // Workspace Tabs are not used in
+       // frontend list preview
+       if (Ext.get('workspacetabs')) {
+               TYPO3.Workspaces.Tabs = new Ext.Panel({
+                       renderTo: 'workspacetabs',
+                       autoWidth: true,
+                       layout: 'fit',
+                       items: [
+                               {
+                                       xtype: 'WorkspacesTabPanel',
+                                       unstyled: true,
+                                       items: TYPO3.settings.Workspaces.workspaceTabs,
+                                       activeTab: 'workspace-' + TYPO3.settings.Workspaces.activeWorkspaceId
+                               }
+                       ]
+               });
+       }
 
        // fire grid
        var WS = new TYPO3.Workspaces.App.init();