relatedAttributeFunctions

This commit is contained in:
yuri
2015-05-15 15:26:17 +03:00
parent 25ad4ffa43
commit 43f15252bb
3 changed files with 21 additions and 6 deletions
@@ -69,8 +69,7 @@
"layoutListDisabled": true,
"layoutMassUpdateDisabled": true,
"importDisabled": true,
"noLoad": true,
"noSave": true
"noLoad": true
}
},
"links": {
@@ -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) {
};
}
},
},
},
});
});
+6
View File
@@ -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);