1
0
mirror of https://github.com/fspc/BikeShed-1.git synced 2025-02-28 08:43:23 -05:00

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

Need to create a default task list for all bikes.
This commit is contained in:
Jason Denney 2013-02-09 10:00:46 -05:00
parent 545c33b953
commit cd65e34ae1
5 changed files with 37 additions and 4 deletions

View File

@ -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

View File

@ -2,7 +2,7 @@ class BikesBorder < Netzke::Base
# Remember regions collapse state and size # Remember regions collapse state and size
include Netzke::Basepack::ItemPersistence include Netzke::Basepack::ItemPersistence
component :bikes component :bikes
component :bike_logs component :bike_logs_and_tasks_accordian
def configure(c) def configure(c)
super super
@ -10,7 +10,7 @@ class BikesBorder < Netzke::Base
c.title = "Bikes" c.title = "Bikes"
c.items = [ c.items = [
{ netzke_component: :bikes, region: :center, split: true }, { 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 end

View File

@ -8,7 +8,12 @@
view.on('itemclick', function(view, record){ 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! // 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.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); }, this);
} }
} }

19
app/components/tasks.rb Normal file
View File

@ -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

View File

@ -6,7 +6,6 @@
var store = this.getComponent('user_logs').getStore() var store = this.getComponent('user_logs').getStore()
store.on('load', function (store, records, operation, success){ store.on('load', function (store, records, operation, success){
console.log("Bitches");
this.getComponent('user_stats').updateStats(); this.getComponent('user_stats').updateStats();
}, this); }, this);
} }