Skip to content

EspoCRM – Open Source CRM Application

ref

Yuri Kuznetsov85d4f6f304c5
diff --git a/client/src/app.js b/client/src/app.js
index 758da993a6..60191c6533 100644
--- a/client/src/app.js
+++ b/client/src/app.js
@@ -69,7 +69,7 @@ class App {
/**
* @param {module:app~Options} options Options.
- * @param {module:app~callback} callback A callback.
+ * @param {function(App): void} callback A callback.
*/
constructor(options, callback) {
options = options || {};
@@ -131,7 +131,11 @@ class App {
this.appTimestamp = options.appTimestamp;
this.initCache(options)
- .then(() => this.init(options, callback));
+ .then(async () => {
+ await this.init(options);
+
+ callback(this);
+ });
uiAppInit();
}
@@ -144,13 +148,13 @@ class App {
/**
* @protected
- * @type {module:models/user}
+ * @type {User}
*/
user = null
/**
* @private
- * @type {module:models/preferences}
+ * @type {Preferences}
*/
preferences = null
@@ -162,7 +166,7 @@ class App {
/**
* @private
- * @type {module:metadata}
+ * @type {Metadata}
*/
metadata = null
@@ -315,6 +319,12 @@ class App {
*/
webSocketManager = null
+ /**
+ * @private
+ * @type {AclManager}
+ */
+ acl
+
/**
* An application timestamp. Used for asset cache busting and update detection.
*
@@ -368,9 +378,8 @@ class App {
/**
* @private
* @param {module:app~Options} options
- * @param {function} [callback]
*/
- init(options, callback) {
+ async init(options) {
this.appParams = new AppParams();
this.controllers = {};
@@ -407,47 +416,42 @@ class App {
this.initBroadcastChannel();
- Promise
- .all([
- this.settings.load(),
- this.language.loadDefault(),
- this.initTemplateBundles(),
- ])
- .then(() => {
- this.loader.setIsDeveloperMode(this.settings.get('isDeveloperMode'));
-
- this.user = new User();
- this.preferences = new Preferences();
+ await Promise.all([
+ this.settings.load(),
+ this.language.loadDefault(),
+ this.initTemplateBundles(),
+ ]);
- this.preferences.settings = this.settings;
+ this.loader.setIsDeveloperMode(this.settings.get('isDeveloperMode'));
- /** @type {module:acl-manager} */
- this.acl = this.createAclManager();
+ this.user = new User();
+ this.preferences = new Preferences();
- this.fieldManager.acl = this.acl;
+ this.preferences.setSettings(this.settings);
- this.themeManager = new ThemeManager(this.settings, this.preferences, this.metadata, this.themeName);
- this.modelFactory = new ModelFactory(this.metadata);
- this.collectionFactory = new CollectionFactory(this.modelFactory, this.settings, this.metadata);
+ this.acl = this.createAclManager();
- if (this.settings.get('useWebSocket')) {
- this.webSocketManager = new WebSocketManager(this.settings);
- }
+ this.fieldManager.acl = this.acl;
- container.set(AclManager, this.acl);
- container.set(User, this.user);
- container.set(Preferences, this.preferences);
- container.set(ThemeManager, this.themeManager);
- container.set(ModelFactory, this.modelFactory);
- container.set(CollectionFactory, this.collectionFactory);
- container.set(WebSocketManager, this.webSocketManager);
+ this.themeManager = new ThemeManager(this.settings, this.preferences, this.metadata, this.themeName);
+ this.modelFactory = new ModelFactory(this.metadata);
+ this.collectionFactory = new CollectionFactory(this.modelFactory, this.settings, this.metadata);
- this.initUtils();
- this.initView();
- this.initBaseController();
+ if (this.settings.get('useWebSocket')) {
+ this.webSocketManager = new WebSocketManager(this.settings);
+ }
- callback.call(this, this);
- });
+ container.set(AclManager, this.acl);
+ container.set(User, this.user);
+ container.set(Preferences, this.preferences);
+ container.set(ThemeManager, this.themeManager);
+ container.set(ModelFactory, this.modelFactory);
+ container.set(CollectionFactory, this.collectionFactory);
+ container.set(WebSocketManager, this.webSocketManager);
+
+ this.initUtils();
+ this.initView();
+ this.initBaseController();
}
/**
diff --git a/client/src/controllers/preferences.js b/client/src/controllers/preferences.js
index 7f8052a412..c7eff8e78f 100644
--- a/client/src/controllers/preferences.js
+++ b/client/src/controllers/preferences.js
@@ -34,10 +34,11 @@ class PreferencesController extends RecordController {
defaultAction = 'own'
getModel(callback, context) {
- const model = new Preferences();
+ const model = new Preferences({}, {
+ defs: this.getMetadata().get('entityDefs.Preferences') || {},
+ });
- model.settings = this.getConfig();
- model.defs = this.getMetadata().get('entityDefs.Preferences');
+ model.setSettings(this.getConfig());
if (callback) {
callback.call(this, model);
@@ -57,7 +58,7 @@ class PreferencesController extends RecordController {
this.actionEdit({id: this.getUser().id});
}
- actionList() {}
+ actionList(options) {}
}
export default PreferencesController;
diff --git a/client/src/models/preferences.js b/client/src/models/preferences.js
index 5d29f20646..ebacf1b632 100644
--- a/client/src/models/preferences.js
+++ b/client/src/models/preferences.js
@@ -39,6 +39,12 @@ class Preferences extends Model {
entityType = 'Preferences'
urlRoot = 'Preferences'
+ /**
+ * @private
+ * @type {import('models/settings').default}
+ */
+ settings
+
/**
* Get dashlet options.
*
@@ -59,6 +65,14 @@ class Preferences extends Model {
isPortal() {
return this.get('isPortalUser');
}
+
+ /**
+ * @internal
+ * @param {import('models/settings').default} settings
+ */
+ setSettings(settings) {
+ this.settings = settings;
+ }
}
export default Preferences;