X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=js%2Fcrm.backbone.js;h=eb45249c1717e9fd3ac194efdfc7d0a811baabb0;hb=87401f5438ce382f49beb22bf4dda10aa827efa7;hp=647d70c735a9a9aa635d7102fd9bda03e3825329;hpb=3bf2c46c41711b0ec2e3135cc4435f18d24ee3e6;p=civicrm-core.git diff --git a/js/crm.backbone.js b/js/crm.backbone.js index 647d70c735..eb45249c17 100644 --- a/js/crm.backbone.js +++ b/js/crm.backbone.js @@ -1,5 +1,4 @@ -(function($) { - var CRM = (window.CRM) ? (window.CRM) : (window.CRM = {}); +(function($, _) { if (!CRM.Backbone) CRM.Backbone = {}; /** @@ -117,11 +116,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 +321,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; }, /** @@ -554,8 +564,8 @@ var wrapError = function (model, options) { var error = options.error; options.error = function(resp) { - if (error) error(model, resp, options); + if (error) error(model, resp, optio) model.trigger('error', model, resp, options); }; }; -})(cj); +})(CRM.$, CRM._);