[BUGFIX] Empty grid list in frontend workspace preview 07/44307/3
authorOliver Hader <oliver@typo3.org>
Mon, 26 Oct 2015 23:06:56 +0000 (00:06 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Mon, 30 Nov 2015 20:26:46 +0000 (21:26 +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/44307
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
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 7573c3b..ffa6ac2 100644 (file)
@@ -164,11 +164,19 @@ class ReviewController extends AbstractController
         $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->setMetaCharsetTag(
+            $this->pageRenderer->getMetaCharsetTag() . LF
+            . GeneralUtility::wrapJS('document.domain = ' . GeneralUtility::quoteJSvalue($backendDomain) . ';')
+        );
         $this->pageRenderer->addInlineSetting('Workspaces', 'singleView', '1');
     }
 
@@ -242,6 +250,7 @@ class ReviewController extends AbstractController
         foreach ($this->getAdditionalResourceService()->getLocalizationResources() as $localizationResource) {
             $this->pageRenderer->addInlineLanguageLabelFile($localizationResource);
         }
+        $this->pageRenderer->addInlineSetting('FormEngine', 'moduleUrl', BackendUtility::getModuleUrl('record_edit'));
         $this->pageRenderer->addInlineSetting('RecordHistory', 'moduleUrl', BackendUtility::getModuleUrl('record_history'));
     }
 
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 4250ec7..3f792ac 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();