[BUGFIX] Showmodule cannot be called before Store is loaded
authorOliver Hader <oliver@typo3.org>
Mon, 10 Oct 2011 21:24:41 +0000 (23:24 +0200)
committerJigal van Hemert <jigal@xs4all.nl>
Tue, 11 Oct 2011 08:21:22 +0000 (10:21 +0200)
Example: Using the direct page edit feature (backend.php?edit=xxx)
the BE responds with "Module loader No module found. If this is a
temporary error, please reload the Backend!" error.

Since the AJAX request is not finished at the time this is called,
it has to be checked whether the store was completely loaded.

Change-Id: Ia7c39fc94e75ef003a7a839856ea78cbd0854a66
Releases: 4.6,4.5
Resolves: #28951
Reviewed-on: http://review.typo3.org/5681
Reviewed-by: Helmut Hummel
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
Tested-by: Jigal van Hemert
typo3/js/modulemenu.js

index 3ea88d9..ccaa881 100644 (file)
@@ -50,6 +50,19 @@ TYPO3.ModuleMenu.Store = new Ext.data.JsonStore({
        url: 'ajax.php?ajaxID=ModuleMenu::getData',
        baseParams: {
                'action': 'getModules'
+       },
+       listeners: {
+               beforeload: function(store) {
+                       this.loaded = false;
+               },
+               load: function(store) {
+                       this.loaded = true;
+               }
+       },
+       // Custom indicator for loaded store:
+       loaded: false,
+       isLoaded: function() {
+               return this.loaded;
        }
 
 });
@@ -213,7 +226,13 @@ TYPO3.ModuleMenu.App = {
 
        loadFirstAvailableModule: function(params) {
                params = params || '';
-               if (TYPO3.ModuleMenu.Store.getCount() === 0) {
+               if (TYPO3.ModuleMenu.Store.isLoaded() === false) {
+                       new Ext.util.DelayedTask(
+                               this.loadFirstAvailableModule,
+                               this,
+                               [params]
+                       ).delay(250);
+               } else if (TYPO3.ModuleMenu.Store.getCount() === 0) {
                                // Store is empty, something went wrong
                        TYPO3.Flashmessage.display(TYPO3.Severity.error, 'Module loader', 'No module found. If this is a temporary error, please reload the Backend!', 50000);
                } else {