Browse Source

Altered Bikes view to show a bike's task list.

Need to create a default task list for all bikes.
denney-disable-on-select
Jason Denney 12 years ago
parent
commit
cd65e34ae1
  1. 10
      app/components/bike_logs_and_tasks_accordian.rb
  2. 4
      app/components/bikes_border.rb
  3. 7
      app/components/bikes_border/javascripts/init_component.js
  4. 19
      app/components/tasks.rb
  5. 1
      app/components/user_profile_border/javascripts/init_component.js

10
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

4
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

7
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);
}
}

19
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

1
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);
}

Loading…
Cancel
Save