partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 2afe5e8e589571a1dad90bf1e3ba0c26dfb02571
parent 1cafadc1c9c0eda334750bec296108e3238471c5
Author: Felicitus <felicitus@felicitus.org>
Date:   Sat, 12 May 2012 10:47:08 +0200

Automatic transfer of the user settings on login, so we have the information immediately available after login.

Diffstat:
Msrc/backend/de/RaumZeitLabor/PartKeepr/Auth/AuthService.php | 15++++++++++++++-
Msrc/frontend/js/Components/Part/Editor/PartEditor.js | 2+-
Msrc/frontend/js/Components/Session/SessionManager.js | 2++
Msrc/frontend/js/PartKeepr.js | 16+++++++++-------
4 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/Auth/AuthService.php b/src/backend/de/RaumZeitLabor/PartKeepr/Auth/AuthService.php @@ -29,7 +29,20 @@ class AuthService extends AnonService { /* Start Session */ $session = SessionManager::getInstance()->startSession($authenticatedUser); - return array("sessionid" => $session->getSessionID(), "username" => $this->getParameter("username"), "admin" => $session->getUser()->isAdmin()); + $aPreferences = array(); + + foreach ($session->getUser()->getPreferences() as $result) { + $aPreferences[] = $result->serialize(); + } + + return array( + "sessionid" => $session->getSessionID(), + "username" => $this->getParameter("username"), + "admin" => $session->getUser()->isAdmin(), + "userPreferences" => array( + "response" => array( + "data" => $aPreferences + ))); } else { throw new InvalidLoginDataException(); } diff --git a/src/frontend/js/Components/Part/Editor/PartEditor.js b/src/frontend/js/Components/Part/Editor/PartEditor.js @@ -376,7 +376,7 @@ Ext.define('PartKeepr.PartEditor', { // because we don't know which event will come first this.getForm().isValid(); - if (this.record.get("footprint") == 0) { + if (this.record.get("footprint") === 0) { this.footprintNone.setValue(true); } else { this.footprintSet.setValue(true); diff --git a/src/frontend/js/Components/Session/SessionManager.js b/src/frontend/js/Components/Session/SessionManager.js @@ -77,6 +77,8 @@ Ext.define("PartKeepr.SessionManager", { PartKeepr.getApplication().setAdmin(response.admin); PartKeepr.getApplication().setUsername(response.username); + PartKeepr.getApplication().setInitialUserPreferences(response.userPreferences); + this.fireEvent("login"); }, diff --git a/src/frontend/js/PartKeepr.js b/src/frontend/js/PartKeepr.js @@ -65,6 +65,8 @@ Ext.application({ */ onLogin: function () { this.createGlobalStores(); + + this.getUserPreferenceStore().getProxy().getReader().read(PartKeepr.initialUserPreferences); this.reloadStores(); var j = Ext.create("PartKeepr.PartManager", { @@ -90,18 +92,18 @@ Ext.application({ }, /** + * Sets the initial user preferences, which are applied into the userPreferenceStore after login. + */ + setInitialUserPreferences: function (obj) { + PartKeepr.initialUserPreferences = obj; + }, + /** * Displays the tip of the day window. * * This method checks if the user has disabled tips, and if so, this method * avoids showing the window. */ displayTipOfTheDayWindow: function () { - if (!this.userPreferenceStore._loaded) { - this.displayTipWindowTask.delay(100); - return; - - } - if (!this.tipOfTheDayStore._loaded) { this.displayTipWindowTask.delay(100); return; @@ -242,7 +244,7 @@ Ext.application({ { model: 'PartKeepr.UserPreference', pageSize: -1, - autoLoad: true, + autoLoad: false, listeners: { scope: this, load: this.storeLoaded