From 43f15252bb5bceae0619fc2c6bbd1f18226aaecc Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 15 May 2015 15:26:17 +0300 Subject: [PATCH] relatedAttributeFunctions --- .../metadata/entityDefs/Document.json | 3 +-- .../crm/src/views/opportunity/detail.js | 18 ++++++++++++++---- frontend/client/src/views/detail.js | 6 ++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Document.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Document.json index 4bfa238fb8..f2ee2e3fe6 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Document.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Document.json @@ -69,8 +69,7 @@ "layoutListDisabled": true, "layoutMassUpdateDisabled": true, "importDisabled": true, - "noLoad": true, - "noSave": true + "noLoad": true } }, "links": { diff --git a/frontend/client/modules/crm/src/views/opportunity/detail.js b/frontend/client/modules/crm/src/views/opportunity/detail.js index aaab7e7cc9..3f306e90f9 100644 --- a/frontend/client/modules/crm/src/views/opportunity/detail.js +++ b/frontend/client/modules/crm/src/views/opportunity/detail.js @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with EspoCRM. If not, see http://www.gnu.org/licenses/. - ************************************************************************/ + ************************************************************************/ Espo.define('Crm:Views.Opportunity.Detail', 'Views.Detail', function (Dep) { @@ -29,7 +29,17 @@ Espo.define('Crm:Views.Opportunity.Detail', 'Views.Detail', function (Dep) { 'accountName': 'accountName' }, }, - + + relatedAttributeFunctions: { + 'documents': function () { + var data = {}; + if (this.model.get('accountId')) { + data['accountsIds'] = [this.model.get('accountId')] + } + return data; + } + }, + selectRelatedFilters: { 'contacts': { 'account': function () { @@ -42,10 +52,10 @@ Espo.define('Crm:Views.Opportunity.Detail', 'Views.Detail', function (Dep) { }; } }, - + }, }, - + }); }); diff --git a/frontend/client/src/views/detail.js b/frontend/client/src/views/detail.js index 552f1870b7..e2653cad5e 100644 --- a/frontend/client/src/views/detail.js +++ b/frontend/client/src/views/detail.js @@ -185,6 +185,8 @@ Espo.define('Views.Detail', 'Views.Main', function (Dep) { relatedAttributeMap: {}, + relatedAttributeFunctions: {}, + selectRelatedFilters: {}, actionCreateRelated: function (data) { @@ -195,6 +197,10 @@ Espo.define('Views.Detail', 'Views.Main', function (Dep) { var attributes = {}; + if (this.relatedAttributeFunctions[link] && typeof this.relatedAttributeFunctions[link] == 'function') { + attributes = _.extend(this.relatedAttributeFunctions[link].call(this), attributes); + } + Object.keys(this.relatedAttributeMap[link] || {}).forEach(function (attr) { attributes[this.relatedAttributeMap[link][attr]] = this.model.get(attr); }, this);