From 4a67ebe77e1b5becd3b2d8ba099ab6031c160dff Mon Sep 17 00:00:00 2001 From: Jason Denney Date: Sun, 3 Nov 2013 11:34:48 -0500 Subject: [PATCH] Disable sub panels until item clicked --- .../javascripts/init_component.js | 24 +++++++++++++++---- .../customers/javascripts/init_component.js | 1 - app/components/tasks.rb | 2 ++ .../javascripts/init_component.js | 9 +++++++ .../javascripts/init_component.js | 8 +++++++ .../javascripts/init_component.js | 14 ++++++++++- 6 files changed, 52 insertions(+), 6 deletions(-) diff --git a/app/components/bikes_border/javascripts/init_component.js b/app/components/bikes_border/javascripts/init_component.js index 2054a6e..788f62a 100644 --- a/app/components/bikes_border/javascripts/init_component.js +++ b/app/components/bikes_border/javascripts/init_component.js @@ -5,14 +5,30 @@ // setting the 'rowclick' event var view = this.getComponent('bikes').getView(); + + //disable until a bike is clicked + var bike_logs_comp = this.queryById('bike_logs'); + if( bike_logs_comp){ + bike_logs_comp.disable(); + } + var bike_tasks_comp = this.queryById('tasks'); + if( bike_tasks_comp ){ + bike_tasks_comp.disable(); + } + view.on('itemclick', function(view, record){ // The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server! this.selectBike({bike_id: record.get('id')}); - if( this.queryById('bike_logs') ){ - this.queryById('bike_logs').getStore().load(); + // query for these components again, can change if not visible because of accordian + var bike_logs_comp = this.queryById('bike_logs'); + var bike_tasks_comp = this.queryById('tasks'); + if( bike_logs_comp ){ + bike_logs_comp.getStore().load(); + bike_logs_comp.enable(); } - if( this.queryById('tasks') ){ - this.queryById('tasks').getStore().load(); + if( bike_tasks_comp ){ + bike_tasks_comp.getStore().load(); + bike_tasks_comp.enable(); } }, this); } diff --git a/app/components/customers/javascripts/init_component.js b/app/components/customers/javascripts/init_component.js index 29aa00c..cd36027 100644 --- a/app/components/customers/javascripts/init_component.js +++ b/app/components/customers/javascripts/init_component.js @@ -4,7 +4,6 @@ this.callParent(); this.getView().on('itemclick', function(view, record){ // The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server! - console.log("user: " + record.get('id') ); this.selectCustomer({customer_id: record.get('id'), customer_type: 'Customer'}); }, this); } diff --git a/app/components/tasks.rb b/app/components/tasks.rb index 917e44b..aa9b684 100644 --- a/app/components/tasks.rb +++ b/app/components/tasks.rb @@ -2,6 +2,8 @@ class Tasks < Netzke::Basepack::Grid def configure(c) super + #disable by default, will be enabled once bike is clicked + c.disabled = true task_list_id = nil if session[:selected_bike_id] task_list_id = Bike.find_by_id(session[:selected_bike_id]).task_list.id diff --git a/app/components/transactions_border/javascripts/init_component.js b/app/components/transactions_border/javascripts/init_component.js index 5d41919..41c8c3f 100644 --- a/app/components/transactions_border/javascripts/init_component.js +++ b/app/components/transactions_border/javascripts/init_component.js @@ -5,10 +5,19 @@ // setting the 'rowclick' event var view = this.getComponent('transactions').getView(); + + if( this.queryById('transaction_logs')){ + this.queryById('transaction_logs').disable(); + } + view.on('itemclick', function(view, record){ // The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server! this.selectTransaction({transaction_id: record.get('id')}); this.getComponent('transaction_logs').getStore().load(); + + if( this.queryById('transaction_logs')){ + this.queryById('transaction_logs').enable(); + } }, this); } } diff --git a/app/components/user_transactions_border/javascripts/init_component.js b/app/components/user_transactions_border/javascripts/init_component.js index 8266a14..0a82e05 100644 --- a/app/components/user_transactions_border/javascripts/init_component.js +++ b/app/components/user_transactions_border/javascripts/init_component.js @@ -5,10 +5,18 @@ // setting the 'rowclick' event var view = this.getComponent('user_transactions').getView(); + + if( this.queryById('transaction_logs')){ + this.queryById('transaction_logs').disable(); + } view.on('itemclick', function(view, record){ // The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server! this.selectTransaction({transaction_id: record.get('id')}); this.getComponent('transaction_logs').getStore().load(); + + if( this.queryById('transaction_logs')){ + this.queryById('transaction_logs').enable(); + } }, this); } } diff --git a/app/components/users_and_profiles_border/javascripts/init_component.js b/app/components/users_and_profiles_border/javascripts/init_component.js index 616de1f..d010668 100644 --- a/app/components/users_and_profiles_border/javascripts/init_component.js +++ b/app/components/users_and_profiles_border/javascripts/init_component.js @@ -6,7 +6,12 @@ if (stats != undefined){ stats.updateStats(); } - + if( this.queryById('user_profiles')){ + this.queryById('user_profiles').disable(); + } + if( this.queryById('user_logs')){ + this.queryById('user_logs').disable(); + } // setting the 'rowclick' event var view = this.getComponent('users').getView(); view.on('itemclick', function(view, record){ @@ -14,6 +19,13 @@ this.selectUser({user_id: record.get('id')}); this.getComponent('user_profiles').getStore().load(); this.getComponent('user_logs').getStore().load(); + + if( this.queryById('user_profiles')){ + this.queryById('user_profiles').enable(); + } + if( this.queryById('user_logs')){ + this.queryById('user_logs').enable(); + } }, this); } }