Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

material da ultima aula

  • Loading branch information...
commit fbf9ccc154e70b3543cde50281aede3f220e1245 1 parent 1afcc96
@cmilfont authored
View
4 app/assets/javascripts/model/Rotina.js
@@ -3,7 +3,7 @@ Ext.define('Workout.model.Rotina', {
proxy: {
type: 'rest', format: 'json', url: '/rotinas'
},
- fields: ['titulo', 'exercicio', {name:'id', mapping:'id'}],
+ fields: ['titulo', {name:'id', mapping:'id'}],
hasMany: [
{model: 'Workout.model.Item', name: 'itens', associationKey: 'itens'}
]
@@ -14,7 +14,7 @@ Ext.define('Workout.model.RotinaTree', {
proxy: {
type: 'rest', format: 'json', url: '/rotinas'
},
- fields: ['id', 'titulo', 'exercicio'],
+ fields: ['id', 'titulo', 'exercicio', 'repeticao', 'tempo'],
hasMany: [
{model: 'Workout.model.Item', name: 'itens', associationKey: 'itens'}
]
View
11 app/assets/javascripts/store/Rotinas.js
@@ -17,14 +17,19 @@ Ext.define('Workout.store.Rotinas', {
adicionarItensExpandindo: function(root, node){
if( node.itens().count() > 0 ){
node.itens().each( this.adicionarItem, node);
- node.expand()
+ node.expand();
}
},
adicionarItem: function(item){
+
+ console.log(item);
+
this.appendChild({
leaf: true,
item: item,
- exercicio: item.exercicio().get("titulo")
- })
+ exercicio: item.exercicio().get("titulo"),
+ repeticao: item.get("repeticao"),
+ tempo: item.get("tempo")
+ });
}
});
View
10 app/assets/javascripts/view/rotina/Exercicio.js
@@ -0,0 +1,10 @@
+Ext.define("Workout.view.rotina.Exercicio", {
+ vincular: function() {
+
+ Ext.create("Ext.window.Window", {
+ items: [{
+ xtype: "exercicioform", width: 400
+ }]
+ }).show()
+ }
+});
View
79 app/assets/javascripts/view/rotina/List.js
@@ -2,24 +2,26 @@ Ext.define('Workout.view.rotina.List', {
extend: 'Ext.tree.Panel',
alias: 'widget.rotinalist',
mixins: {
- vincular: "Workout.view.rotina.Vincular"
+ exercicio: "Workout.view.rotina.Exercicio",
+ rotina: "Workout.view.rotina.Rotina"
},
store: Ext.createByAlias("store.rotinas"),
columns: [
{ text: "", dataIndex: "id", xtype: "treecolumn" },
{ text: 'Rotina', sortable: false, flex: 2, dataIndex: 'titulo'},
- { text: 'Exercicio', sortable: false, flex: 2, dataIndex: 'exercicio' }
+ { text: 'Exercicio', sortable: false, flex: 2, dataIndex: 'exercicio' },
+ { text: 'Repetições', sortable: false, flex: 2, dataIndex: 'repeticao' },
+ { text: 'Tempo', sortable: false, flex: 2, dataIndex: 'tempo' }
],
- selModel: {
- allowDeselect: true
- },
+ selModel: { allowDeselect: true },
singleExpand: true,
rootVisible: false,
constructor: function() {
+ var buttonConfig = { xtype: 'button', pressed: true, scope: this };
this.tbar = [
- { xtype: 'button', text: 'Cadastrar' , pressed: true, handler: this.abrirJanela, scope: this},
- { xtype: 'button', text: 'Editar', itemId: 'editar', disabled: true, pressed: true, handler: this.abrirJanela, scope: this },
- { xtype: 'button', text: 'Excluir', itemId: 'excluir', disabled: true, pressed: true, handler: this.excluir, scope: this },
+ Ext.apply({ text: 'Cadastrar', handler: this.abrirJanela}, buttonConfig) ,
+ Ext.apply({ text: 'Editar', handler: this.abrirJanela, itemId: 'editar', disabled: true }, buttonConfig),
+ Ext.apply({ text: 'Excluir', handler: this.excluir, itemId: 'excluir', disabled: true }, buttonConfig),
"-"
];
this.callParent(arguments);
@@ -29,64 +31,7 @@ Ext.define('Workout.view.rotina.List', {
scope: this
});
},
- excluir: function() {
- Ext.Msg.show({
- title:'Excluir Rotina',
- msg: 'Deseja realmente excluir essa rotina de treinos?',
- buttons: Ext.Msg.YESNO,
- scope: this,
- fn: function(btn){
- if(btn == "yes")
- this.getSelectionModel().getLastSelected().destroy();
- }
- });
- },
-
- criarJanela: function(config) {
- return Ext.create("Ext.window.Window", config);
- },
-
- abrirJanela: function(button) {
- var model = null;
- if(button.text != "Cadastrar") model = this.getSelectionModel().getLastSelected();
- this.currentWindow = this.criarJanela({
- title: "Criar/Editar Rotina",
- items: [{
- xtype: "rotinaform",
- salvarCallback: this.adicionar,
- scopeSalvarCallback: this,
- model: model
- }]
- });
- this.currentWindow.show();
- },
- adicionar: function(json) {
- var model = this.getStore().getNodeById( json.id ),
- params = { scope: this, callback: this.adicionarRotinaNaTree};
- if( !model ) {
- model = Ext.create('Workout.model.Rotina', json);
- } else {
- model.set("titulo", json.titulo);
- params.callback = this.fecharESelecionar;
- }
- model.save( params );
- },
-
- adicionarRotinaNaTree: function(model) {
- var model = this.getRootNode().appendChild({
- leaf: true,
- id: model.getId(),
- titulo: model.get("titulo")
- });
- this.fecharESelecionar(model);
- },
-
- fecharESelecionar : function(model) {
- this.getSelectionModel().deselectAll()
- this.currentWindow.close();
- this.getSelectionModel().select( model );
- },
-
+
desabilitarAoSelecionar: function(rowModel, model, index, eOpts) {
this.down("#editar").disable();
this.down("#excluir").disable();
@@ -103,7 +48,7 @@ Ext.define('Workout.view.rotina.List', {
if(!model.raw.item) {
this.down("#editar").enable();
this.down("#excluir").enable();
- docked.add({ text: "Vincular Exercicio", scope: this, handler: this.vincularExercicio, pressed: true, itemId: "vincular" })
+ docked.add({ text: "Vincular Exercicio", scope: this, handler: this.vincular, pressed: true, itemId: "vincular" })
} else {
docked.add({ text: "Editar Exercicio", handler: function(){}, pressed: true, itemId: "editarexercicio" })
docked.add({ text: "Desvincular Exercicio", handler: function(){}, pressed: true, itemId: "desvincular" })
View
62 app/assets/javascripts/view/rotina/Rotina.js
@@ -0,0 +1,62 @@
+Ext.define("Workout.view.rotina.Rotina", {
+
+ excluir: function() {
+ Ext.Msg.show({
+ title:'Excluir Rotina',
+ msg: 'Deseja realmente excluir essa rotina de treinos?',
+ buttons: Ext.Msg.YESNO,
+ scope: this,
+ fn: function(btn){
+ if(btn == "yes")
+ this.getSelectionModel().getLastSelected().destroy();
+ }
+ });
+ },
+
+ criarJanela: function(config) {
+ return Ext.create("Ext.window.Window", config);
+ },
+
+ abrirJanela: function(button) {
+ var model = null;
+ if(button.text != "Cadastrar") model = this.getSelectionModel().getLastSelected();
+ this.currentWindow = this.criarJanela({
+ title: "Criar/Editar Rotina",
+ items: [{
+ xtype: "rotinaform",
+ salvarCallback: this.adicionar,
+ scopeSalvarCallback: this,
+ model: model
+ }]
+ });
+ this.currentWindow.show();
+ },
+ adicionar: function(json) {
+ var model = this.getStore().getNodeById( json.id ),
+ params = { scope: this, callback: this.adicionarRotinaNaTree};
+ if( !model ) {
+ model = Ext.create('Workout.model.Rotina', json);
+ } else {
+ model.set("titulo", json.titulo);
+ params.callback = this.fecharESelecionar;
+ }
+ model.save( params );
+ },
+
+ adicionarRotinaNaTree: function(model) {
+ var model = this.getRootNode().appendChild({
+ leaf: true,
+ id: model.getId(),
+ titulo: model.get("titulo")
+ });
+ this.fecharESelecionar(model);
+ },
+
+ fecharESelecionar : function(model) {
+ this.getSelectionModel().deselectAll()
+ this.currentWindow.close();
+ this.getSelectionModel().select( model );
+ }
+
+
+});
View
13 app/assets/javascripts/view/rotina/Vincular.js
@@ -1,13 +0,0 @@
-Ext.define("Workout.view.rotina.Vincular", {
- vincularExercicio: function() {
- var tree = this;
-
- console.log("Arvore?", this);
-
- Ext.create("Ext.window.Window", {
- items: [{
- xtype: "exercicioform", width: 400
- }]
- }).show()
- }
-});
Please sign in to comment.
Something went wrong with that request. Please try again.