X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=js%2Fcrm.backbone.js;h=eb45249c1717e9fd3ac194efdfc7d0a811baabb0;hb=c3b9508c6f950351186517c3a321a0aed4ee7ff8;hp=647d70c735a9a9aa635d7102fd9bda03e3825329;hpb=481d774f43c20320836d1739a8a28fbe521312bf;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._);