Skip to content

Commit

Permalink
jsdoc, types
Browse files Browse the repository at this point in the history
  • Loading branch information
yurikuzn committed Jun 20, 2023
1 parent fc8be6d commit 6465277
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 20 deletions.
16 changes: 14 additions & 2 deletions client/src/field-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,24 @@ class FieldManager {
*/
constructor(defs, metadata, acl) {

/**
* @typedef {Object} FieldManager~defs
* @property {string[]} [actualFields]
* @property {string[]} [notActualFields]
* @property {'suffix'|'prefix'} [naming]
* @property {Object.<string, Object.<string, *>>} [params]
* @property {boolean} [filter]
* @property {boolean} [notMergeable]
* @property {string} [view]
*/


/**
* @public
* @internal
* @type {Object}
* @type {FieldManager~defs}
*/
this.defs = defs || {};
this.defs = defs || /** @type {FieldManager~defs} */ {};

/**
* @public
Expand Down
5 changes: 4 additions & 1 deletion client/src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,9 @@
}

if (indexOfExports !== -1) {
let exports = args[indexOfExports];
let exports = args[indexOfExports];

// noinspection JSUnresolvedReference
value = ('default' in exports) ? exports.default : exports;
}

Expand Down Expand Up @@ -1042,6 +1043,8 @@

let loader = new Loader();

// noinspection JSUnusedGlobalSymbols

Espo.loader = {

/**
Expand Down
2 changes: 2 additions & 0 deletions client/src/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ class Model {
return urlRoot.replace(/[^\/]$/, '$&/') + encodeURIComponent(id);
}

// noinspection JSUnusedLocalSymbols
/**
* Prepare attributes.
*
Expand Down Expand Up @@ -999,6 +1000,7 @@ class Model {

/**
* @deprecated Use `getClonedAttributes`.
* @todo Remove in v8.0.
* @return {Object.<string, *>}
*/
toJSON() {
Expand Down
6 changes: 5 additions & 1 deletion client/src/multi-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ class MultiCollection extends Collection {
throw new Error("No 'list' in response.");
}

return response.list.map(attributes => {
/** @type {({_scope?: string} & Object.<string, *>)[]} */
const list = response.list;

return list.map(attributes => {
let entityType = attributes._scope;

if (!entityType) {
Expand Down Expand Up @@ -79,4 +82,5 @@ class MultiCollection extends Collection {
}
}

// noinspection JSUnusedGlobalSymbols
export default MultiCollection;
1 change: 1 addition & 0 deletions client/src/number-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class NumberUtil {
return stringValue;
}

// noinspection JSUnusedGlobalSymbols
/**
* Format a float number.
*
Expand Down
3 changes: 2 additions & 1 deletion client/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import Backbone from 'lib!backbone';
* @param {string} event An event.
*/

// noinspection JSUnusedGlobalSymbols
/**
* A router.
*
Expand Down Expand Up @@ -561,7 +562,7 @@ const Router = Backbone.Router.extend(/** @lends Router# */ {
/**
* Dispatch a controller action.
*
* @param {string} controller A controller.
* @param {string|null} [controller] A controller.
* @param {string|null} [action] An action.
* @param {Object} [options] Options.
* @fires module:router#routed
Expand Down
2 changes: 1 addition & 1 deletion client/src/search-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class SearchManager {
* @public
* @type {string}
*/
this.scope = collection.name;
this.scope = collection.entityType || collection.name;

/**
* @private
Expand Down
21 changes: 19 additions & 2 deletions client/src/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ import $ from 'lib!jquery';
* @property {boolean} [footerAtTheTop=false] To display a footer at the top.
* @property {module:ui.Dialog~Button[]} [buttonList] Buttons.
* @property {module:ui.Dialog~Button[]} [dropdownItemList] Dropdown action items.
* @property {boolean} [fullHeight] Deprecated.
* @property {Number} [bodyDiffHeight]
* @property {Number} [screenWidthXs]
*/

/**
Expand Down Expand Up @@ -84,6 +87,8 @@ class Dialog {
onRemove
onClose
onBackdropClick
buttons
screenWidthXs

/**
* @param {module:ui.Dialog~Params} options Options.
Expand Down Expand Up @@ -233,6 +238,7 @@ class Dialog {
if (this.draggable) {
this.$el.find('header').css('cursor', 'pointer');

// noinspection JSUnresolvedReference
this.$el.draggable({
handle: 'header',
});
Expand Down Expand Up @@ -557,6 +563,7 @@ class Dialog {
* Show.
*/
show() {
// noinspection JSUnresolvedReference
this.$el.modal({
backdrop: this.backdrop,
keyboard: this.keyboard,
Expand Down Expand Up @@ -642,6 +649,7 @@ class Dialog {
this.skipRemove = false;
}, 50);

// noinspection JSUnresolvedReference
this.$el.modal('hide');
this.$el.find('.modal-content').addClass('hidden');
}
Expand All @@ -665,13 +673,15 @@ class Dialog {
* @return {Element|null}
*/
_findClosestFocusableElement(element) {
// noinspection JSUnresolvedReference
let isVisible = !!(
element.offsetWidth ||
element.offsetHeight ||
element.getClientRects().length
);

if (isVisible) {
// noinspection JSUnresolvedReference
element.focus({preventScroll: true});

return element;
Expand Down Expand Up @@ -705,13 +715,15 @@ class Dialog {
let element = this._findClosestFocusableElement(this.activeElement);

if (element) {
// noinspection JSUnresolvedReference
element.focus({preventScroll: true});
}
}, 50);
}
}

this._close();
// noinspection JSUnresolvedReference
this.$el.modal('hide');
$(this).trigger('dialog:close');
}
Expand Down Expand Up @@ -796,7 +808,7 @@ Espo.Ui = {
return new Promise(resolve => {
let dialog = new Dialog({
backdrop: backdrop,
header: false,
header: null,
className: 'dialog-confirm',
body: '<span class="confirm-message">' + message + '</a>',
buttonList: [
Expand Down Expand Up @@ -896,6 +908,7 @@ Espo.Ui = {
container = $modalBody.length ? $modalBody : 'body';
}

// noinspection JSUnresolvedReference
$el
.popover({
placement: o.placement || 'bottom',
Expand Down Expand Up @@ -928,6 +941,7 @@ Espo.Ui = {
}

$body.off('click.popover-' + view.cid);
// noinspection JSUnresolvedReference
$el.popover('hide');
});

Expand All @@ -945,6 +959,7 @@ Espo.Ui = {

if (!o.noToggleInit) {
$el.on('click', () => {
// noinspection JSUnresolvedReference
$el.popover('toggle');
});
}
Expand All @@ -955,10 +970,12 @@ Espo.Ui = {
return;
}

// noinspection JSUnresolvedReference
$el.popover('hide');
};

let destroy = () => {
// noinspection JSUnresolvedReference
$el.popover('destroy');
$body.off('click.popover-' + view.cid);

Expand Down Expand Up @@ -1020,7 +1037,7 @@ Espo.Ui = {
marked.parse(message) :
marked.parseInline(message);

let sanitizedMessage = DOMPurify.sanitize(parsedMessage).toString();
let sanitizedMessage = DOMPurify.sanitize(parsedMessage, {}).toString();

let closeButton = options.closeButton || false;

Expand Down
4 changes: 2 additions & 2 deletions client/src/views/admin/entity-manager/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ function (Dep, Model) {
return false;
}

if (!this.getFieldManager().isScopeFieldAvailable(scope, item)) {
if (!this.getFieldManager().isEntityTypeFieldAvailable(scope, item)) {
return false;
}

Expand Down Expand Up @@ -802,7 +802,7 @@ function (Dep, Model) {
return false;
}

if (!this.getFieldManager().isScopeFieldAvailable(foreignEntityType, item)) {
if (!this.getFieldManager().isEntityTypeFieldAvailable(foreignEntityType, item)) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion client/src/views/email/record/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ define('views/email/record/detail', ['views/record/detail'], function (Dep) {
},

actionPrint: function () {
/** @type {module:views/fields/wysiwyg.Class} */
/** @type {module:views/fields/wysiwyg} */
let bodyView = this.getFieldView('body');

if (!bodyView) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/fields/foreign-bool.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ define('views/fields/foreign-bool', ['views/fields/bool', 'helpers/misc/foreign-
setup: function () {
Dep.prototype.setup.call(this);

/** @var {module:helpers/misc/foreign-field.Class} */
/** @var {module:helpers/misc/foreign-field} */
let helper = new Helper(this);

let foreignParams = helper.getForeignParams();
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/fields/foreign-date.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ define('views/fields/foreign-date', ['views/fields/date', 'helpers/misc/foreign-
setup: function () {
Dep.prototype.setup.call(this);

/** @var {module:helpers/misc/foreign-field.Class} */
/** @var {module:helpers/misc/foreign-field} */
let helper = new Helper(this);

let foreignParams = helper.getForeignParams();
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/fields/foreign-datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function (Dep, Helper) {
setup: function () {
Dep.prototype.setup.call(this);

/** @var {module:helpers/misc/foreign-field.Class} */
/** @var {module:helpers/misc/foreign-field} */
let helper = new Helper(this);

let foreignParams = helper.getForeignParams();
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/fields/foreign-float.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ define('views/fields/foreign-float', ['views/fields/float', 'helpers/misc/foreig
setup: function () {
Dep.prototype.setup.call(this);

/** @var {module:helpers/misc/foreign-field.Class} */
/** @var {module:helpers/misc/foreign-field} */
let helper = new Helper(this);

let foreignParams = helper.getForeignParams();
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/fields/foreign-int.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ define('views/fields/foreign-int',
setup: function () {
Dep.prototype.setup.call(this);

/** @var {module:helpers/misc/foreign-field.Class} */
/** @var {module:helpers/misc/foreign-field} */
let helper = new Helper(this);

let foreignParams = helper.getForeignParams();
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/fields/foreign-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ define('views/fields/foreign-text', ['views/fields/text', 'helpers/misc/foreign-
setup: function () {
Dep.prototype.setup.call(this);

/** @var {module:helpers/misc/foreign-field.Class} */
/** @var {module:helpers/misc/foreign-field} */
let helper = new Helper(this);

let foreignParams = helper.getForeignParams();
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/fields/foreign-url-multiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ define('views/fields/foreign-url-multiple',
setup: function () {
Dep.prototype.setup.call(this);

/** @var {module:helpers/misc/foreign-field.Class} */
/** @var {module:helpers/misc/foreign-field} */
let helper = new Helper(this);

let foreignParams = helper.getForeignParams();
Expand Down
4 changes: 2 additions & 2 deletions client/src/views/import-error/fields/validation-failures.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ define('views/import-error/fields/validation-failures', ['views/fields/base'], (

if (Array.isArray(itemList)) {
itemList.forEach(item => {
/** @var {module:field-manager.Class} */
/** @var {module:field-manager} */
let fieldManager = this.getFieldManager();
/** @var {module:language.Class} */
/** @var {module:language} */
let language = this.getLanguage();

let fieldType = fieldManager.getEntityTypeFieldParam(entityType, item.field, 'type');
Expand Down

0 comments on commit 6465277

Please sign in to comment.