diff --git a/Gemfile b/Gemfile index 6d9f6a4..576ae5f 100644 --- a/Gemfile +++ b/Gemfile @@ -43,8 +43,6 @@ gem 'rails_admin' gem 'jquery-ui-rails' gem 'american_date' - - group :doc do # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', require: false diff --git a/app/assets/stylesheets/_badges.css.scss b/app/assets/stylesheets/_badges.css.scss new file mode 100644 index 0000000..07c0047 --- /dev/null +++ b/app/assets/stylesheets/_badges.css.scss @@ -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); + } + } +} diff --git a/app/assets/stylesheets/vacation_time.css.scss b/app/assets/stylesheets/vacation_time.css.scss new file mode 100644 index 0000000..e87f3a7 --- /dev/null +++ b/app/assets/stylesheets/vacation_time.css.scss @@ -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/ diff --git a/app/controllers/homes_controller.rb b/app/controllers/homes_controller.rb index 12a92f3..8d605a6 100644 --- a/app/controllers/homes_controller.rb +++ b/app/controllers/homes_controller.rb @@ -1,5 +1,6 @@ class HomesController < ApplicationController def show @profiles = Profile.all + @office_branches = OfficeBranch.all end end diff --git a/app/controllers/job_title_users_controller.rb b/app/controllers/job_title_users_controller.rb new file mode 100644 index 0000000..a2e7b44 --- /dev/null +++ b/app/controllers/job_title_users_controller.rb @@ -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 diff --git a/app/controllers/office_branches_controller.rb b/app/controllers/office_branches_controller.rb index c9ba017..4ca0106 100644 --- a/app/controllers/office_branches_controller.rb +++ b/app/controllers/office_branches_controller.rb @@ -43,7 +43,7 @@ def destroy private def office_branch_params - params.require(:office_branch).permit(:location) + params.require(:office_branch).permit(:city, :state, :country) end def find_office_branch diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index fed7808..10f88d8 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -8,6 +8,7 @@ def show def new @profile = Profile.new + @user = @profile.user end def create @@ -18,6 +19,7 @@ def create def edit @profile = find_profile @user = @profile.user + @job_title_user = JobTitleUser.new end def update diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c17228a..bfe441f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -31,7 +31,9 @@ def user_params :email, :password, :department_id, - :office_branch_id + :office_branch_id, + :job_title_users, + :job_titles ) end diff --git a/app/helpers/vacation_time_helper.rb b/app/helpers/vacation_time_helper.rb new file mode 100644 index 0000000..53a3331 --- /dev/null +++ b/app/helpers/vacation_time_helper.rb @@ -0,0 +1,2 @@ +module VacationTimeHelper +end diff --git a/app/models/job_title.rb b/app/models/job_title.rb new file mode 100644 index 0000000..17d9163 --- /dev/null +++ b/app/models/job_title.rb @@ -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 diff --git a/app/models/job_title_user.rb b/app/models/job_title_user.rb new file mode 100644 index 0000000..a5ffaa4 --- /dev/null +++ b/app/models/job_title_user.rb @@ -0,0 +1,4 @@ +class JobTitleUser < ActiveRecord::Base + belongs_to :user + belongs_to :job_title +end diff --git a/app/models/null_job_title.rb b/app/models/null_job_title.rb new file mode 100644 index 0000000..f7a7ee0 --- /dev/null +++ b/app/models/null_job_title.rb @@ -0,0 +1,5 @@ +class NullJobTitle + def name + "No Current Job" + end +end diff --git a/app/models/null_profile.rb b/app/models/null_profile.rb index c32d895..a254788 100644 --- a/app/models/null_profile.rb +++ b/app/models/null_profile.rb @@ -7,4 +7,5 @@ def to_partial_path def present? false end + end diff --git a/app/models/office_branch.rb b/app/models/office_branch.rb index 1d71630..8a28337 100644 --- a/app/models/office_branch.rb +++ b/app/models/office_branch.rb @@ -1,5 +1,7 @@ class OfficeBranch < ActiveRecord::Base - validates :location, presence: true + validates :city, presence: true + validates :country, presence: true + has_many :users def profiles diff --git a/app/models/user.rb b/app/models/user.rb index b7032da..7678e06 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 + + def current_job + job_titles.last || NullJobTitle.new + end def has_any_contact_information? address || diff --git a/app/views/homes/show.html.erb b/app/views/homes/show.html.erb index a8d2a37..3ca5727 100644 --- a/app/views/homes/show.html.erb +++ b/app/views/homes/show.html.erb @@ -32,9 +32,9 @@
  • - Departments + Office Branches
    -

    Donec mattis mauris gravida metus laoreet non rutrum sem viverra. Aenean nibh libero, viverra vel vestibulum in, porttitor ut sapien. Phasellus tempor lorem id justo ornare tincidunt. Nulla faucibus, purus eu placerat fermentum, velit mi iaculis nunc, bibendum tincidunt ipsum justo eu mauris. Nulla facilisi. Vestibulum vel lectus ac purus tempus suscipit nec sit amet eros. Nullam fringilla, enim eu lobortis dapibus, quam magna tincidunt nibh, sit amet imperdiet dolor justo congue turpis.

    + <%= geo_chart @office_branches.group(:country).count %>
  • diff --git a/app/views/office_branches/_office_branch.html.erb b/app/views/office_branches/_office_branch.html.erb index 50f730f..506c94b 100644 --- a/app/views/office_branches/_office_branch.html.erb +++ b/app/views/office_branches/_office_branch.html.erb @@ -1,5 +1,5 @@ diff --git a/app/views/office_branches/new.html.erb b/app/views/office_branches/new.html.erb index 16fe178..932c212 100644 --- a/app/views/office_branches/new.html.erb +++ b/app/views/office_branches/new.html.erb @@ -2,6 +2,8 @@ <%= form_for(@office_branch) do |form| %> <%= render "form_errors", target: @office_branch %> - <%= form.text_field :location, placeholder: "Location" %> + <%= form.text_field :city, placeholder: "City" %> + <%= form.text_field :state, placeholder: "State" %> + <%= form.text_field :country, placeholder: "Country" %> <%= form.submit "Create Office Branch" %> <% end %> diff --git a/app/views/office_branches/show.html.erb b/app/views/office_branches/show.html.erb index 509d260..7cedfb9 100644 --- a/app/views/office_branches/show.html.erb +++ b/app/views/office_branches/show.html.erb @@ -1,4 +1,4 @@ -

    <%= @office_branch.location %>

    +

    <%= @office_branch.city %>, <%= @office_branch.state %>