Permalink
Browse files

Merge remote-tracking branch 'XTUPLE/quote_dev' into 19453

  • Loading branch information...
2 parents b1ee307 + 352cbbf commit 6285654883a35a2464c0109ec306d64bfc433289 Linda Nichols committed Mar 15, 2013
Showing with 12 additions and 7 deletions.
  1. +12 −7 lib/backbone-x/source/model.js
@@ -738,14 +738,14 @@ white:true*/
Return whether the model is in a read-only state. If an attribute name
is passed, returns whether that attribute is read-only. It is also
capable of checking the read only status of child objects via a search path string.
-
+
<pre><code>
// Inquire on the whole model
var readOnly = this.isReadOnly();
-
+
// Inquire on a single attribute
var readOnly = this.isReadOnly("name");
-
+
// Inquire using a search path
var readOnly = this.isReadOnly("contact.firstName");
</code></pre>
@@ -794,7 +794,7 @@ white:true*/
/**
A utility function that triggers a `notify` event. Useful for passing along
information to the interface. Bind to `notify` to use.
-
+
<pre><code>
var m = new XM.MyModel();
var raiseAlert = function (model, value, options) {
@@ -1194,10 +1194,14 @@ white:true*/
model,
// Helper functions
- isRelation = function (attr, value, type) {
+ isRelation = function (attr, value, type, options) {
+ options = options || {};
+
var rel;
rel = _.find(that.relations, function (relation) {
- return relation.key === attr && relation.type === type;
+ return relation.key === attr
+ && relation.type === type
+ && (!options.nestedOnly || relation.isNested);
});
return rel ? _.isObject(value) : false;
},
@@ -1263,7 +1267,8 @@ white:true*/
params.type = "_array".loc();
return XT.Error.clone('xt1003', { params: params });
}
- // Validate children
+ // Validate children if they're nested, but not if they're not
+ isRel = isRelation(attr, value, Backbone.HasMany, {nestedOnly: true});
if (isRel && value.models) {
for (i = 0; i < value.models.length; i++) {
model = value.models[i];

0 comments on commit 6285654

Please sign in to comment.