Permalink
Browse files

issue #19735: Remove components of model no longer needed due to upgr…

…ade.
  • Loading branch information...
1 parent 6ebadd9 commit edc40a0e74c86b57c5a30a3ed4ba64211eb6f6ba John Rogelstad committed Mar 17, 2013
@@ -81,10 +81,11 @@ white:true*/
// METHODS
//
- validateEdit: function (attributes) {
+ validate: function (attributes) {
if (attributes.parent && attributes.parent.id === this.id) {
return XT.Error.clone('xt2006');
}
+ return XM.Document.prototype.validate.apply(this, arguments);
}
});
@@ -65,7 +65,7 @@ white:true*/
return this;
},
- validateEdit: function (attributes, options) {
+ validate: function (attributes, options) {
var settings = XT.session.getSettings(),
strict = settings.get('StrictAddressCountry'),
country = attributes.country,
@@ -80,6 +80,7 @@ white:true*/
return XT.Error.clone('xt2008');
}
}
+ return XM.Document.prototype.validate.apply(this, arguments);
}
};
@@ -284,7 +285,7 @@ white:true*/
// METHODS
//
- validateEdit: function (attributes) {
+ validate: function (attributes) {
var params = {};
if (attributes.abbreviation &&
@@ -300,6 +301,7 @@ white:true*/
params.length = "3";
return XT.Error.clone('xt1006', { params: params });
}
+ return XM.Document.prototype.validate.apply(this, arguments);
}
});
@@ -67,10 +67,11 @@ white:true*/
return name.join(' ');
},
- validateSave: function (attributes, options) {
+ validate: function (attributes, options) {
if (!attributes.firstName && !attributes.lastName) {
return XT.Error.clone('xt2004');
}
+ return XM.Document.prototype.validate.apply(this, arguments);
}
});
@@ -244,14 +244,15 @@ white:true*/
return this.get('abbreviation') + ' - ' + this.get('symbol');
},
- validateEdit: function (attributes) {
+ validate: function (attributes) {
var params = {};
if (attributes.abbreviation &&
attributes.abbreviation.length !== 3) {
params.attr = "_abbreviation".loc();
params.length = "3";
return XT.Error.clone('xt1006', { params: params });
}
+ return XM.Document.prototype.validate.apply(this, arguments);
}
});
@@ -186,11 +186,12 @@ white:true*/
if (value) { this.set('status', XM.Incident.ASSIGNED); }
},
- validateSave: function () {
+ validate: function () {
var K = XM.Incident;
if (this.get('status') === K.ASSIGNED && !this.get('assignedTo')) {
return XT.Error.clone('xt2001');
}
+ return XM.Document.prototype.validate.apply(this, arguments);
},
save: function (key, value, options) {
@@ -234,12 +234,13 @@ white:true*/
}
},
- validateSave: function () {
+ validate: function () {
var isSold = this.get('isSold'),
productCategory = this.get('productCategory');
if (isSold && (productCategory.id || -1) === -1) {
return XT.Error.clone('xt2005');
}
+ return XM.Document.prototype.validate.apply(this, arguments);
}
});
@@ -710,7 +710,7 @@ white:true*/
}
},
- validateSave: function () {
+ validate: function () {
var customer = this.get("customer"),
shipto = this.get("shipto"),
total = this.get("total"),
@@ -729,6 +729,8 @@ white:true*/
if (!lineItems.length) {
return XT.Error.clone('xt2012');
}
+
+ return XM.Document.prototype.validate.apply(this, arguments);
},
// ..........................................................
@@ -1455,7 +1457,7 @@ white:true*/
}
},
- validateSave: function () {
+ validate: function () {
var quantity = this.get("quantity");
// Check quantity
@@ -1467,7 +1469,8 @@ white:true*/
if (!this._unitIsFractional && Math.round(quantity) !== quantity) {
return XT.Error.clone('xt2014');
}
-
+
+ return XM.Document.prototype.validate.apply(this, arguments);
},
/** @private
@@ -28,10 +28,11 @@ white:true*/
path: 'http:'
},
- validateSave: function (attributes, options) {
+ validate: function (attributes, options) {
if (!this.validateUrl(attributes.path)) {
return XT.Error.clone('xt2009');
}
+ return XM.Document.prototype.validate.apply(this, arguments);
},
validateUrl: function (value) {
@@ -88,7 +88,7 @@ white:true*/
XM.Document.prototype.statusDidChange.apply(this, arguments);
},
- validateSave: function () {
+ validate: function () {
var models = this.get('options').models,
values = [],
i;
@@ -112,6 +112,8 @@ white:true*/
if (!_.isEqual(values, _.unique(values))) {
return XT.Error.clone('xt2003');
}
+
+ return XM.Document.prototype.validate.apply(this, arguments);
}
});
@@ -157,15 +157,6 @@ white:true*/
canDelete: function () {
return this.getClass().canDelete(this);
},
-
- /**
- Oveload: make sure `silent` changes never fire. Backbone .9.10 behaves
- this way anyway, so this should be removed at the next upgrade.
- */
- change: function () {
- this._silent = {};
- Backbone.RelationalModel.prototype.change.apply(this, arguments);
- },
/**
Returns only attribute records that have changed.
@@ -250,16 +241,6 @@ white:true*/
XT.log(resp);
},
- /**
- Return whether the model is in a valid state to `save`.
-
- @returns {Boolean}
- */
- isValid: function () {
- var options = {validateSave: true};
- return !this.validate || !this.validate(this.attributes, options);
- },
-
lockDidChange: function (model, lock) {
var that = this,
options = {};
@@ -1003,7 +984,6 @@ white:true*/
success = options.success;
options.wait = true;
options.cascade = true; // Cascade status to children
- options.validateSave = true;
options.success = function (resp) {
model.setStatus(K.READY_CLEAN, options);
if (XT.debugging) {
@@ -1194,36 +1174,21 @@ white:true*/
/**
Default validation checks `attributes` for:<br />
&#42; Data type integrity.<br />
- &#42; Required fields when `validateSave=true` option is passed.<br />
- &#42; Read Only and Privileges (when editing).<br />
+ &#42; Required fields.<br />
<br />
Returns `undefined` if the validation succeeded, or some value, usually
an error message, if it fails.<br />
<br />
- Use the `force` option to ignore validation. This is useful when
- higher level function calls passing through `set` need to skip
- validation to work properly.<br />
- <br />
- It is recommended customizations be implemented on `validateEdit` or
- `validateSave` to reduce risk of accidentally over-writing or losing
- logic included in the base validate function.
- @seealso `validateEdit`
- @seealso `validateSave`
@param {Object} Attributes
@param {Object} Options
*/
validate: function (attributes, options) {
attributes = attributes || {};
options = options || {};
- if (options.force || this.getStatus() === XM.Model.BUSY_FETCHING) {
- return;
- }
var that = this, i, result,
K = XM.Model,
S = XT.Session,
- keys = _.keys(attributes),
- original = _.pick(this.originalAttributes(), keys),
status = this.getStatus(),
attr, value, category, column, params = {},
type = this.recordType.replace(/\w+\./i, ''),
@@ -1330,55 +1295,15 @@ white:true*/
}
// Check required.
- if (options.validateSave) {
- for (i = 0; i < this.requiredAttributes.length; i += 1) {
- value = attributes[this.requiredAttributes[i]];
- if (value === undefined || value === null || value === "") {
- params.attr = ("_" + this.requiredAttributes[i]).loc();
- return XT.Error.clone('xt1004', { params: params });
- }
- }
- result = this.validateSave(attributes, options);
- if (result) { return result; }
- }
-
- // Check read only and privileges.
- if ((status & K.READY) && !_.isEqual(attributes, original)) {
-
- if (!this.canUpdate() && status !== K.READY_NEW) {
- return XT.Error.clone('xt1010');
+ for (i = 0; i < this.requiredAttributes.length; i += 1) {
+ value = attributes[this.requiredAttributes[i]];
+ if (value === undefined || value === null || value === "") {
+ params.attr = ("_" + this.requiredAttributes[i]).loc();
+ return XT.Error.clone('xt1004', { params: params });
}
}
- return this.validateEdit(attributes, options);
- },
-
- /**
- Called at the end of the `validate` function if the function has not
- returned a result for any other reason. This is the safest place to
- implement custom editing validation. The default implementation returns
- `undefined`.
-
- @seealso `validate`
- @param {Object} Attributes
- @param {Object} Options
- */
- validateEdit: function (attributes, options) {
- // Implement custom code here on your own class
- },
-
- /**
- Called by the `validate` function after checking required fields
- if the `validateSave=true` option was passed. Implement custom validation
- before committing to the server here. The default implementation
- returns `undefined`.
-
- @seealso `validate`
- @param {Object} Attributes
- @param {Object} Options
- */
- validateSave: function (attributes, options) {
- // Implement custom code here on your own class
+ return;
}

0 comments on commit edc40a0

Please sign in to comment.