This commit is contained in:
Yuri Kuznetsov
2024-08-20 15:43:54 +03:00
parent 603ca985df
commit fc24840a7b
8 changed files with 107 additions and 116 deletions
@@ -26,12 +26,11 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/settings/fields/date-format', ['views/fields/enum'], function (Dep) {
import EnumFieldView from 'views/fields/enum';
return Dep.extend({
export default class extends EnumFieldView {
setupOptions: function () {
this.params.options = this.getMetadata().get(['app', 'dateTime', 'dateFormatList']) || [];
},
});
});
setupOptions() {
this.params.options = this.getMetadata().get(['app', 'dateTime', 'dateFormatList']) || [];
}
}
@@ -26,38 +26,38 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/settings/fields/default-currency', ['views/fields/enum'], function (Dep) {
import EnumFieldView from 'views/fields/enum';
return Dep.extend({
export default class extends EnumFieldView {
setup: function () {
Dep.prototype.setup.call(this);
setup() {
super.setup();
this.validations.push('existing');
},
this.validations.push(() => this.validateExisting());
}
setupOptions: function () {
this.params.options = Espo.Utils.clone(this.getConfig().get('currencyList') || []);
},
setupOptions() {
this.params.options = Espo.Utils.clone(this.getConfig().get('currencyList') || []);
}
validateExisting: function () {
var currencyList = this.model.get('currencyList');
validateExisting() {
/** @type {string[]} */
const currencyList = this.model.get('currencyList');
if (!currencyList) {
return;
}
if (!currencyList) {
return false;
}
var value = this.model.get(this.name);
const value = this.model.get(this.name);
if (~currencyList.indexOf(value)) {
return;
}
if (currencyList.includes(value)) {
return false;
}
var msg = this.translate('fieldInvalid', 'messages').replace('{field}', this.getLabelText());
const msg = this.translate('fieldInvalid', 'messages').replace('{field}', this.getLabelText());
this.showValidationMessage(msg);
this.showValidationMessage(msg);
return true;
},
});
});
return true;
}
}
@@ -26,33 +26,32 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/settings/fields/email-address-lookup-entity-type-list',
['views/fields/entity-type-list'], function (Dep) {
import EntityTypeListFieldView from 'views/fields/entity-type-list';
return Dep.extend({
// noinspection JSUnusedGlobalSymbols
export default class extends EntityTypeListFieldView {
setupOptions: function () {
Dep.prototype.setupOptions.call(this);
setupOptions() {
super.setupOptions();
this.params.options = this.params.options.filter(scope => {
if (this.getMetadata().get(['scopes', scope, 'disabled'])) {
return;
}
this.params.options = this.params.options.filter(scope => {
if (this.getMetadata().get(['scopes', scope, 'disabled'])) {
return;
}
if (!this.getMetadata().get(['scopes', scope, 'object'])) {
return;
}
if (!this.getMetadata().get(['scopes', scope, 'object'])) {
return;
}
if (~['User', 'Contact', 'Lead', 'Account'].indexOf(scope)) {
return true;
}
if (['User', 'Contact', 'Lead', 'Account'].includes(scope)) {
return true;
}
var type = this.getMetadata().get(['scopes', scope, 'type']);
const type = this.getMetadata().get(['scopes', scope, 'type']);
if (type === 'Company' || type === 'Person') {
return true;
}
})
},
});
});
if (type === 'Company' || type === 'Person') {
return true;
}
})
}
}
@@ -26,20 +26,20 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/settings/fields/fiscal-year-shift', ['views/fields/enum-int'], function (Dep) {
import EnumIntFieldView from 'views/fields/enum-int';
return Dep.extend({
// noinspection JSUnusedGlobalSymbols
export default class extends EnumIntFieldView {
setupOptions: function () {
this.params.options = [];
this.translatedOptions = {};
setupOptions() {
this.params.options = [];
this.translatedOptions = {};
var monthNameList = this.getLanguage().get('Global', 'lists', 'monthNames') || [];
const monthNameList = this.getLanguage().get('Global', 'lists', 'monthNames') || [];
monthNameList.forEach((name, i) => {
this.params.options.push(i);
this.translatedOptions[i] = name;
});
},
});
});
monthNameList.forEach((name, i) => {
this.params.options.push(i);
this.translatedOptions[i] = name;
});
}
}
@@ -26,28 +26,26 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/settings/fields/global-search-entity-list', ['views/fields/multi-enum'], function (Dep) {
import MultiEnumFieldView from 'views/fields/multi-enum';
return Dep.extend({
export default class extends MultiEnumFieldView {
setup: function () {
setup() {
this.params.options = Object.keys(this.getMetadata().get('scopes'))
.filter(scope => {
const defs = this.getMetadata().get(['scopes', scope]) || {};
this.params.options = Object.keys(this.getMetadata().get('scopes'))
.filter(scope => {
let defs = this.getMetadata().get(['scopes', scope]) || {};
if (defs.disabled || scope === 'Note') {
return;
}
if (defs.disabled || scope === 'Note') {
return;
}
return defs.customizable && defs.entity;
})
.sort((v1, v2) => {
return this.translate(v1, 'scopeNamesPlural')
.localeCompare(this.translate(v2, 'scopeNamesPlural'));
});
return defs.customizable && defs.entity;
})
.sort((v1, v2) => {
return this.translate(v1, 'scopeNamesPlural')
.localeCompare(this.translate(v2, 'scopeNamesPlural'));
});
Dep.prototype.setup.call(this);
},
});
});
super.setup();
}
}
@@ -26,12 +26,10 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/settings/fields/group-tab-list', ['views/settings/fields/tab-list'], function (Dep) {
import TabListFieldView from 'views/settings/fields/tab-list';
return Dep.extend({
export default class extends TabListFieldView {
noGroups: true,
noDelimiters: true,
});
});
noGroups = true
noDelimiters = true
}
@@ -26,21 +26,19 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/settings/fields/history-entity-list', ['views/fields/entity-type-list'], function (Dep) {
import EntityTypeListFieldView from 'views/fields/entity-type-list';
return Dep.extend({
export default class extends EntityTypeListFieldView {
setupOptions: function () {
setupOptions() {
super.setupOptions();
Dep.prototype.setupOptions.call(this);
this.params.options = this.params.options.filter(scope => {
if (this.getMetadata().get('scopes.' + scope + '.disabled')) return;
if (!this.getMetadata().get('scopes.' + scope + '.object')) return;
if (!this.getMetadata().get('scopes.' + scope + '.activity')) return;
this.params.options = this.params.options.filter(scope => {
if (this.getMetadata().get('scopes.' + scope + '.disabled')) return;
if (!this.getMetadata().get('scopes.' + scope + '.object')) return;
if (!this.getMetadata().get('scopes.' + scope + '.activity')) return;
return true;
})
},
});
});
return true;
})
}
}
+7 -8
View File
@@ -26,13 +26,12 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/settings/fields/language', ['views/fields/enum'], function (Dep) {
import EnumFieldView from 'views/fields/enum';
return Dep.extend({
export default class extends EnumFieldView {
setupOptions: function () {
this.params.options = Espo.Utils.clone(this.getMetadata().get(['app', 'language', 'list']) || []);
this.translatedOptions = Espo.Utils.clone(this.getLanguage().translate('language', 'options') || {});
},
});
});
setupOptions() {
this.params.options = Espo.Utils.clone(this.getMetadata().get(['app', 'language', 'list']) || []);
this.translatedOptions = Espo.Utils.clone(this.getLanguage().translate('language', 'options') || {});
}
}