PDA

View Full Version : Design View and Viewmode Links: Invalid Model name



EricRicher
10 Nov 2017, 8:10 AM
I define a model, view and a viewModel as follow using Architect:


Ext.define('MyApp.view.FormPanel', {
extend: 'Ext.form.Panel',
alias: 'widget.formpanel',


requires: [
'MyApp.view.FormPanelViewModel'
],


viewModel: {
type: 'formpanel'
},
title: 'My Form'


});

Ext.define('MyApp.view.FormPanelViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.formpanel',


links: {
theUser: {
type: 'User',
create: true
}
}


});

Ext.define('MyApp.model.User', {
extend: 'Ext.data.Model',
alias: 'model.user',

requires: [
'Ext.data.field.Field'
],




fields: [
{
name: 'firstname'
},
{
name: 'lastname'
}
]


});


Every time I go to Design View to look at the form, I get the following error in the log:

57186

I tried setting type to 'MyApp.model.User' , 'model.User' or simply 'user' in the links config and I get the same error.

Any ideas what I am doing wrong or is this a bug?

EricRicher
16 Nov 2017, 10:44 AM
Not gathering a lot of replies to my question...

Was hoping someone from Sencha would pick it up to see if this is an issue, so I will post it in the bugs forum.

But to add to this, Architect cannot render a view that has Links in the ViewModel. This is annoying to me right now as I am using links in many forms and views to download/upload server data. None of them are showing up in the Design view which sorts of defeats the purpose of using Architect as a visual desing tool.

However, even if Architect has a issue dealing with links config in viewmodels, the code works perfectly fine and as expected.

Here's an archive of a small test project to show this problem. The project is using the modern toolkit.

https://www.dropbox.com/s/fv8vyt5e10w1gyl/LinksTest.xda?dl=0

(Could not figure out how to upload a xda file on the forum although it is supposed to be allowed...)

bogc
29 Nov 2017, 6:25 PM
I just want to confirm that I see the same error. I specified the full name of the model, and it doesn't make any difference. The form is not rendered anymore in SA which is very annoying.

Another way to do it is to simply add the record (theUser) to the data property (data: {theUser: null}) and create the User model in the override for the ViewModel - you'd have to select the ViewModel and click the CreateOverride button:



constructor: function() {
var me = this;
me.callParent(arguments);
me.data.theUser = Ext.create('MyApp.model.User');
// debugger;
},

evgeniybal
19 Mar 2018, 10:23 PM
My solution:
1. Add function initComponent (component template method)
2. Create link from code

this.callParent(arguments);


var user = {
type: 'MyApp.model.User',
create: {
firstName: 'John',
lastName: 'Smith'
}};


var vm = this.getViewModel();
vm.linkTo('newUser', user);