From b282ea4bd024e3e100940e01057ee37291f26969 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 10 Sep 2024 13:23:46 +0300 Subject: [PATCH] ref --- client/src/views/fields/entity-type.js | 10 + client/src/views/team/modals/detail.js | 10 +- client/src/views/team/record/detail.js | 6 +- client/src/views/team/record/edit.js | 6 +- client/src/views/team/record/list.js | 13 +- .../src/views/template/fields/entity-type.js | 27 +- client/src/views/template/fields/font-face.js | 25 +- client/src/views/template/fields/variables.js | 612 +++++++++--------- 8 files changed, 360 insertions(+), 349 deletions(-) diff --git a/client/src/views/fields/entity-type.js b/client/src/views/fields/entity-type.js index b54536a583..19ee3c6bc3 100644 --- a/client/src/views/fields/entity-type.js +++ b/client/src/views/fields/entity-type.js @@ -30,6 +30,16 @@ import EnumFieldView from 'views/fields/enum'; class EntityTypeFieldView extends EnumFieldView { + /** + * @type {Record} + * @protected + */ + scopesMetadataDefs + + /** + * @param {string} entityType + * @return {boolean} + */ checkAvailability(entityType) { const defs = this.scopesMetadataDefs[entityType] || {}; diff --git a/client/src/views/team/modals/detail.js b/client/src/views/team/modals/detail.js index 7ae14ae755..57ccff9955 100644 --- a/client/src/views/team/modals/detail.js +++ b/client/src/views/team/modals/detail.js @@ -26,11 +26,9 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/team/modals/detail', ['views/modals/detail'], function (Dep) { +import DetailModalView from 'views/modals/detail'; - return Dep.extend({ +export default class extends DetailModalView { - editDisabled: true, - - }); -}); + editDisabled = true; +} diff --git a/client/src/views/team/record/detail.js b/client/src/views/team/record/detail.js index 31577b15c2..5a6aa1199d 100644 --- a/client/src/views/team/record/detail.js +++ b/client/src/views/team/record/detail.js @@ -26,9 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/team/record/detail', ['views/record/detail'], function (Dep) { +import DetailRecordView from 'views/record/detail'; - return Dep.extend({ +export default class extends DetailRecordView {} - }); -}); diff --git a/client/src/views/team/record/edit.js b/client/src/views/team/record/edit.js index 6b1964b5ea..514347b2ed 100644 --- a/client/src/views/team/record/edit.js +++ b/client/src/views/team/record/edit.js @@ -26,9 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/team/record/edit', ['views/record/edit'], function (Dep) { +import EditRecordView from 'views/record/edit'; - return Dep.extend({ +export default class extends EditRecordView {} - }); -}); diff --git a/client/src/views/team/record/list.js b/client/src/views/team/record/list.js index 05dc2188ba..cf3adaedf2 100644 --- a/client/src/views/team/record/list.js +++ b/client/src/views/team/record/list.js @@ -26,12 +26,11 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/team/record/list', ['views/record/list'], function (Dep) { +import ListRecordView from 'views/record/list'; - return Dep.extend({ +export default class extends ListRecordView { - quickDetailDisabled: true, - quickEditDisabled: true, - checkAllResultDisabled: true, - }); -}); + quickDetailDisabled = true + quickEditDisabled = true + checkAllResultDisabled = true +} diff --git a/client/src/views/template/fields/entity-type.js b/client/src/views/template/fields/entity-type.js index 82549eb48b..c383b3e422 100644 --- a/client/src/views/template/fields/entity-type.js +++ b/client/src/views/template/fields/entity-type.js @@ -26,20 +26,21 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/template/fields/entity-type', ['views/fields/entity-type'], function (Dep) { +import EntityTypeFieldView from 'views/fields/entity-type'; - return Dep.extend({ +export default class extends EntityTypeFieldView { - checkAvailability: function (entityType) { - var defs = this.scopesMetadataDefs[entityType] || {}; + checkAvailability(entityType) { + const defs = this.scopesMetadataDefs[entityType] || {}; - if (defs.pdfTemplate) { - return true; - } + if (defs.pdfTemplate) { + return true; + } - if (defs.entity && defs.object) { - return true; - } - }, - }); -}); + if (defs.entity && defs.object) { + return true; + } + + return false; + } +} diff --git a/client/src/views/template/fields/font-face.js b/client/src/views/template/fields/font-face.js index f914256df7..0895c35090 100644 --- a/client/src/views/template/fields/font-face.js +++ b/client/src/views/template/fields/font-face.js @@ -26,22 +26,19 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/template/fields/font-face', ['views/fields/enum'], function (Dep) { +import EnumFieldView from 'views/fields/enum'; - return Dep.extend({ +// noinspection JSUnusedGlobalSymbols +export default class extends EnumFieldView { - setupOptions: function () { - var engine = this.getConfig().get('pdfEngine') || 'Dompdf'; + setupOptions() { + const engine = this.getConfig().get('pdfEngine') || 'Dompdf'; - var fontFaceList = this.getMetadata().get([ - 'app', 'pdfEngines', engine, 'fontFaceList', - ]) || []; + let fontFaceList = this.getMetadata().get(['app', 'pdfEngines', engine, 'fontFaceList']) || []; - fontFaceList = Espo.Utils.clone(fontFaceList); + fontFaceList = Espo.Utils.clone(fontFaceList); + fontFaceList.unshift(''); - fontFaceList.unshift(''); - - this.params.options = fontFaceList; - }, - }); -}); + this.params.options = fontFaceList; + } +} diff --git a/client/src/views/template/fields/variables.js b/client/src/views/template/fields/variables.js index 5f151f7cc3..2e4ef153a7 100644 --- a/client/src/views/template/fields/variables.js +++ b/client/src/views/template/fields/variables.js @@ -26,65 +26,185 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/template/fields/variables', ['views/fields/base', 'ui/select'], -function (Dep, /** module:ui/select */Select) { +import BaseFieldView from 'views/fields/base'; +import Select from 'ui/select'; - return Dep.extend({ +export default class extends BaseFieldView { - inlineEditDisabled: true, + inlineEditDisabled = true - detailTemplate: 'template/fields/variables/detail', - editTemplate: 'template/fields/variables/edit', + detailTemplate = 'template/fields/variables/detail' + editTemplate = 'template/fields/variables/edit' - data: function () { - return { - attributeList: this.attributeList, - entityType: this.model.get('entityType'), - translatedOptions: this.translatedOptions - }; - }, + // noinspection JSCheckFunctionSignatures + data() { + // noinspection JSValidateTypes + return { + attributeList: this.attributeList, + entityType: this.model.get('entityType'), + translatedOptions: this.translatedOptions, + }; + } - events: { - 'change [data-name="variables"]': function () { - var attribute = this.$el.find('[data-name="variables"]').val(); + setup() { + this.addHandler('change', '[data-name="variables"]', () => { + const attribute = this.$el.find('[data-name="variables"]').val(); - var $copy = this.$el.find('[data-name="copy"]'); + const $copy = this.$el.find('[data-name="copy"]'); - if (attribute !== '') { - if (this.textVariables[attribute]) { - $copy.val('{{{' + attribute + '}}}'); - } else { - $copy.val('{{' + attribute + '}}'); - } + if (attribute !== '') { + if (this.textVariables[attribute]) { + $copy.val('{{{' + attribute + '}}}'); } else { - $copy.val(''); + $copy.val('{{' + attribute + '}}'); } + } else { + $copy.val(''); } - }, + }); - setup: function () { + this.setupAttributeList(); + this.setupTranslatedOptions(); + + this.listenTo(this.model, 'change:entityType', () => { this.setupAttributeList(); this.setupTranslatedOptions(); + this.reRender(); + }); + } - this.listenTo(this.model, 'change:entityType', () => { - this.setupAttributeList(); - this.setupTranslatedOptions(); - this.reRender(); + setupAttributeList() { + this.translatedOptions = {}; + + const entityType = this.model.get('entityType'); + const fieldList = this.getFieldManager().getEntityTypeFieldList(entityType); + const ignoreFieldList = []; + + fieldList.forEach(field => { + const aclDefs = /** @type {Record} */ + this.getMetadata().get(['entityAcl', entityType, 'fields', field]) || {}; + + const fieldDefs = /** @type {Record} */ + this.getMetadata().get(['entityDefs', entityType, 'fields', field]) || {}; + + if ( + aclDefs.onlyAdmin || + aclDefs.forbidden || + aclDefs.internal || + fieldDefs.disabled || + fieldDefs.utility || + fieldDefs.directAccessDisabled || + fieldDefs.templatePlaceholderDisabled + ) { + ignoreFieldList.push(field); + } + }); + + let attributeList = this.getFieldManager().getEntityTypeAttributeList(entityType) || []; + const forbiddenList = Espo.Utils.clone(this.getAcl().getScopeForbiddenAttributeList(entityType)); + + ignoreFieldList.forEach((field) => { + this.getFieldManager().getEntityTypeFieldAttributeList(entityType, field).forEach(attribute => { + forbiddenList.push(attribute); }); - }, + }); - setupAttributeList: function () { - this.translatedOptions = {}; + attributeList = attributeList.filter(item => { + if (~forbiddenList.indexOf(item)) { + return; + } - var entityType = this.model.get('entityType'); + const fieldType = this.getMetadata().get(['entityDefs', entityType, 'fields', item, 'type']); - var fieldList = this.getFieldManager().getEntityTypeFieldList(entityType); + if (fieldType === 'map') { + return; + } - var ignoreFieldList = []; + return true; + }); + + + attributeList.push('id'); + + if (this.getMetadata().get(`entityDefs.${entityType}.fields.name.type`) === 'personName') { + if (!~attributeList.indexOf('name')) { + attributeList.unshift('name'); + } + } + + this.addAdditionalPlaceholders(entityType, attributeList); + + attributeList = attributeList.sort((v1, v2) => { + return this.translate(v1, 'fields', entityType).localeCompare(this.translate(v2, 'fields', entityType)); + }); + + this.attributeList = attributeList; + + this.textVariables = {}; + + this.attributeList.forEach((item) => { + if ( + ~['text', 'wysiwyg'] + .indexOf(this.getMetadata().get(['entityDefs', entityType, 'fields', item, 'type'])) + ) { + this.textVariables[item] = true; + } + }); + + if (!~this.attributeList.indexOf('now')) { + this.attributeList.unshift('now'); + } + + if (!~this.attributeList.indexOf('today')) { + this.attributeList.unshift('today'); + } + + // noinspection SpellCheckingInspection + attributeList.unshift('pagebreak'); + + this.attributeList.unshift(''); + + const links = /** @type {Record} */this.getMetadata().get(`entityDefs.${entityType}.links`) || {}; + + const linkList = Object.keys(links).sort((v1, v2) => { + return this.translate(v1, 'links', entityType).localeCompare(this.translate(v2, 'links', entityType)); + }); + + linkList.forEach(link => { + const type = links[link].type; + + if (type !== 'belongsTo') { + return; + } + + const scope = links[link].entity; + + if (!scope) { + return; + } + + if (links[link].disabled || links[link].utility) { + return; + } + + if ( + this.getMetadata().get(['entityAcl', entityType, 'links', link, 'onlyAdmin']) || + this.getMetadata().get(['entityAcl', entityType, 'links', link, 'forbidden']) || + this.getMetadata().get(['entityAcl', entityType, 'links', link, 'internal']) + ) { + return; + } + + const fieldList = this.getFieldManager().getEntityTypeFieldList(scope); + + const ignoreFieldList = []; fieldList.forEach(field => { - let aclDefs = this.getMetadata().get(['entityAcl', entityType, 'fields', field]) || {}; - let fieldDefs = this.getMetadata().get(['entityDefs', entityType, 'fields', field]) || {}; + const aclDefs = /** @type {Record} */ + this.getMetadata().get(['entityAcl', entityType, 'fields', field]) || {}; + + const fieldDefs = /** @type {Record} */ + this.getMetadata().get(['entityDefs', entityType, 'fields', field]) || {}; if ( aclDefs.onlyAdmin || @@ -99,20 +219,21 @@ function (Dep, /** module:ui/select */Select) { } }); - var attributeList = this.getFieldManager().getEntityTypeAttributeList(entityType) || []; - - var forbiddenList = Espo.Utils.clone(this.getAcl().getScopeForbiddenAttributeList(entityType)); + let attributeList = this.getFieldManager().getEntityTypeAttributeList(scope) || []; + const forbiddenList = Espo.Utils.clone(this.getAcl().getScopeForbiddenAttributeList(scope)); ignoreFieldList.forEach((field) => { - this.getFieldManager().getEntityTypeFieldAttributeList(entityType, field).forEach(function (attribute) { + this.getFieldManager().getEntityTypeFieldAttributeList(scope, field).forEach((attribute) => { forbiddenList.push(attribute); }); }); attributeList = attributeList.filter((item) => { - if (~forbiddenList.indexOf(item)) return; + if (~forbiddenList.indexOf(item)) { + return; + } - var fieldType = this.getMetadata().get(['entityDefs', entityType, 'fields', item, 'type']); + const fieldType = this.getMetadata().get(['entityDefs', scope, 'fields', item, 'type']); if (fieldType === 'map') { return; @@ -121,301 +242,190 @@ function (Dep, /** module:ui/select */Select) { return true; }); - attributeList.push('id'); - if (this.getMetadata().get('entityDefs.' + entityType + '.fields.name.type') === 'personName') { - if (!~attributeList.indexOf('name')) { - attributeList.unshift('name'); - } + if (this.getMetadata().get(`entityDefs.${scope}.fields.name.type`) === 'personName') { + attributeList.unshift('name'); } - this.addAdditionalPlaceholders(entityType, attributeList); + const originalAttributeList = Espo.Utils.clone(attributeList); - attributeList = attributeList.sort((v1, v2) => { - return this.translate(v1, 'fields', entityType).localeCompare(this.translate(v2, 'fields', entityType)); + this.addAdditionalPlaceholders(scope, attributeList, link, entityType); + + attributeList.sort((v1, v2) => { + return this.translate(v1, 'fields', scope).localeCompare(this.translate(v2, 'fields', scope)); }); - this.attributeList = attributeList; + attributeList.forEach((item) => { + if (~originalAttributeList.indexOf(item)) { + this.attributeList.push(link + '.' + item); + } else { + this.attributeList.push(item); + } + }); - this.textVariables = {}; + attributeList.forEach((item) => { + const variable = `${link}.${item}`; - this.attributeList.forEach((item) => { if ( ~['text', 'wysiwyg'] - .indexOf(this.getMetadata().get(['entityDefs', entityType, 'fields', item, 'type'])) + .indexOf(this.getMetadata().get(['entityDefs', scope, 'fields', item, 'type'])) ) { - this.textVariables[item] = true; + this.textVariables[variable] = true; } }); + }); - if (!~this.attributeList.indexOf('now')) { - this.attributeList.unshift('now'); + return this.attributeList; + } + + addAdditionalPlaceholders(entityType, attributeList, link, superEntityType) { + let value; + + function removeItem(attributeList, item) { + for (let i = 0; i < attributeList.length; i++) { + if (attributeList[i] === item) { + attributeList.splice(i, 1); + } + } + } + + const fieldDefs = this.getMetadata().get(['entityDefs', entityType, 'fields']) || {}; + + for (const field in fieldDefs) { + const fieldType = fieldDefs[field].type; + + let item = field; + + if (link) { + item = `${link}.${item}`; } - if (!~this.attributeList.indexOf('today')) { - this.attributeList.unshift('today'); + if (fieldType === 'image') { + removeItem(attributeList, field + 'Name'); + removeItem(attributeList, field + 'Id'); + + value = 'imageTag ' + item + 'Id'; + attributeList.push(value); + + this.translatedOptions[value] = this.translate(field, 'fields', entityType); + if (link) { + this.translatedOptions[value] = this.translate(link, 'links', superEntityType) + '.' + + this.translatedOptions[value]; + } + } else if (fieldType === 'barcode') { + removeItem(attributeList, field); + + const barcodeType = this.getMetadata().get(['entityDefs', entityType, 'fields', field, 'codeType']); + value = `barcodeImage ${item} type='${barcodeType}'`; + + attributeList.push(value); + + this.translatedOptions[value] = this.translate(field, 'fields', entityType); + if (link) { + this.translatedOptions[value] = this.translate(link, 'links', superEntityType) + '.' + + this.translatedOptions[value]; + } } + } + } - attributeList.unshift('pagebreak'); + setupTranslatedOptions() { + const entityType = this.model.get('entityType'); - this.attributeList.unshift(''); + this.attributeList.forEach((item) => { + const link = item.split('.')[0]; - var links = this.getMetadata().get('entityDefs.' + entityType + '.links') || {}; + // noinspection SpellCheckingInspection + if (~['today', 'now', 'pagebreak'].indexOf(item)) { + if (!this.getMetadata().get(['entityDefs', entityType, 'fields', item])) { + this.translatedOptions[item] = this.getLanguage() + .translateOption(item, 'placeholders', 'Template'); - var linkList = Object.keys(links).sort((v1, v2) => { - return this.translate(v1, 'links', entityType).localeCompare(this.translate(v2, 'links', entityType)); - }); - - linkList.forEach((link) => { - var type = links[link].type; - - if (type !== 'belongsTo') { return; } + } - var scope = links[link].entity; - if (!scope) return; + let field = item; + let scope = entityType; + let isForeign = false; - if (links[link].disabled || links[link].utility) { - return; + if (~item.indexOf('.')) { + isForeign = true; + field = item.split('.')[1]; + scope = this.getMetadata().get(`entityDefs.${entityType}.links.${link}.entity`); + } + + if (this.translatedOptions[item]) { + return; + } + + this.translatedOptions[item] = this.translate(field, 'fields', scope); + + if (field.indexOf('Id') === field.length - 2) { + const baseField = field.substr(0, field.length - 2); + + if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) { + this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + + ' (' + this.translate('id', 'fields') + ')'; } + } + else if (field.indexOf('Name') === field.length - 4) { + const baseField = field.substr(0, field.length - 4); - if ( - this.getMetadata().get(['entityAcl', entityType, 'links', link, 'onlyAdmin']) - || - this.getMetadata().get(['entityAcl', entityType, 'links', link, 'forbidden']) - || - this.getMetadata().get(['entityAcl', entityType, 'links', link, 'internal']) - ) { - return; + if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) { + this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + + ' (' + this.translate('name', 'fields') + ')'; } + } + else if (field.indexOf('Type') === field.length - 4) { + const baseField = field.substr(0, field.length - 4); - var fieldList = this.getFieldManager().getEntityTypeFieldList(scope); - - var ignoreFieldList = []; - - fieldList.forEach(field => { - let aclDefs = this.getMetadata().get(['entityAcl', entityType, 'fields', field]) || {}; - let fieldDefs = this.getMetadata().get(['entityDefs', entityType, 'fields', field]) || {}; - - if ( - aclDefs.onlyAdmin || - aclDefs.forbidden || - aclDefs.internal || - fieldDefs.disabled || - fieldDefs.utility || - fieldDefs.directAccessDisabled || - fieldDefs.templatePlaceholderDisabled - ) { - ignoreFieldList.push(field); - } - }); - - var attributeList = this.getFieldManager().getEntityTypeAttributeList(scope) || []; - - var forbiddenList = Espo.Utils.clone(this.getAcl().getScopeForbiddenAttributeList(scope)); - - ignoreFieldList.forEach((field) => { - this.getFieldManager().getEntityTypeFieldAttributeList(scope, field).forEach((attribute) => { - forbiddenList.push(attribute); - }); - }); - - attributeList = attributeList.filter((item) => { - if (~forbiddenList.indexOf(item)) { - return; - } - - var fieldType = this.getMetadata().get(['entityDefs', scope, 'fields', item, 'type']); - - if (fieldType === 'map') { - return; - } - - return true; - }); - - attributeList.push('id'); - - if (this.getMetadata().get('entityDefs.' + scope + '.fields.name.type') === 'personName') { - attributeList.unshift('name'); - } - - var originalAttributeList = Espo.Utils.clone(attributeList); - - this.addAdditionalPlaceholders(scope, attributeList, link, entityType); - - attributeList.sort((v1, v2) => { - return this.translate(v1, 'fields', scope).localeCompare(this.translate(v2, 'fields', scope)); - }); - - attributeList.forEach((item) => { - if (~originalAttributeList.indexOf(item)) { - this.attributeList.push(link + '.' + item); - } else { - this.attributeList.push(item); - } - }); - - attributeList.forEach((item) => { - var variable = link + '.' + item; - - if ( - ~['text', 'wysiwyg'] - .indexOf(this.getMetadata().get(['entityDefs', scope, 'fields', item, 'type'])) - ) { - this.textVariables[variable] = true; - } - }); - }); - - return this.attributeList; - }, - - addAdditionalPlaceholders: function (entityType, attributeList, link, superEntityType) { - function removeItem(attributeList, item) { - for (var i = 0; i < attributeList.length; i++) { - if (attributeList[i] === item) { - attributeList.splice(i, 1); - } + if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) { + this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + + ' (' + this.translate('type', 'fields') + ')'; } } - var fieldDefs = this.getMetadata().get(['entityDefs', entityType, 'fields']) || {}; + if (field.indexOf('Ids') === field.length - 3) { + const baseField = field.substr(0, field.length - 3); - for (var field in fieldDefs) { - var fieldType = fieldDefs[field].type; - - var item = field; - if (link) item = link + '.' + item; - - var cAttributeList = Espo.Utils.clone(attributeList); - - if (fieldType === 'image') { - removeItem(attributeList, field + 'Name'); - removeItem(attributeList, field + 'Id'); - - var value = 'imageTag '+item+'Id'; - attributeList.push(value); - - this.translatedOptions[value] = this.translate(field, 'fields', entityType); - if (link) { - this.translatedOptions[value] = this.translate(link, 'links', superEntityType) + '.' + - this.translatedOptions[value]; - } - } else if (fieldType === 'barcode') { - removeItem(attributeList, field); - - var barcodeType = this.getMetadata().get(['entityDefs', entityType, 'fields', field, 'codeType']); - var value = "barcodeImage "+item+" type='"+barcodeType+"'"; - - attributeList.push(value); - - this.translatedOptions[value] = this.translate(field, 'fields', entityType); - if (link) { - this.translatedOptions[value] = this.translate(link, 'links', superEntityType) + '.' + - this.translatedOptions[value]; - } + if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) { + this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + + ' (' + this.translate('ids', 'fields') + ')'; } } - }, + else if (field.indexOf('Names') === field.length - 5) { + const baseField = field.substr(0, field.length - 5); - setupTranslatedOptions: function () { - var entityType = this.model.get('entityType'); - - this.attributeList.forEach((item) => { - if (~['today', 'now', 'pagebreak'].indexOf(item)) { - if (!this.getMetadata().get(['entityDefs', entityType, 'fields', item])) { - this.translatedOptions[item] = this.getLanguage() - .translateOption(item, 'placeholders', 'Template'); - - return; - } + if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) { + this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + + ' (' + this.translate('names', 'fields') + ')'; } - - var field = item; - var scope = entityType; - var isForeign = false; - - if (~item.indexOf('.')) { - isForeign = true; - field = item.split('.')[1]; - var link = item.split('.')[0]; - scope = this.getMetadata().get('entityDefs.' + entityType + '.links.' + link + '.entity'); - } - - if (this.translatedOptions[item]) { - return; - } - - this.translatedOptions[item] = this.translate(field, 'fields', scope); - - if (field.indexOf('Id') === field.length - 2) { - var baseField = field.substr(0, field.length - 2); - - if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) { - this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + - ' (' + this.translate('id', 'fields') + ')'; - } - } - else if (field.indexOf('Name') === field.length - 4) { - var baseField = field.substr(0, field.length - 4); - - if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) { - this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + - ' (' + this.translate('name', 'fields') + ')'; - } - } - else if (field.indexOf('Type') === field.length - 4) { - var baseField = field.substr(0, field.length - 4); - - if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) { - this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + - ' (' + this.translate('type', 'fields') + ')'; - } - } - - if (field.indexOf('Ids') === field.length - 3) { - var baseField = field.substr(0, field.length - 3); - - if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) { - this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + - ' (' + this.translate('ids', 'fields') + ')'; - } - } - else if (field.indexOf('Names') === field.length - 5) { - var baseField = field.substr(0, field.length - 5); - if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) { - this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + - ' (' + this.translate('names', 'fields') + ')'; - } - } - else if (field.indexOf('Types') === field.length - 5) { - var baseField = field.substr(0, field.length - 5); - - if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) { - this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + - ' (' + this.translate('types', 'fields') + ')'; - } - } - - if (isForeign) { - this.translatedOptions[item] = this.translate(link, 'links', entityType) + '.' + - this.translatedOptions[item]; - } - }); - }, - - afterRender: function () { - Dep.prototype.afterRender.call(this); - - if (this.mode === this.MODE_EDIT) { - Select.init(this.$el.find('[data-name="variables"]')); } - }, + else if (field.indexOf('Types') === field.length - 5) { + const baseField = field.substr(0, field.length - 5); - fetch: function () {}, + if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) { + this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + + ' (' + this.translate('types', 'fields') + ')'; + } + } - }); -}); + if (isForeign) { + this.translatedOptions[item] = this.translate(link, 'links', entityType) + '.' + + this.translatedOptions[item]; + } + }); + } + + afterRender() { + super.afterRender(); + + if (this.mode === this.MODE_EDIT) { + Select.init(this.$el.find('[data-name="variables"]')); + } + } + + fetch() {} +}