| Class | Admin::CategoriesController |
| In: |
app/controllers/admin/categories_controller.rb
|
| Parent: | Admin::AdminController |
Manage Asssociation and BAR categories
Add category as child
# File app/controllers/admin/categories_controller.rb, line 25
25: def add_child
26: category_id = params[:id]
27: @category = Category.find(category_id)
28: parent_id = params[:parent_id]
29: if parent_id.present?
30: @parent = Category.find(parent_id)
31: @category.parent = @parent
32: else
33: @category.parent = nil
34: end
35: @category.save!
36: render :update do |page|
37: page.remove "category_#{@category.id}_row"
38: if @parent
39: if @parent.name == RacingAssociation.current.short_name
40: page.replace_html "association_category_root", :partial => "category", :collection => @parent.children.sort
41: page.call :bindCategoryEvents
42: else
43: page.call :expandDisclosure, parent_id
44: end
45: else
46: page.replace_html "unknown_category_root", :partial => "category", :collection => Category.find_all_unknowns.sort
47: page.call :bindCategoryEvents
48: end
49: end
50: end
Show all Association Categories
# File app/controllers/admin/categories_controller.rb, line 9
9: def index
10: respond_to do |format|
11: format.html {
12: @category = Category.find_or_create_by_name(RacingAssociation.current.short_name)
13: @unknowns = Category.find_all_unknowns
14: }
15: format.js {
16: render :update do |page|
17: @category = Category.find(params[:category_id], :include => :children)
18: page.replace_html "category_#{@category.id}_children", :partial => "category", :collection => @category.children.sort
19: end
20: }
21: end
22: end
Calculate MbraTeamBar only
# File app/controllers/admin/categories_controller.rb, line 59
59: def recompute_team_bar
60: MbraTeamBar.calculate!
61: redirect_to :action => :index
62: end