I'd like to subclass a model that I've created using Sencha Architect. Say I have a model called BaseModel that I've already created, and I need to create another model, call it MyModel, which extends BaseModel. In code, it would look something like this:
// BaseModel.js
Ext.define('MyApp.model.BaseModel', {
extend: 'Ext.data.Model',
fields: [...]
});
and
// MyModel.js
Ext.define('MyApp.model.MyModel', {
extend: 'MyApp.model.BaseModel',
fields: [...]
});
I'm new to ExtJS and Sencha Architect but this is something that's so simple to do in code and so important to proper software design that I imagine there must be a way to do this in Architect. Unfortunately I couldn't figure out how to do this easily. After some digging I found this in the Sencha docs, http://docs.sencha.com/architect/2/#!/guide/classes, which states the following under the heading "Custom Classes":
While the features described here enable the creation of classes from the supported items in the Toolbox, sometimes you may need to create a plain parentless class or a class that extends another class that does not appear in the Toolbox. You can do this in Architect by using the Class item in the Toolbox.
Okay, sounds promising — so I tried that. In the project inspector I hit the plus sign, went to "Class", and within that hit "Model". So now I have a custom Model class in my project. I call it MyModel
and I set the "extend" config to be MyApp.model.BaseModel
. So now at least the code is correct and looks like what I have above. However, Architect seems to have no idea that the MyModel
class is a model, even though it's sitting in the "Model" section of my Project Inspector and extends BaseModel
. It doesn't have any of the Model config properties like "fields" that I need to specify, and I can't associate MyModel
with any kind of Store. In other words, Architect treats MyModel
as a completely custom class and doesn't expose any Model behavior. That basically makes this way of subclassing completely useless — I can subclass a Model but then I can't use it as a model anywhere in my project, so what's the point?
So the question is how do I get Architect to treat MyModel
as an actual model? Is this not the correct way to subclass in Architect? I'm just starting my project but I foresee needing to subclass very often, whether it's models, controllers, stores, etc. and if I can't do this with Architect it's a severe limitation.