EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
Link parent foreign filter entity types with already existing link with the same name
Yurii97fc28d7e3ba
diff --git a/client/src/views/admin/link-manager/modals/edit.js b/client/src/views/admin/link-manager/modals/edit.jsindex 60cfa7a571..614cd661d9 100644--- a/client/src/views/admin/link-manager/modals/edit.js+++ b/client/src/views/admin/link-manager/modals/edit.js@@ -32,6 +32,7 @@ import Index from 'views/admin/link-manager/index';import EnumFieldView from 'views/fields/enum';import Ajax from 'ajax';import Ui from 'ui';+import Utils from 'utils';class LinkManagerEditModalView extends ModalView {@@ -503,11 +504,9 @@ class LinkManagerEditModalView extends ModalView {model: model,mode: 'edit',selector: '.field[data-name="foreignLinkEntityTypeList"]',- defs: {- name: 'foreignLinkEntityTypeList',- params: {- options: this.model.get('parentEntityTypeList') || [],- },+ name: 'foreignLinkEntityTypeList',+ params: {+ options: this.getForeignLinkEntityTypeListOptions(),},});@@ -526,7 +525,7 @@ class LinkManagerEditModalView extends ModalView {this.getView('foreignLinkEntityTypeList');if (view && !this.noParentEntityTypeList) {- view.setOptionList(this.model.get('parentEntityTypeList') || []);+ view.setOptionList(this.getForeignLinkEntityTypeListOptions());}const checkedList = Espo.Utils.clone(this.model.get('foreignLinkEntityTypeList') || []);@@ -553,6 +552,42 @@ class LinkManagerEditModalView extends ModalView {this.listenTo(this.model, 'change:entityForeign', () => this.controlFilterField());}+ /**+ * @return {string[]}+ */+ getForeignLinkEntityTypeListOptions() {+ let values = Utils.clone(this.model.get('parentEntityTypeList') ?? []);++ console.log(values);++ const linkForeign = this.model.attributes.linkForeign;++ if (!linkForeign) {+ return [];+ }++ values = values.filter(entityType => {+ /**+ * @type {{+ * type: string,+ * } | null}+ */+ const defs = this.getMetadata().get(`entityDefs.${entityType}.links.${linkForeign}`);++ if (!defs) {+ return true;+ }++ if (defs.type !== 'hasChildren') {+ return false;+ }++ return true;+ });++ return values;+ }+getEntityTypeLayouts(entityType) {const defs = this.getMetadata().get(['clientDefs', entityType, 'additionalLayouts'], {});