Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
add nav top
Browse files Browse the repository at this point in the history
  • Loading branch information
Harley Trung committed May 22, 2009
1 parent 6e32aa2 commit 44b4474
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 31 deletions.
15 changes: 8 additions & 7 deletions app/controllers/departments_controller.rb
Expand Up @@ -2,15 +2,15 @@ class DepartmentsController < ApplicationController
def index
@departments = Department.all
end

def show
@department = Department.find(params[:id])
redirect_to department_users_path(params[:id])
end

def new
@department = Department.new
end

def create
@department = Department.new(params[:department])
if @department.save
Expand All @@ -20,11 +20,11 @@ def create
render :action => 'new'
end
end

def edit
@department = Department.find(params[:id])
end

def update
@department = Department.find(params[:id])
if @department.update_attributes(params[:department])
Expand All @@ -34,11 +34,12 @@ def update
render :action => 'edit'
end
end

def destroy
@department = Department.find(params[:id])
@department.destroy
flash[:notice] = "Successfully destroyed department."
redirect_to departments_url
end
end

2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
@@ -1,5 +1,5 @@
class UsersController < ApplicationController
before_filter :load_department, :only => [:index, :new, :create]
before_filter :load_department, :only => [:index, :new, :create, :mass_add]

def index
@users = @department.users
Expand Down
11 changes: 8 additions & 3 deletions app/helpers/layout_helper.rb
Expand Up @@ -7,17 +7,22 @@ def title(page_title, show_title = true)
@content_for_title = page_title.to_s
@show_title = show_title
end

def show_title?
@show_title
end

def stylesheet(*args)
content_for(:head) { stylesheet_link_tag(*args.map(&:to_s)) }
end

def javascript(*args)
args = args.map { |arg| arg == :defaults ? arg : arg.to_s }
content_for(:head) { javascript_include_tag(*args) }
end

def tab(str)
str == controller.controller_name ? "current_tab" : "tab"
end
end

16 changes: 0 additions & 16 deletions app/views/departments/show.html.erb

This file was deleted.

18 changes: 14 additions & 4 deletions app/views/layouts/application.html.erb
Expand Up @@ -3,20 +3,30 @@
<html>
<head>
<title><%= h(yield(:title) || "Untitled") %></title>
<%= stylesheet_link_tag 'application' %>
<%= stylesheet_link_tag 'application', 'nav' %>
<%= yield(:head) %>
</head>
<body>

<%= render :file => 'layouts/nav_top' %>
<% if @current_user %>
<div id="login">
<p>Hello <%= @current_user.name %>!</p>
You are logged in as <%= @current_user.netid %> <%= link_to "[Logout]", logout_path %>
</div>
<% end %>

<div id="container">
<%- flash.each do |name, msg| -%>
<%= content_tag :div, msg, :id => "flash_#{name}" %>
<%- end -%>
<%- if show_title? -%>
<h1><%=h yield(:title) %></h1>
<%- end -%>
<%= yield %>
<%= yield(:my_content) || yield %>
</div>
</body>
</html>

8 changes: 8 additions & 0 deletions app/views/layouts/nav_top.html.erb
@@ -0,0 +1,8 @@
<div id="nav_top">
<ul class="no_underlined">
<li class="<%= tab('users') %>"><%= link_to "Users", department_users_path(@department) %></li>
<li class="<%= tab('roles') %>"><%= link_to "Roles", department_roles_path(@department) %></li>
<li class="<%= tab('loc_groups') %>"><%= link_to "Loc Groups", department_loc_groups_path(@department) %></li>
<ul>
</div>

18 changes: 18 additions & 0 deletions app/views/layouts/users.html.erb
@@ -0,0 +1,18 @@
<% content_for :my_content do %>
<div id="nav_bar">
<ul>
<li><%= link_to "New User", new_department_user_path(@department) %></li>
<li><%= link_to "Mass Add", mass_add_department_users_path(@department) %></li>
<li><%= link_to "All Users", department_users_path(@department) %></li>
<ul>
</div>

<div id="tab_content">
<%= yield %>
</div>

<div class="clear"></div>
<% end %>
<%= render :file => 'layouts/application.html.erb' %>

47 changes: 47 additions & 0 deletions public/stylesheets/nav.css
@@ -0,0 +1,47 @@
.no_underlined a{
text-decoration: none;
color: whitesmoke;
}

li.current_tab{
background: #222;
}

div#nav_top{
width: 84.2%;
margin: 0 auto;
}

div#nav_top ul{
margin: 0 auto;
}

div#nav_top li{
display: inline;
padding-right: 20px;
padding-left: 20px;
width: 200px;
}

div #nav_bar{
width: 20%;
height: 100%;
float: left;
border: 1px solid black;
background-color: whitesmoke;
padding: 10px;
word-wrap: break-word;
}

a{
color: blue;
}
a:hover{
color: orange;
}

div #tab_content{
float: right;
width: 70%;
}

0 comments on commit 44b4474

Please sign in to comment.