I had a likelly context and make a extends class to Ext.controller.Controller on controller directory like as:
Code:
Ext.define('TecFoodApp.controller.Controller', { extend: 'Ext.app.Controller', activeDataStore: null, backView: null, slideLeftTransition: { type: "slide", direction: "left" }, slideRightTransition: { type: 'slide', direction: 'right' }, onBackToCommand:function(view){ Ext.Viewport.setActiveItem(view); Ext.Viewport.animateActiveItem(view, this.SlideRightTransition); }, onSaveCommand: function (form) { var record = form.getRecord(); var values = form.getValues(); if (values.id > 0){ record.set(values); } else{ record = this.activeDataStore.getModel(); record.set(values); this.activeDataStore.add(record); novo = true; } this.activeDataStore.sync(); if (novo){ //faz reload para atualziar this.activeDataStore.load(); } this.onBackToCommand(this.backView); }, onSetActiveDataStore:function(cmp){ this.activeDataStore = cmp.getStore(); console.log("activeDataStore => " + this.activeDataStore.getStoreId()); }, onSetBackView:function(cmp){ this.backView = cmp.getId(); console.log("backView => " + this.backView); }})
This class add a new method onBackToCommand wich opens a view passed as argument. note, backView property defined by me on this class.
The views can now call the backtoview passing theirs name that maybe another extension on views that is a new challenge becouse view are a lot of components.
to use my personalized controller may be like:
Code:
Ext.define('TecFoodApp.controller.OperadorController', {
extend: 'TecFoodApp.controller.Controller', stores:["Operadores","Processos"], models:["Operador"], config: { refs: { operadorListarView: "operadorlistarview", operadorCadastrarView: "operadorcadastrarview" }, control: { operadorListarView: { scope: this, backToCommand: "onBackToCommand", itemtap: "onItemTapCommand", setActiveDataStore:"onSetActiveDataStore", setBackView: "onSetBackView" }, operadorCadastrarView: { scope:this, backToCommand: "onBackToCommand", saveCommand: "onSaveCommand" } } },....dropped.....
worth considering the example my little experience in frame, I'm learning some things from architecture to develop something more solid.