Commit 75f9e078

mo khan <mo@mokhan.ca>
2014-07-20 16:32:02
replace cake controller with home controller in dashboard section.
1 parent 874352e
Changed files (6)
app/assets/javascripts/backbone/controllers/cakes_controller.js.coffee
@@ -6,10 +6,12 @@ class CakeSide.Controllers.CakesController extends Marionette.Controller
     @comment_view = CakeSide.Application.request('CommentView')
 
   index: ->
+    @selectTab()
     @comment_view.hide()
     @content_region.show(new @views.IndexView(collection: @cakes))
 
   show: (id) ->
+    @selectTab()
     cake = @cakes.get(id)
     @content_region.show(new @views.ShowView(model: cake))
     @comment_view.render
@@ -18,9 +20,15 @@ class CakeSide.Controllers.CakesController extends Marionette.Controller
       url: cake.public_url()
 
   newCake: ->
+    @selectTab()
     @comment_view.hide()
     @content_region.show(new @views.NewView(collection: @cakes))
 
   edit: (id) ->
+    @selectTab()
     @content_region.show(new @views.EditView(model: @cakes.get(id)))
     @comment_view.hide()
+
+  selectTab: ->
+    $('.nav-tabs').children().removeClass('active')
+    $('#cakes-tab').addClass('active')
app/assets/javascripts/backbone/controllers/tutorials_controller.js.coffee
@@ -6,9 +6,15 @@ class CakeSide.Controllers.TutorialsController extends Marionette.Controller
     @comment_view = CakeSide.Application.request('CommentView')
 
   index: ->
+    @selectTab()
     @comment_view.hide()
     @content_region.show(new @views.IndexView(collection: @tutorials))
 
   new: ->
+    @selectTab()
     @comment_view.hide()
     @content_region.show(new @views.NewView(collection: @tutorials))
+
+  selectTab: ->
+    $('.nav-tabs').children().removeClass('active')
+    $('#tutorial-tab').addClass('active')
app/controllers/my/cakes_controller.rb → app/controllers/my/home_controller.rb
@@ -1,5 +1,5 @@
 module My
-  class CakesController < BaseController
+  class HomeController < BaseController
     def index
     end
   end
app/views/my/cakes/index.html.erb → app/views/my/home/index.html.erb
@@ -14,7 +14,7 @@
   <% end %>
 <% end -%>
 
-<%= render partial: "shared/account_nav", locals: { selected: :creations } %>
+<%= render partial: "shared/account_nav", locals: { selected: nil }  %>
 <div id="backbone-content"></div>
 <div id="disqus_thread"></div>
 <div id="modal" class="modal hide fade"></div>
app/views/shared/_account_nav.html.erb
@@ -2,8 +2,8 @@
   <div class="span12">
     <ul class="nav nav-tabs">
       <li class="<%= selected == :dashboard ? "active" : "" %>"><%= link_to "Dashboard", my_dashboard_path %></li>
-      <li class="<%= selected == :creations ? "active" : "" %>"><%= link_to "Creations", my_root_path(anchor: 'cakes') %></li>
-      <li class=""><%= link_to "Tutorials", my_root_path(anchor: 'tutorials') %></li>
+      <li id="cakes-tab"><%= link_to "Creations", my_root_path(anchor: 'cakes') %></li>
+      <li id="tutorial-tab"><%= link_to "Tutorials", my_root_path(anchor: 'tutorials') %></li>
       <li class="<%= selected == :favorites ? "active" : "" %>"><%= link_to "Favorites", my_favorites_path %></li>
       <li class="<%= selected == :basic_info ? "active" : "" %>"><%= link_to "Settings", my_settings_path %></li>
       <li class="<%= selected == :password ? "active" : "" %>"><%= link_to "Password", my_passwords_path %></li>
config/routes.rb
@@ -68,11 +68,10 @@ Cake::Application.routes.draw do
 
   namespace :my do
     get 'dashboard', to: 'dashboard#index'
-    resources :cakes, only: [:index]
     resources :favorites, only: [:index]
     resources :settings, only: [:index, :update]
     resources :passwords, only: [:index, :update]
     resources :avatars, only: [:edit, :update]
-    root to: "cakes#index"
+    root to: "home#index"
   end
 end