ref
This commit is contained in:
@@ -30,6 +30,16 @@ import EnumFieldView from 'views/fields/enum';
|
||||
|
||||
class EntityTypeFieldView extends EnumFieldView {
|
||||
|
||||
/**
|
||||
* @type {Record<string, Record>}
|
||||
* @protected
|
||||
*/
|
||||
scopesMetadataDefs
|
||||
|
||||
/**
|
||||
* @param {string} entityType
|
||||
* @return {boolean}
|
||||
*/
|
||||
checkAvailability(entityType) {
|
||||
const defs = this.scopesMetadataDefs[entityType] || {};
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<string, 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() {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user