diff --git a/app/components/bike_logs_and_tasks_accordian.rb b/app/components/bike_logs_and_tasks_accordian.rb new file mode 100644 index 0000000..2a4d98c --- /dev/null +++ b/app/components/bike_logs_and_tasks_accordian.rb @@ -0,0 +1,10 @@ +class BikeLogsAndTasksAccordian < Netzke::Basepack::Accordion + component :bike_logs + component :tasks + + def configure(c) + c.prevent_header = true + c.items = [ :bike_logs, :tasks ] + super + end +end diff --git a/app/components/bikes_border.rb b/app/components/bikes_border.rb index ab626da..89c1b68 100644 --- a/app/components/bikes_border.rb +++ b/app/components/bikes_border.rb @@ -2,7 +2,7 @@ class BikesBorder < Netzke::Base # Remember regions collapse state and size include Netzke::Basepack::ItemPersistence component :bikes - component :bike_logs + component :bike_logs_and_tasks_accordian def configure(c) super @@ -10,7 +10,7 @@ class BikesBorder < Netzke::Base c.title = "Bikes" c.items = [ { netzke_component: :bikes, region: :center, split: true }, - { netzke_component: :bike_logs, region: :south, height: 300, split: true} + { netzke_component: :bike_logs_and_tasks_accordian, region: :south, height: 300, split: true} ] end diff --git a/app/components/bikes_border/javascripts/init_component.js b/app/components/bikes_border/javascripts/init_component.js index 8637e43..2054a6e 100644 --- a/app/components/bikes_border/javascripts/init_component.js +++ b/app/components/bikes_border/javascripts/init_component.js @@ -8,7 +8,12 @@ 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')}); - this.getComponent('bike_logs').getStore().load(); + if( this.queryById('bike_logs') ){ + this.queryById('bike_logs').getStore().load(); + } + if( this.queryById('tasks') ){ + this.queryById('tasks').getStore().load(); + } }, this); } } diff --git a/app/components/tasks.rb b/app/components/tasks.rb new file mode 100644 index 0000000..84e4a10 --- /dev/null +++ b/app/components/tasks.rb @@ -0,0 +1,19 @@ +class Tasks < Netzke::Basepack::Grid + def configure(c) + super + c.model = "Task" + c.scope = lambda{ |rel| + if session[:selected_bike_id] + rel.where(:task_list_id => Bike.find_by_id(session[:selected_bike_id]).task_list.id) + else + #show nothing, whatever this works + rel.where(:task_list_id => 0) + end + } + end + + #override with nil to remove actions + def default_bbar + [ :apply, :add_in_form] + end +end diff --git a/app/components/user_profile_border/javascripts/init_component.js b/app/components/user_profile_border/javascripts/init_component.js index c5a338b..10faa94 100644 --- a/app/components/user_profile_border/javascripts/init_component.js +++ b/app/components/user_profile_border/javascripts/init_component.js @@ -6,7 +6,6 @@ var store = this.getComponent('user_logs').getStore() store.on('load', function (store, records, operation, success){ - console.log("Bitches"); this.getComponent('user_stats').updateStats(); }, this); }