jsdoc and fixes

This commit is contained in:
Yuri Kuznetsov
2022-06-17 16:01:55 +03:00
parent 7ef9b5be4e
commit bccf6a4e05
24 changed files with 147 additions and 91 deletions
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('crm:controllers/unsubscribe', 'controller', function (Dep) {
define('crm:controllers/unsubscribe', ['controller'], function (Dep) {
return Dep.extend({
@@ -54,7 +54,6 @@ Espo.define('crm:controllers/unsubscribe', 'controller', function (Dep) {
}, function (view) {
view.render();
});
}
},
});
});
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('crm:knowledge-base-helper', 'ajax', function (Ajax) {
define('crm:knowledge-base-helper', ['ajax'], function (Ajax) {
var KnowledgeBaseHelper = function (language) {
this.language = language;
@@ -41,25 +41,27 @@ Espo.define('crm:knowledge-base-helper', 'ajax', function (Ajax) {
getAttributesForEmail: function (model, attributes, callback) {
attributes = attributes || {};
attributes.body = model.get('body');
if (attributes.name) {
attributes.name = attributes.name + ' ';
} else {
attributes.name = '';
}
attributes.name += this.getLanguage().translate('KnowledgeBaseArticle', 'scopeNames') + ': ' + model.get('name');
attributes.name += this.getLanguage().translate('KnowledgeBaseArticle', 'scopeNames') + ': ' +
model.get('name');
Ajax.postRequest('KnowledgeBaseArticle/action/getCopiedAttachments', {
id: model.id
}).then(function (data) {
}).then((data) => {
attributes.attachmentsIds = data.ids;
attributes.attachmentsNames = data.names;
attributes.isHtml = true;
callback(attributes);
}.bind(this));
}
});
},
});
return KnowledgeBaseHelper;
});
@@ -34,12 +34,19 @@ Espo.define('crm:views/contact/fields/accounts', 'views/fields/link-multiple-wit
events: {
'click [data-action="switchPrimary"]': function (e) {
$target = $(e.currentTarget);
let $target = $(e.currentTarget);
var id = $target.data('id');
if (!$target.hasClass('active')) {
this.$el.find('button[data-action="switchPrimary"]').removeClass('active').children().addClass('text-muted');
$target.addClass('active').children().removeClass('text-muted');
this.$el.find('button[data-action="switchPrimary"]')
.removeClass('active')
.children()
.addClass('text-muted');
$target.addClass('active')
.children()
.removeClass('text-muted');
this.setPrimaryId(id);
}
}
@@ -47,9 +54,11 @@ Espo.define('crm:views/contact/fields/accounts', 'views/fields/link-multiple-wit
getAttributeList: function () {
var list = Dep.prototype.getAttributeList.call(this);
list.push('accountId');
list.push('accountName');
list.push('title');
return list;
},
@@ -68,7 +77,6 @@ Espo.define('crm:views/contact/fields/accounts', 'views/fields/link-multiple-wit
this.primaryName = this.model.get(this.primaryNameFieldName);
}, this);
if (this.mode === 'edit' || this.mode === 'detail') {
this.events['click a[data-action="setPrimary"]'] = function (e) {
var id = $(e.currentTarget).data('id');
@@ -111,6 +119,7 @@ Espo.define('crm:views/contact/fields/accounts', 'views/fields/link-multiple-wit
names.push(this.getDetailLinkHtml(id));
}
}, this);
return names.join('');
}
},
@@ -207,8 +216,6 @@ Espo.define('crm:views/contact/fields/accounts', 'views/fields/link-multiple-wit
}
return data;
}
},
});
});
@@ -35,12 +35,21 @@ define(
events: {
'click [data-action="switchPrimary"]': function (e) {
$target = $(e.currentTarget);
let $target = $(e.currentTarget);
var id = $target.data('id');
if (!$target.hasClass('active')) {
this.$el.find('button[data-action="switchPrimary"]').removeClass('active').children().addClass('text-muted');
$target.addClass('active').children().removeClass('text-muted');
this.$el.find('button[data-action="switchPrimary"]')
.removeClass('active')
.children()
.addClass('text-muted');
$target
.addClass('active')
.children()
.removeClass('text-muted');
this.setPrimaryId(id);
}
}
@@ -48,8 +57,10 @@ define(
getAttributeList: function () {
var list = Dep.prototype.getAttributeList.call(this);
list.push(this.primaryIdFieldName);
list.push(this.primaryNameFieldName);
return list;
},
@@ -138,7 +149,10 @@ define(
var isPrimary = (id == this.primaryId);
var iconHtml = '<span class="fas fa-star fa-sm ' + (!isPrimary ? 'text-muted' : '') + '"></span>';
var title = this.translate('Primary');
var $primary = $('<button type="button" class="btn btn-link btn-sm pull-right hidden" title="'+title+'" data-action="switchPrimary" data-id="'+id+'">'+iconHtml+'</button>');
var $primary = $('<button type="button" class="btn btn-link btn-sm pull-right hidden" ' +
'title="'+title+'" data-action="switchPrimary" data-id="' + id + '">' + iconHtml + '</button>');
$primary.insertAfter($el.children().first().children().first());
this.managePrimaryButton();
@@ -148,6 +162,7 @@ define(
managePrimaryButton: function () {
var $primary = this.$el.find('button[data-action="switchPrimary"]');
if ($primary.length > 1) {
$primary.removeClass('hidden');
} else {
@@ -175,7 +190,9 @@ define(
getSelectFilters: function () {
if (this.model.get('accountId')) {
var nameHash = {};
nameHash[this.model.get('accountId')] = this.model.get('accountName');
return {
'accounts': {
type: 'linkedWith',
@@ -197,6 +214,5 @@ define(
}
}
},
});
});
@@ -24,9 +24,9 @@
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
************************************************************************/
Espo.define('Crm:Views.Target.Detail', 'Views.Detail', function (Dep) {
define('crm:views/target/detail', ['views/detail'], function (Dep) {
return Dep.extend({
@@ -50,4 +50,3 @@ Espo.define('Crm:Views.Target.Detail', 'Views.Detail', function (Dep) {
});
});
@@ -89,7 +89,7 @@ define('views/admin/entity-manager/index', 'view', function (Dep) {
isRemovable = false;
}
hasView = d.customizable;
let hasView = d.customizable;
this.scopeDataList.push({
name: scope,
@@ -68,7 +68,7 @@ Espo.define('views/dashlets/fields/records/expanded-layout', 'views/fields/base'
this.$container.append($row);
$input = $row.find('input');
let $input = $row.find('input');
$input.selectize({
options: fieldDataList,
@@ -25,13 +25,16 @@
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('views/email-filter/fields/action', 'views/fields/enum', function (Dep) {
define('views/email-filter/fields/action', ['views/fields/enum'], function (Dep) {
return Dep.extend({
setup: function () {
Dep.prototype.setup.call(this);
this.controlActionOptions();
this.listenTo(this.model, 'change:parentType', this.controlActionOptions, this);
},
@@ -41,11 +44,10 @@ Espo.define('views/email-filter/fields/action', 'views/fields/enum', function (D
} else {
this.params.options = ['Skip'];
}
if (this.isRendered()) {
this.reRender();
}
}
},
});
});
+2 -1
View File
@@ -802,7 +802,8 @@ define('views/fields/base', ['view'], function (Dep) {
var $sign = $label.find('span.required-sign');
if ($label.length && !$sign.length) {
$text = $label.find('span.label-text');
let $text = $label.find('span.label-text');
$('<span class="required-sign"> *</span>').insertAfter($text);
$sign = $label.find('span.required-sign');
}
@@ -326,7 +326,7 @@ define('views/fields/link-multiple-with-columns', 'views/fields/link-multiple',
}
}, this);
$left = $('<div>');
let $left = $('<div>');
if (columnFormElementJQList.length === 1) {
$left.append(columnFormElementJQList[0]);
@@ -358,7 +358,7 @@ define('views/fields/link-multiple-with-columns', 'views/fields/link-multiple',
$el.append($left);
$right = $('<div>');
let $right = $('<div>');
$right.append(removeHtml);
$el.append($right);
@@ -34,7 +34,7 @@ define('views/fields/link-multiple-with-primary', 'views/fields/link-multiple',
events: {
'click [data-action="switchPrimary"]': function (e) {
$target = $(e.currentTarget);
let $target = $(e.currentTarget);
var id = $target.data('id');
@@ -161,11 +161,11 @@ define('views/fields/link-multiple-with-primary', 'views/fields/link-multiple',
var removeHtml = '<a href="javascript:" class="pull-right" data-id="' + id + '" data-action="clearLink">' +
'<span class="fas fa-times"></a>';
$left = $('<div>');
let $left = $('<div>');
$left.append(nameHtml);
$el.append($left);
$right = $('<div>');
let $right = $('<div>');
$right.append(removeHtml);
$el.append($right);
@@ -237,7 +237,7 @@ define('views/fields/link-multiple-with-role', 'views/fields/link-multiple', fun
);
}
$left = $('<div class="pull-left">');
let $left = $('<div class="pull-left">');
if ($role) {
$left.append($role);
@@ -247,7 +247,7 @@ define('views/fields/link-multiple-with-role', 'views/fields/link-multiple', fun
$el.append($left);
$right = $('<div>');
let $right = $('<div>');
$right.append(removeHtml);
+30 -24
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/global-search/global-search', 'view', function (Dep) {
define('views/global-search/global-search', ['view'], function (Dep) {
return Dep.extend({
@@ -34,7 +34,7 @@ define('views/global-search/global-search', 'view', function (Dep) {
events: {
'keypress input.global-search-input': function (e) {
if (e.keyCode == 13) {
if (e.keyCode === 13) {
this.runSearch();
}
},
@@ -48,12 +48,13 @@ define('views/global-search/global-search', 'view', function (Dep) {
setup: function () {
this.wait(true);
this.getCollectionFactory().create('GlobalSearch', function (collection) {
this.getCollectionFactory().create('GlobalSearch', (collection) => {
this.collection = collection;
collection.name = 'GlobalSearch';
this.wait(false);
}, this);
this.wait(false);
});
},
afterRender: function () {
@@ -62,8 +63,8 @@ define('views/global-search/global-search', 'view', function (Dep) {
runSearch: function () {
var text = this.$input.val().trim();
if (text != '' && text.length >= 2) {
text = text;
if (text !== '' && text.length >= 2) {
this.search(text);
}
},
@@ -90,39 +91,44 @@ define('views/global-search/global-search', 'view', function (Dep) {
this.listenToOnce(view, 'close', this.closePanel);
});
$document = $(document);
$document.on('mouseup.global-search', function (e) {
if (e.which !== 1) return;
let $document = $(document);
$document.on('mouseup.global-search', (e) => {
if (e.which !== 1) {
return;
}
if (!$container.is(e.target) && $container.has(e.target).length === 0) {
this.closePanel();
}
}.bind(this));
$document.on('click.global-search', function (e) {
});
$document.on('click.global-search', (e) => {
if (
e.target.tagName == 'A' &&
$(e.target).data('action') != 'showMore' &&
e.target.tagName === 'A' &&
$(e.target).data('action') !== 'showMore' &&
!$(e.target).hasClass('global-search-button')
) {
setTimeout(function () {
setTimeout(() => {
this.closePanel();
}.bind(this), 100);
return;
}, 100);
}
}.bind(this));
});
},
closePanel: function () {
$container = $('#global-search-panel');
let $container = $('#global-search-panel');
$container.remove();
let $document = $(document);
$('#global-search-panel').remove();
$document = $(document);
if (this.hasView('panel')) {
this.getView('panel').remove();
};
}
$document.off('mouseup.global-search');
$document.off('click.global-search');
$container.remove();
},
});
});
+3 -2
View File
@@ -458,10 +458,11 @@ define('views/import/step1', ['view', 'model'], function (Dep, Model) {
return;
}
$row = $('<tr>');
let $row = $('<tr>');
row.forEach((value) => {
$cell = $('<td>').html(value);
let $cell = $('<td>').html(value);
$row.append($cell);
});
+3 -2
View File
@@ -106,7 +106,7 @@ define('views/import/step2', 'view', function (Dep) {
},
afterRender: function () {
$container = $('#mapping-container');
let $container = $('#mapping-container');
var $table = $('<table>').addClass('table').addClass('table-bordered').css('table-layout', 'fixed');
@@ -152,7 +152,8 @@ define('views/import/step2', 'view', function (Dep) {
}
$select = this.getFieldDropdown(i, selectedName);
let $select = this.getFieldDropdown(i, selectedName);
$cell = $('<td>').append($select);
$row.append($cell);
@@ -130,7 +130,8 @@ define('views/modals/password-change-request', 'views/modal', function (Dep) {
if (!isValid) return;
$submit = this.$el.find('button[data-name="submit"]');
let $submit = this.$el.find('button[data-name="submit"]');
$submit.addClass('disabled');
Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
+1 -1
View File
@@ -445,7 +445,7 @@ define('views/notification/badge', 'view', function (Dep) {
});
});
$document = $(document);
let $document = $(document);
$document.on('mouseup.notification', e => {
if (!$container.is(e.target) && $container.has(e.target).length === 0) {
+2 -2
View File
@@ -774,7 +774,7 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct
var $p = $('.popover');
$p.each(function (i, el) {
$el = $(el);
let $el = $(el);
$el.css('top', ($el.position().top - blockHeight) + 'px');
});
}
@@ -787,7 +787,7 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct
var $p = $('.popover');
$p.each(function (i, el) {
$el = $(el);
let $el = $(el);
$el.css('top', ($el.position().top + blockHeight) + 'px');
});
}
+1 -1
View File
@@ -200,7 +200,7 @@ define(
},
'click .actions-menu a.mass-action': function (e) {
$el = $(e.currentTarget);
let $el = $(e.currentTarget);
var action = $el.data('action');
+4 -1
View File
@@ -121,7 +121,8 @@ define('views/role/record/table', 'view', function (Dep) {
$dropdowns.removeAttr('disabled');
$dropdowns.removeClass('hidden');
$dropdowns.each(function (i, select) {
$select = $(select);
let $select = $(select);
if (this.lowestLevelByDefault) {
$select.find('option').last().prop('selected', true);
} else {
@@ -140,7 +141,9 @@ define('views/role/record/table', 'view', function (Dep) {
$select.find('option').first().prop('selected', true);
}
}
$select.trigger('change');
this.controlSelectColor($select);
}.bind(this));
} else {
+2 -2
View File
@@ -552,8 +552,8 @@ define('views/site/navbar', 'view', function (Dep) {
this.adjustBodyMinHeightMethodName = 'adjustBodyMinHeightHorizontal';
$moreDd = $('#nav-more-tabs-dropdown');
$moreLi = $moreDd.closest('li');
let $moreDd = $('#nav-more-tabs-dropdown');
let $moreLi = $moreDd.closest('li');
var updateWidth = () => {
var windowWidth = window.innerWidth;
+2 -2
View File
@@ -128,7 +128,7 @@ define('views/stream/record/edit', 'views/record/base', function (Dep) {
this.post();
}
else if (e.keyCode === 9) {
$text = $(e.currentTarget);
let $text = $(e.currentTarget);
if ($text.val() === '') {
this.disablePostingMode();
@@ -301,4 +301,4 @@ define('views/stream/record/edit', 'views/record/base', function (Dep) {
},
});
});
});
+21 -10
View File
@@ -96,10 +96,13 @@ define('views/user/fields/teams', 'views/fields/link-multiple-with-role', functi
if (role != '') {
role = this.getHelper().escapeString(role);
roleHtml = ' <span class="text-muted chevron-right"></span> <span class="text-muted">' + role + '</span>';
roleHtml = ' <span class="text-muted chevron-right"></span> <span class="text-muted">' + role +
'</span>';
}
var lineHtml = '<div>' + '<a href="#' + this.foreignScope + '/view/' + id + '">' + name + '</a> ' + roleHtml + '</div>';
var lineHtml = '<div>' + '<a href="#' + this.foreignScope + '/view/' + id + '">' + name + '</a> ' +
roleHtml + '</div>';
return lineHtml;
},
@@ -109,25 +112,33 @@ define('views/user/fields/teams', 'views/fields/link-multiple-with-role', functi
if (!roleList.length) {
return;
};
}
if (roleList.length || roleValue) {
$role = $('<select class="role form-control input-sm pull-right" data-id="'+id+'">');
let $role = $('<select class="role form-control input-sm pull-right" data-id="'+id+'">');
roleList.unshift('');
roleList.forEach(function (role) {
roleList.forEach(role => {
var selectedHtml = (role == roleValue) ? 'selected': '';
role = this.getHelper().escapeString(role);
var label = role;
if (role == '') {
label = '--' + this.translate('None', 'labels') + '--';
}
option = '<option value="'+role+'" ' + selectedHtml + '>' + label + '</option>';
$role.append(option);
}, this);
let optionHtml = '<option value="'+role+'" ' + selectedHtml + '>' + label + '</option>';
$role.append(optionHtml);
});
return $role;
} else {
return $('<div class="small pull-right text-muted">').html(roleValue);
}
return $('<div class="small pull-right text-muted">').html(roleValue);
},
});
});
+12 -5
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('views/user/modals/access', 'views/modal', function (Dep) {
define('views/user/modals/access', ['views/modal'], function (Dep) {
return Dep.extend({
@@ -68,14 +68,22 @@ Espo.define('views/user/modals/access', 'views/modal', function (Dep) {
];
var fieldTable = Espo.Utils.cloneDeep(this.options.aclData.fieldTable || {});
for (var scope in fieldTable) {
var scopeData = fieldTable[scope] || {};
for (var field in scopeData) {
if (this.getMetadata().get(['app', 'acl', 'mandatory', 'scopeFieldLevel', scope, field]) !== null) {
if (
this.getMetadata()
.get(['app', 'acl', 'mandatory', 'scopeFieldLevel', scope, field]) !== null
) {
delete scopeData[field];
}
if (scopeData[field] && this.getMetadata().get(['entityDefs', scope, 'fields', field, 'readOnly'])) {
if (
scopeData[field] &&
this.getMetadata().get(['entityDefs', scope, 'fields', field, 'readOnly'])
) {
if (scopeData[field].edit === 'no' && scopeData[field].read === 'yes') {
delete scopeData[field];
}
@@ -92,7 +100,6 @@ Espo.define('views/user/modals/access', 'views/modal', function (Dep) {
});
this.headerHtml = this.translate('Access');
}
},
});
});