From 2da413754ef5bfc8d55e3a0b1e0722eb91a56ae9 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Wed, 15 Jun 2022 15:37:22 +0300 Subject: [PATCH] jsdoc --- client/src/action-handler.js | 48 ++++++++++++++++++++++++-- client/src/app.js | 3 ++ client/src/cache.js | 66 +++++++++++++++++++++++++++++++++--- client/src/controller.js | 2 +- 4 files changed, 111 insertions(+), 8 deletions(-) diff --git a/client/src/action-handler.js b/client/src/action-handler.js index 1cfb972899..d1b33df078 100644 --- a/client/src/action-handler.js +++ b/client/src/action-handler.js @@ -29,66 +29,110 @@ define('action-handler', [], function () { /** - * An action handler. + * An action handler. To be extended by specific action handlers. * * @class * @name Class * @param {module:view.Class} view A view. + * @memberOf module:action-handler */ let ActionHandler = function (view) { + /** + * @type {module:view.Class} + * @protected + */ this.view = view; }; - _.extend(ActionHandler.prototype, { + _.extend(ActionHandler.prototype, /** @lends {module:action-handler.Class#} */ { + /** + * @deprecated Use `this.view`. + */ getConfig: function () { return this.view.getConfig(); }, + /** + * @deprecated Use `this.view`. + */ getMetadata: function () { return this.view.getMetadata(); }, + /** + * @deprecated Use `this.view`. + */ getAcl: function () { return this.view.getAcl(); }, + /** + * @deprecated Use `this.view`. + */ getUser: function () { return this.view.getUser(); }, + /** + * @deprecated Use `this.view`. + */ getRouter: function () { return this.view.getRouter(); }, + /** + * @deprecated Use `this.view`. + */ getHelper: function () { return this.view.getHelper(); }, + /** + * @deprecated Use `this.view`. + */ getLanguage: function () { return this.view.getLanguage(); }, + /** + * @deprecated Use `this.view`. + */ getModelFactory: function () { return this.view.getModelFactory(); }, + /** + * @deprecated Use `this.view`. + */ getCollectionFactory: function () { return this.view.getCollectionFactory(); }, + /** + * @deprecated Use `Espo.Ajax`. + */ ajaxPostRequest: function () { return this.view.ajaxPostRequest.apply(this.view, arguments); }, + /** + * @deprecated Use `Espo.Ajax`. + */ ajaxPutRequest: function () { return this.view.ajaxPutRequest.apply(this.view, arguments); }, + /** + * @deprecated Use `Espo.Ajax`. + */ ajaxGetRequest: function () { return this.view.ajaxGetRequest.apply(this.view, arguments); }, + /** + * @deprecated Use `this.view`. + */ confirm: function () { return this.view.confirm.apply(this.view, arguments); }, diff --git a/client/src/app.js b/client/src/app.js index 02661fdde9..e4d585af1b 100644 --- a/client/src/app.js +++ b/client/src/app.js @@ -237,7 +237,10 @@ function ( collectionFactory: null, /** + * A view factory. + * * @private + * @type {Bull.Factory} */ viewFactory: null, diff --git a/client/src/cache.js b/client/src/cache.js index 0a4caf80ea..6177c1e230 100644 --- a/client/src/cache.js +++ b/client/src/cache.js @@ -28,6 +28,14 @@ define('cache', [], function () { + /** + * Cache for source and resource files. + * + * @class + * @name Class + * @memberOf module:cache + * @param {Number} [cacheTimestamp] A cache timestamp. + */ var Cache = function (cacheTimestamp) { this.basePrefix = this.prefix; @@ -40,19 +48,25 @@ define('cache', [], function () { } }; - _.extend(Cache.prototype, { + _.extend(Cache.prototype, /** @lends module:cache.Class# */ { + /** + * @private + */ prefix: 'cache', + /** + * Handle actuality. Clears cache if not actual. + * + * @param {Number} cacheTimestamp A cache timestamp. + */ handleActuality: function (cacheTimestamp) { let storedTimestamp = this.getCacheTimestamp(); if (storedTimestamp) { if (storedTimestamp !== cacheTimestamp) { this.clear(); - this.set('app', 'cacheTimestamp', cacheTimestamp); - this.storeTimestamp(); } @@ -60,36 +74,65 @@ define('cache', [], function () { } this.clear(); - this.set('app', 'cacheTimestamp', cacheTimestamp); - this.storeTimestamp(); }, + /** + * Get a cache timestamp. + * + * @returns {number} + */ getCacheTimestamp: function () { return parseInt(this.get('app', 'cacheTimestamp') || 0); }, + /** + * @deprecated + * @todo Revise whether is needed. + */ storeTimestamp: function () { let frontendCacheTimestamp = Date.now(); this.set('app', 'timestamp', frontendCacheTimestamp); }, + /** + * @private + * @param {string} type + * @returns {string} + */ composeFullPrefix: function (type) { return this.prefix + '-' + type; }, + /** + * @private + * @param {string} type + * @param {string} name + * @returns {string} + */ composeKey: function (type, name) { return this.composeFullPrefix(type) + '-' + name; }, + /** + * @private + * @param {string} type + */ checkType: function (type) { if (typeof type === 'undefined' && toString.call(type) !== '[object String]') { throw new TypeError("Bad type \"" + type + "\" passed to Cache()."); } }, + /** + * Get a stored value. + * + * @param {string} type A type/category. + * @param {string} name A name. + * @returns {string|null} Null if no stored value. + */ get: function (type, name) { this.checkType(type); @@ -126,6 +169,13 @@ define('cache', [], function () { return null; }, + /** + * Store a value. + * + * @param {string} type A type/category. + * @param {string} name A name. + * @param {any} value A value. + */ set: function (type, name, value) { this.checkType(type); @@ -143,6 +193,12 @@ define('cache', [], function () { } }, + /** + * Clear a stored value. + * + * @param {string} type A type/category. + * @param {string} name A name. + */ clear: function (type, name) { let reText; diff --git a/client/src/controller.js b/client/src/controller.js index 548cc6ef29..d892cd7b50 100644 --- a/client/src/controller.js +++ b/client/src/controller.js @@ -99,7 +99,7 @@ define('controller', [], function () { /** * A view factory. * - * @type {Bull.ViewFactory} + * @type {Bull.Factory} * @protected */ viewFactory: null,