This commit is contained in:
Yuri Kuznetsov
2023-07-30 16:45:40 +03:00
parent fcc990ac24
commit 2888e1fadd
26 changed files with 1213 additions and 1241 deletions
+37 -36
View File
@@ -26,50 +26,51 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/fields/foreign-array', ['views/fields/array'], function (Dep) {
import ArrayFieldView from 'views/fields/array';
return Dep.extend({
class ForeignArrayFieldView extends ArrayFieldView {
type: 'foreign',
type = 'foreign'
setupOptions: function () {
this.params.options = [];
setupOptions() {
this.params.options = [];
let field = this.params.field;
let link = this.params.link;
let field = this.params.field;
let link = this.params.link;
if (!field || !link) {
return;
}
if (!field || !link) {
return;
}
let scope = this.getMetadata().get(['entityDefs', this.model.entityType, 'links', link, 'entity']);
let scope = this.getMetadata().get(['entityDefs', this.model.entityType, 'links', link, 'entity']);
if (!scope) {
return;
}
if (!scope) {
return;
}
let {
optionsPath,
translation,
options,
isSorted,
displayAsLabel,
style,
} = this.getMetadata()
.get(['entityDefs', scope, 'fields', field]);
let {
optionsPath,
translation,
options,
isSorted,
displayAsLabel,
style,
} = this.getMetadata()
.get(['entityDefs', scope, 'fields', field]);
options = optionsPath ? this.getMetadata().get(optionsPath) : options;
options = optionsPath ? this.getMetadata().get(optionsPath) : options;
this.params.options = Espo.Utils.clone(options) || [];
this.params.translation = translation;
this.params.isSorted = isSorted || false;
this.params.displayAsLabel = displayAsLabel || false;
this.styleMap = style || {};
this.params.options = Espo.Utils.clone(options) || [];
this.params.translation = translation;
this.params.isSorted = isSorted || false;
this.params.displayAsLabel = displayAsLabel || false;
this.styleMap = style || {};
this.translatedOptions = Object.fromEntries(
this.params.options
.map(item => [item, this.getLanguage().translateOption(item, field, scope)])
);
},
});
});
this.translatedOptions = Object.fromEntries(
this.params.options
.map(item => [item, this.getLanguage().translateOption(item, field, scope)])
);
}
}
export default ForeignArrayFieldView;