PDA

View Full Version : [INFOREQ] Extending a model ignores the proxy



gbjk
22 Aug 2011, 7:30 AM
I'm using Sencha Touch 1.1.0.

If you extend a model, then the code in ModelMgr.registerType ignores the proxy you've supplied in config, and imposes the one from the model you're extending.

I expected extend to allow me to extend the model, including the proxy.

The proxy includes the url, and so it's pretty fundamental to be able to override it.

Thanks

Gareth

mike.estes
22 Aug 2011, 9:07 AM
Please fill out the template (http://www.sencha.com/forum/showthread.php?104623-Posting-to-the-bug-forum) and provide a test case, it helps us process these reports efficiently.

gbjk
23 Aug 2011, 4:01 AM
Sencha Touch version tested:

1.1.0
Platform tested against:

Ubuntu/Google Chrome
Description:

Extending a model ignores any proxy defined, and forces inheritance of the proxy from the extended model
Test Case:



webxg_mobile.models.Vehicle = Ext.regModel('Vehicle', {
fields: [
{name: 'license_no', type: 'string'},
],
proxy: {
type: 'webxg',
url: 'vehicle/',
},
extend: 'webxg',
});


Steps to reproduce the problem:

Define a model
extend that model in a new defined model
The result that was expected:

Proxy should be respected
The result that occurs instead:

extended model's proxy overrode it
Possible fix:

--- ./src/platform/src/data/ModelMgr.bak 2011-08-23 12:53:58.078922040 +0100
+++ ./src/platform/src/data/ModelMgr.js 2011-08-23 12:55:20.958863037 +0100
@@ -93,7 +93,11 @@
extendModelProto = extendModel.prototype;
extendValidations = extendModelProto.validations;

- proxy = extendModel.proxy;
+ // Ideally merge the proxy parameters together, but at least respect the sub-item
+ if (!config.proxy){
+ proxy = extendModel.proxy;
+ }
+ else {
+ proxy = config.proxy;
+ }
+
fields = extendModelProto.fields.items.concat(fields);
associations = extendModelProto.associations.items.concat(associations);
config.validations = extendValidations ? extendValidations.concat(config.validations) : config.validations;