Permalink
Browse files

resetando app para curso

  • Loading branch information...
1 parent fbf9ccc commit 6ecaf2f55f1b7141b844b2fe96ef0dd3e272d476 @cmilfont committed Jan 8, 2013
@@ -1,26 +0,0 @@
-Ext.onReady(function(){
-
- Ext.Ajax.extraParams = {
- authenticity_token : Ext.select("meta[name='csrf-token']").first().getAttribute('content')
- }
-
- // Ext.Ajax.on('requestexception', function (conn, response, options) {
- // if (response.status === 401 || response.status === 401) {
- // resp = JSON.parse(response.responseText)
- // Ext.Msg.alert('Erro', resp.message);
- // }
- // });
-
-});
-
-Ext.application({
- name: 'Workout',
- paths: {"Ext.ux":"/assets/ux"},
- requires: ['Ext.ux.RowExpander'],
- appFolder: '/assets',
- autoCreateViewport: true,
- controllers: ['Rotinas']
-});
-
-//Ext.Loader.setPath("Ext.ux", "/assets/ux");
-//Ext.require('Ext.ux.RowExpander');
@@ -1,22 +0,0 @@
-Ext.define('Workout.controller.Dashboard', {
- extend: 'Ext.app.Controller',
- init: function() {
- this.control({
- "button[itemId='treinos']": {
- click: {
- scope: this,
- fn: this.onTabAdd
- }
- }
- });
- },
-
- onTabAdd: function(button) {
- this.getTabPanel().addTab(button.text, button.viewModel);
- }
-
- , getTabPanel: function() {
- return Ext.ComponentQuery.query("tabpanel[itemId='tabs']")[0];
- }
-
-});
@@ -1,41 +0,0 @@
-Ext.define('Workout.controller.Rotinas', {
- extend: 'Ext.app.Controller',
- requires: ['Workout.store.Rotinas'],
- views: ['rotina.List', 'rotina.Form', 'exercicio.Form', 'exercicio.Combo'],
- models: ['Rotina', 'Item', 'Exercicio'],
- stores: ['Rotinas'],
- init: function() {
- this.control({
-
- //"button[itemId='rotinas']": {
- "#rotinas" : {
- click: {
- scope: this,
- fn: this.onTabAdd
- }
- },
-
- "rotinalist[itemId='tab-Rotinas']": {
- afterrender: function(view) {
- //view.store.load();
- //view.refresh();
- }
- }
- });
- },
-
- onTabAdd: function(button) {
- this.getTabPanel().addTab({
- title: button.text,
- itemId: "tab-" + button.text,
- closable: true,
- xtype: "rotinalist"
- });
- }
-
- , getTabPanel: function() {
- return Ext.ComponentQuery.query("tabpanel[itemId='tabs']")[0];
- }
-
-
-});
@@ -1,7 +0,0 @@
-Ext.define('Workout.model.Exercicio', {
- extend: 'Ext.data.Model',
- fields: ['id','titulo', 'descricao'],
- proxy: {
- type: 'rest', format: 'json', url: '/exercicios'
- }
-});
@@ -1,9 +0,0 @@
-Ext.define('Workout.model.Item', {
- extend: 'Ext.data.Model',
- fields: [
- 'id','repeticao', 'tempo', 'rotina_id', 'exercicio_id'
- ],
- belongsTo: [
- {model: 'Workout.model.Exercicio', associationKey: 'exercicio', getterName: 'exercicio'}
- ]
-});
@@ -1,21 +0,0 @@
-Ext.define('Workout.model.Rotina', {
- extend: 'Ext.data.Model',
- proxy: {
- type: 'rest', format: 'json', url: '/rotinas'
- },
- fields: ['titulo', {name:'id', mapping:'id'}],
- hasMany: [
- {model: 'Workout.model.Item', name: 'itens', associationKey: 'itens'}
- ]
-});
-
-Ext.define('Workout.model.RotinaTree', {
- extend: 'Ext.data.Model',
- proxy: {
- type: 'rest', format: 'json', url: '/rotinas'
- },
- fields: ['id', 'titulo', 'exercicio', 'repeticao', 'tempo'],
- hasMany: [
- {model: 'Workout.model.Item', name: 'itens', associationKey: 'itens'}
- ]
-});
@@ -1,35 +0,0 @@
-Ext.define('Workout.store.Rotinas', {
- alias: 'store.rotinas',
- extend: 'Ext.data.TreeStore',
- model: "Workout.model.RotinaTree",
- root: "Workout.model.Rotina",
- constructor: function() {
- this.callParent(arguments);
- this.on({
- beforeappend: this.transformarFolha,
- append: this.adicionarItensExpandindo,
- scope: this
- });
- },
- transformarFolha: function(root, node){
- if( node.itens().count() == 0 && node.get("id")) node.set("leaf", true);
- },
- adicionarItensExpandindo: function(root, node){
- if( node.itens().count() > 0 ){
- node.itens().each( this.adicionarItem, node);
- node.expand();
- }
- },
- adicionarItem: function(item){
-
- console.log(item);
-
- this.appendChild({
- leaf: true,
- item: item,
- exercicio: item.exercicio().get("titulo"),
- repeticao: item.get("repeticao"),
- tempo: item.get("tempo")
- });
- }
-});
@@ -1,21 +0,0 @@
-Ext.define('Workout.view.DashboardTabPanel', {
- alias: 'widget.dtabpanel',
- extend: 'Ext.tab.Panel',
- itemId: "tabs",
- frame: true,
- style: {
- backgroundColor: "#3C8FC0"
- },
- activeTab: 0,
- items: [{
- title: 'Dashboard',
- xtype: "panel",
- html: 'Dashboard com os dados do usuaário'
- }],
-
- addTab: function(panel) {
- var tab = this.down("[itemId='tab-" + panel.title + "']");
- if(!tab) tab = this.add(panel);
- this.setActiveTab(tab);
- }
-});
@@ -1,23 +0,0 @@
-Ext.define('Workout.view.DashboardToolbar', {
- alias: 'widget.dtoolbar',
- extend: 'Ext.toolbar.Toolbar',
- style: {
- backgroundColor: "#3C8FC0"
- },
- items: [
- { xtype: 'tbtext', text: 'Workout', cls: 'home_title' },
- '->',
- { xtype: 'button', overCls: 'home_menu_over', cls: 'home_menu', pressedCls: "home_pressed", text: 'Rotinas', itemId: 'rotinas'},
- { xtype: 'button', overCls: 'home_menu_over', cls: 'home_menu', pressedCls: "home_pressed", text: 'Treinos', itemId: 'treinos'},
- {
- xtype: 'splitbutton', overCls: 'home_split_over', cls: 'home_split', text : 'Perfil',
- menu: {
- items: [
- {text: 'Item 1', handler: function(){ alert("Item 1 clicked"); }},
- {text: 'Item 2', handler: function(){ alert("Item 2 clicked"); }}
- ]
- }
- },
- { xtype: 'tbspacer', width: 50 }
- ]
-});
@@ -1,12 +0,0 @@
-Ext.define('Workout.view.Viewport', {
- extend: 'Ext.container.Viewport',
- layout: 'border',
- requires: ['Workout.view.DashboardTabPanel', 'Workout.view.DashboardToolbar'],
- style: {
- backgroundColor: "#3C8FC0"
- },
- items: [
- { region: 'north', xtype: 'dtoolbar' },
- { region: 'center', xtype: 'dtabpanel' }
- ]
-});
@@ -1,31 +0,0 @@
-Ext.define("Workout.view.exercicio.Combo", {
- extend: 'Ext.form.field.ComboBox',
- alias: ["widget.exerciciocombo"],
- name: "exercicio_id",
- displayField: 'titulo',
- valueField: 'id',
- fieldLabel: 'Exercício',
- store: { model: "Workout.model.Exercicio" },
- template: '<div>{titulo} - <a data-id="{id}">editar</a> </div>',
- setupListConfig: function() {
- var combo = this;
- return {
- getInnerTpl: function() {
- return combo.template;
- },
- listeners: {
- el: {
- click: function(evento, el) {
- var id = evento.getTarget().getAttribute("data-id");
- console.log("Id dele: ", id);
- return false;
- }
- }
- }
- };
- },
- initComponent: function() {
- this.listConfig = this.setupListConfig();
- this.callParent();
- },
-});
@@ -1,24 +0,0 @@
-Ext.define('Workout.view.exercicio.Form', {
- extend: 'Ext.form.Panel',
- alias: 'widget.exercicioform',
- formBind: true,
- salvarCallback: Ext.emptyFn,
- scopeSalvarCallback: null,
- model: null,
- constructor: function(config) {
- this.callParent(arguments);
- if(config.model) this.getForm().loadRecord(config.model);
- },
- items: [
- {xtype: "hiddenfield", name: "id"},
- {xtype: "exerciciocombo"}
- ],
- buttons: [{ text: "Salvar", formBind:true, handler: function(){
- var panel = this.up("form");
- var form = panel.getForm();
- if( form.isValid() ) {
- panel.salvarCallback.call( panel.scopeSalvarCallback, form.getValues() );
- }
- }}]
-
-});
@@ -1,10 +0,0 @@
-Ext.define("Workout.view.rotina.Exercicio", {
- vincular: function() {
-
- Ext.create("Ext.window.Window", {
- items: [{
- xtype: "exercicioform", width: 400
- }]
- }).show()
- }
-});
@@ -1,23 +0,0 @@
-Ext.define('Workout.view.rotina.Form', {
- extend: 'Ext.form.Panel',
- alias: 'widget.rotinaform',
- formBind: true,
- salvarCallback: Ext.emptyFn,
- scopeSalvarCallback: null,
- model: null,
- constructor: function(config) {
- this.callParent(arguments);
- if(config.model) this.getForm().loadRecord(config.model);
- },
- items: [
- {xtype: "hiddenfield", name: "id"},
- {name: "titulo", xtype: "textfield", fieldLabel: "Titulo", allowBlank: false, margin: 5 }
- ],
- buttons: [{ text: "Salvar", formBind:true, handler: function(){
- var panel = this.up("form");
- var form = panel.getForm();
- if( form.isValid() ) {
- panel.salvarCallback.call( panel.scopeSalvarCallback, form.getValues() );
- }
- }}]
-});
@@ -1,57 +0,0 @@
-Ext.define('Workout.view.rotina.List', {
- extend: 'Ext.tree.Panel',
- alias: 'widget.rotinalist',
- mixins: {
- 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: 'Repetições', sortable: false, flex: 2, dataIndex: 'repeticao' },
- { text: 'Tempo', sortable: false, flex: 2, dataIndex: 'tempo' }
- ],
- selModel: { allowDeselect: true },
- singleExpand: true,
- rootVisible: false,
- constructor: function() {
- var buttonConfig = { xtype: 'button', pressed: true, scope: this };
- this.tbar = [
- 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);
- this.on({
- select: this.habilitarAoSelecionar,
- deselect: this.desabilitarAoSelecionar,
- scope: this
- });
- },
-
- desabilitarAoSelecionar: function(rowModel, model, index, eOpts) {
- this.down("#editar").disable();
- this.down("#excluir").disable();
-
- var vincular = this.down("#vincular"),
- editarexercicio = this.down("#editarexercicio"),
- desvincular = this.down("#desvincular");
- if(vincular) vincular.destroy();
- if(editarexercicio) editarexercicio.destroy();
- if(desvincular) desvincular.destroy();
- },
- habilitarAoSelecionar: function(rowModel, model, index, eOpts) {
- var docked = this.getDockedItems()[0];
- if(!model.raw.item) {
- this.down("#editar").enable();
- this.down("#excluir").enable();
- 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" })
- }
- }
-});
Oops, something went wrong.

0 comments on commit 6ecaf2f

Please sign in to comment.