[TASK] Replace ExtDirect State for module menu with jQuery 08/51208/4
authorBenni Mack <benni@typo3.org>
Mon, 9 Jan 2017 06:07:56 +0000 (07:07 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Mon, 9 Jan 2017 09:05:02 +0000 (10:05 +0100)
The obsolete State Provider for storing and retrieving the information
if the backend module menu should be collapsed or not
should not use ExtDirect but instead us the native Storage functionality
already in place for TYPO3.

The namespace (BackendComponents.States.typo3-module-menu) is
kept for now (see BackendController.php for details on ExtDirect), but could
easily be modified.

Resolves: #79211
Releases: master
Change-Id: I4de6b46ea0f18201cb8bb0af6077c1d9dfffcec7
Reviewed-on: https://review.typo3.org/51208
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Resources/Public/JavaScript/ModuleMenu.js

index fa7215e..d555d72 100644 (file)
 require(
        [
                'jquery',
+               'TYPO3/CMS/Backend/Storage',
                'TYPO3/CMS/Backend/Icons',
                'TYPO3/CMS/Backend/Viewport'
        ],
-       function ($, Icons) {
+       function ($, Storage, Icons) {
                if (typeof TYPO3.ModuleMenu !== 'undefined') {
                        return TYPO3.ModuleMenu.App;
                }
@@ -48,30 +49,28 @@ require(
                                }
 
                                // check if module menu should be collapsed or not
-                               var state = Ext.state.Manager.getProvider().get('typo3-module-menu');
+                               var state = Storage.Persistent.get('BackendComponents.States.typo3-module-menu');
                                if (state && state.collapsed) {
                                        TYPO3.ModuleMenu.App.toggleMenu(state.collapsed);
                                }
 
                                // check if there are collapsed items in the users' configuration
-                               require(['TYPO3/CMS/Backend/Storage'], function () {
-                                       var collapsedMainMenuItems = me.getCollapsedMainMenuItems();
-                                       $.each(collapsedMainMenuItems, function (key, itm) {
-                                               if (itm !== true) {
-                                                       return;
-                                               }
-                                               var $group = $('#' + key);
-                                               if ($group.length > 0) {
-                                                       var $groupContainer = $group.find('.modulemenu-group-container');
-                                                       $group.addClass('collapsed').removeClass('expanded');
-                                                       TYPO3.Backend.NavigationContainer.cleanup();
-                                                       $groupContainer.hide().promise().done(function () {
-                                                               TYPO3.Backend.doLayout();
-                                                       });
-                                               }
-                                       });
-                                       me.initializeEvents();
+                               var collapsedMainMenuItems = me.getCollapsedMainMenuItems();
+                               $.each(collapsedMainMenuItems, function (key, itm) {
+                                       if (itm !== true) {
+                                               return;
+                                       }
+                                       var $group = $('#' + key);
+                                       if ($group.length > 0) {
+                                               var $groupContainer = $group.find('.modulemenu-group-container');
+                                               $group.addClass('collapsed').removeClass('expanded');
+                                               TYPO3.Backend.NavigationContainer.cleanup();
+                                               $groupContainer.hide().promise().done(function () {
+                                                       TYPO3.Backend.doLayout();
+                                               });
+                                       }
                                });
+                               me.initializeEvents();
                        },
 
                        initializeEvents: function () {
@@ -139,9 +138,9 @@ require(
                                        $('.scaffold').removeClass('scaffold-toolbar-expanded');
                                }
 
-                               // @todo remove once we have a new state manager
-                               Ext.state.Manager.set(
-                                       'typo3-module-menu',
+                               // Persist collapsed state in the UC of the current user
+                               Storage.Persistent.set(
+                                       'BackendComponents.States.typo3-module-menu',
                                        {
                                                collapsed: collapse
                                        }