I am still learning Extjs and mvc so I have a design question that I am sure someone can answer for me. My question is:
I have 2 controllers that handle two different views. Either of the two controllers are called to render the correct view based on the type of user. So in my case if the user is admin then they will get the admin view based on credentials and if the person a standard user then they will get the standard view. Should the decision logic be placed in the app.js or should there be another controller that decides which controller to call?
One way I am thinking about:
controller for admin
Ext.define('adminController', {
// handles admin
})
controller for standard user
Ext.define('standardController', {
// handles standard
})
App.js
Ext.application({
name: 'MTK',
autoCreateViewport: true,
if(admin) {
controllers: ['adminController']
}
else(std){
controllers: ['standardController']
}
});
Another idea:
controller for admin
Ext.define('adminController', {
// handles admin
})
controller for standard user
Ext.define('standardController', {
// handles standard
})
main controller
Ext.define('mainController', {
if(admin){
call adminController
}
else(std){
call standardController
}
})
I wouldn’t do (or at least too much of it) this in the frontend. I guess you should be able to know the user role the time the user is logging in so.
For me I do it this way, but I must say I have a much more complex ACL and I won’t bother a user with modules or views where the backend will refuse any access to.
I am using these two approaches:
Both approaches result in less code, faster loading’s and easier debugging
I hope this points you in the right direction.