-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added job title functionality #27
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
.badges { | ||
$badge-background: $medium-gray; | ||
$badge-dark-color: $dark-gray; | ||
$badge-error-color: $error-color; | ||
$badge-notice-color: $notice-color; | ||
$badge-success-color: $success-color; | ||
$badge-font-color: #fff; | ||
$badge-font-size: $base-font-size * .75; | ||
|
||
display: block; | ||
margin-bottom: $base-line-height; | ||
|
||
.badge { | ||
@include inline-block; | ||
background: $badge-background; | ||
border-radius: 2em; | ||
color: $badge-font-color; | ||
font-size: $badge-font-size; | ||
font-weight: 600; | ||
line-height: 1; | ||
padding: .25em 1em; | ||
text-align: center; | ||
|
||
&.dark { | ||
background: $badge-dark-color; | ||
} | ||
|
||
&.error { | ||
background: $badge-error-color; | ||
color: darken($badge-error-color, 60); | ||
} | ||
|
||
&.notice { | ||
background: $badge-notice-color; | ||
color: darken($badge-error-color, 60); | ||
} | ||
|
||
&.success { | ||
background: $badge-success-color; | ||
color: darken($badge-success-color, 60); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the vacation_time controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
class HomesController < ApplicationController | ||
def show | ||
@profiles = Profile.all | ||
@office_branches = OfficeBranch.all | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class JobTitleUsersController < ApplicationController | ||
def create | ||
@job_title = JobTitleUser.new(job_title_params) | ||
if @job_title.save | ||
redirect_to root_path | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
private | ||
|
||
def job_title_params | ||
params.require(:job_title_user).permit(:job_title_id, :user_id) | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module VacationTimeHelper | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is empty and should be removed. |
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class JobTitle < ActiveRecord::Base | ||
has_many :job_title_users | ||
has_many :users, through: :job_title_users | ||
|
||
def name | ||
super || NullJobTitle.new | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class JobTitleUser < ActiveRecord::Base | ||
belongs_to :user | ||
belongs_to :job_title | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class NullJobTitle | ||
def name | ||
"No Current Job" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ def to_partial_path | |
def present? | ||
false | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,16 @@ class User < ActiveRecord::Base | |
has_many :salaries, dependent: :destroy | ||
belongs_to :department | ||
belongs_to :office_branch | ||
has_many :job_title_users | ||
has_many :job_titles, through: :job_title_users | ||
|
||
def job_titles | ||
super || NullJobTitles.new | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing whitespace detected. |
||
|
||
def current_job | ||
job_titles.last || NullJobTitle.new | ||
end | ||
|
||
def has_any_contact_information? | ||
address || | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<ul> | ||
<li> | ||
<%= link_to office_branch.location, office_branch %> | ||
<%= link_to office_branch.city %> | ||
</li> | ||
</ul> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,6 @@ | |
resources :salaries, only: [:show, :new, :create, :index] | ||
end | ||
|
||
resource :job_title_users, only: ['create'] | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
class CreateSalaries < ActiveRecord::Migration | ||
rails class CreateSalaries < ActiveRecord::Migration | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
def change | ||
create_table :salaries do |t| | ||
t.decimal :salary | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AddStateToOfficeBranch < ActiveRecord::Migration | ||
def change | ||
rename_column :office_branches, :location, :city | ||
add_column :office_branches, :state, :string | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddCountryToOfficeBranches < ActiveRecord::Migration | ||
def change | ||
add_column :office_branches, :country, :string | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class CreateJobTitles < ActiveRecord::Migration | ||
def change | ||
create_table :job_titles do |t| | ||
t.date :date | ||
t.string :job_title | ||
t.integer :user_id | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class RemoveUserIdFromJobTitles < ActiveRecord::Migration | ||
def change | ||
remove_column :job_titles, :user_id | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddJobTitleIdToJobTitles < ActiveRecord::Migration | ||
def change | ||
add_column :job_titles, :job_title_id, :integer | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class CreateJobTitleUsers < ActiveRecord::Migration | ||
def change | ||
create_table :job_title_users do |t| | ||
t.integer :user_id | ||
t.integer :job_title_id | ||
t.timestamps | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class RemoveDateFromJobTitle < ActiveRecord::Migration | ||
def change | ||
remove_column :job_titles, :date | ||
remove_column :job_titles, :job_title_id | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddDateToJobTitleUsers < ActiveRecord::Migration | ||
def change | ||
add_column :job_title_users, :date, :date | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class ChangeJobTitleToName < ActiveRecord::Migration | ||
def change | ||
rename_column :job_titles, :job_title, :name | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,13 @@ | |
# | ||
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) | ||
# Mayor.create(name: 'Emanuel', city: cities.first) | ||
job_list = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just create an array of strings, instead of an array of arrays? job_list = [
"Paper Sales",
"Branch Manager",
"Warehouse",
"Secretary"
] |
||
["Paper Sales"], | ||
["Branch Manager"], | ||
["Warehouse"], | ||
["Secretary"] | ||
] | ||
|
||
job_list.each do |job| | ||
JobTitle.create( :job_title => job[0]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you change the arrays above, this can be |
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this file for?