From 1518570ac3c377cd95f54efc6d9215e4e4bac01b Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 19 Feb 2014 15:39:57 -0800 Subject: [PATCH] HR-216 - crm.backbone.js - Allow limiting the return to specific fields --- js/crm.backbone.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/js/crm.backbone.js b/js/crm.backbone.js index 647d70c735..46ed699808 100644 --- a/js/crm.backbone.js +++ b/js/crm.backbone.js @@ -117,11 +117,16 @@ _.defaults(ModelClass.prototype, { crmEntityName: crmEntityName, crmActions: {}, // map: string backboneActionName => string serverSideActionName + crmReturn: null, // array: list of fields to return toCrmAction: function(action) { return this.crmActions[action] ? this.crmActions[action] : action; }, toCrmCriteria: function() { - return (this.get('id')) ? {id: this.get('id')} : {}; + var result = (this.get('id')) ? {id: this.get('id')} : {}; + if (this.crmReturn != null) { + result.return = this.crmReturn; + } + return result; }, duplicate: function() { var newModel = new ModelClass(this.toJSON()); @@ -317,7 +322,13 @@ return this.crmActions[action] ? this.crmActions[action] : action; }, toCrmCriteria: function() { - return (this.crmCriteria) ? _.extend({}, this.crmCriteria) : {}; + var result = (this.crmCriteria) ? _.extend({}, this.crmCriteria) : {}; + if (this.crmReturn != null) { + result.return = this.crmReturn; + } else if (this.model && this.model.prototype.crmReturn != null) { + result.return = this.model.prototype.crmReturn; + } + return result; }, /** -- 2.25.1