Skip to content
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

Holiday Overrides #111

Merged
merged 6 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ GEM
chunky_png (1.4.0)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
concurrent-ruby (1.3.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
countries (6.0.1)
unaccent (~> 0.3)
Expand Down Expand Up @@ -194,7 +194,7 @@ GEM
csv
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
i18n (1.14.5)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
i18n-tasks (1.0.14)
activesupport (>= 4.0.2)
Expand All @@ -218,7 +218,7 @@ GEM
activesupport (>= 6.0.0)
railties (>= 6.0.0)
io-console (0.7.2)
irb (1.14.0)
irb (1.14.1)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jmespath (1.6.2)
Expand Down Expand Up @@ -261,7 +261,7 @@ GEM
mime-types-data (3.2024.0604)
mini_magick (4.13.1)
mini_mime (1.1.5)
minitest (5.24.1)
minitest (5.25.1)
mission_control-jobs (0.2.1)
importmap-rails
rails (~> 7.1)
Expand Down Expand Up @@ -321,7 +321,7 @@ GEM
rspec-support (~> 3.12)
raabro (1.4.0)
racc (1.8.1)
rack (3.1.7)
rack (3.1.8)
rack-proxy (0.7.7)
rack
rack-session (2.0.0)
Expand Down Expand Up @@ -377,7 +377,7 @@ GEM
psych (>= 4.0.0)
redcarpet (3.6.0)
regexp_parser (2.9.2)
reline (0.5.9)
reline (0.5.10)
io-console (~> 0.5)
responders (3.1.1)
actionpack (>= 5.2)
Expand Down Expand Up @@ -488,7 +488,7 @@ GEM
temple (0.10.3)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
thor (1.3.1)
thor (1.3.2)
thread_safe (0.3.6)
tilt (2.3.0)
time_will_tell (0.1.0)
Expand All @@ -501,9 +501,8 @@ GEM
launchy
netrc
thor
turbo-rails (2.0.6)
turbo-rails (2.0.11)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -532,14 +531,14 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.1)
webrick (1.8.2)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
yael (0.0.3)
zeitwerk (2.6.17)
zeitwerk (2.7.0)

PLATFORMS
aarch64-linux
Expand Down
11 changes: 11 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@ class UsersController < ApplicationController
before_action :assign_user, except: :index

def index
@filter = params[:filter].presence || "employee"
@users = policy_scope(User.alphabetically)
case @filter
when "employee"
@users = @users.currently_employed
when "sprinter"
@users = @users.sprinter
when "hr"
@users = @users.hr
when "archive"
@users = @users.where(roles: [])
end
end

def show
Expand Down
4 changes: 0 additions & 4 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ def full_name
[first_name, last_name].map(&:presence).compact.join(" ").presence || email
end

def yearly_holidays
30
end

def remaining_holidays
yearly_holidays - used_holidays
end
Expand Down
7 changes: 5 additions & 2 deletions app/views/users/_user.html.slim
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
- salary = user.current_salary
.card
.card style="view-transition-name: user-card-#{user.id}"
.card__header
.card__icon: img src=user.avatar_image(size: 80)
.card__header-content
a.card__title href=user_path(user) = user.display_name
a.card__title href=user_path(user)
= user.full_name
- if user.nick_name.present?
= " (#{user.nick_name})"
.card__subtitle
= t(".days_of_holidays_remaining",days: user.remaining_holidays)
- if user.unpaid_holidays_this_year_total.positive?
Expand Down
4 changes: 4 additions & 0 deletions app/views/users/index.html.slim
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.container: .stack
h1.headline = t ".users"
.line.line--space-between
.stack.stack--row.stack--small.stack--wrap
- (["employee", "sprinter", "hr", "archive"]).each do |filter|
a.pill class=("active" if filter == @filter) href=(url_for(filter:)) = t("user.filter.#{filter}")
= render @users
7 changes: 7 additions & 0 deletions db/migrate/20241016121754_add_pto_amount_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class AddPtoAmountToUsers < ActiveRecord::Migration[7.1]
def change
add_column :users, :yearly_holidays, :integer, null: false, default: 30
end
end
3 changes: 2 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"license": "MIT",
"dependencies": {
"@hotwired/stimulus": "^3.2.2",
"@hotwired/turbo-rails": "^8.0.5",
"@hotwired/turbo-rails": "^8.0.12",
"@nerdgeschoss/shimmer": "^0.0.10",
"chart.js": "^3.7.0",
"chartkick": "^4.1.1",
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,18 @@
resolved "https://registry.yarnpkg.com/@hotwired/stimulus/-/stimulus-3.2.2.tgz#071aab59c600fed95b97939e605ff261a4251608"
integrity sha512-eGeIqNOQpXoPAIP7tC1+1Yc1yl1xnwYqg+3mzqxyrbE5pg5YFBZcA6YoTiByJB6DKAEsiWtl6tjTJS4IYtbB7A==

"@hotwired/turbo-rails@^8.0.5":
version "8.0.5"
resolved "https://registry.yarnpkg.com/@hotwired/turbo-rails/-/turbo-rails-8.0.5.tgz#18c2f0e4f7f952307650308590edf5eb9544b0d3"
integrity sha512-1A9G9u28IRAl0C57z8Ka3AhNPyJdwfOrbjr+ABZk2ZEUw2QO7cJ0pgs77asUj2E/tzn1PgrxrSVu24W+1Q5uBA==
"@hotwired/turbo-rails@^8.0.12":
version "8.0.12"
resolved "https://registry.yarnpkg.com/@hotwired/turbo-rails/-/turbo-rails-8.0.12.tgz#6f1a2661122c0a2bf717f3bc68b5106638798c89"
integrity sha512-ZXwu9ez+Gd4RQNeHIitqOQgi/LyqY8J4JqsUN0nnYiZDBRq7IreeFdMbz29VdJpIsmYqwooE4cFzPU7QvJkQkA==
dependencies:
"@hotwired/turbo" "^8.0.5"
"@hotwired/turbo" "^8.0.12"
"@rails/actioncable" "^7.0"

"@hotwired/turbo@^8.0.5":
version "8.0.5"
resolved "https://registry.yarnpkg.com/@hotwired/turbo/-/turbo-8.0.5.tgz#abae6dad018a891e4286e87fa0959217e3866d5a"
integrity sha512-TdZDA7fxVQ2ZycygvpnzjGPmFq4sO/E2QVg+2em/sJ3YTSsIWVEis8HmWlumz+c9DjWcUkcCuB+muF08TInpAQ==
"@hotwired/turbo@^8.0.12":
version "8.0.12"
resolved "https://registry.yarnpkg.com/@hotwired/turbo/-/turbo-8.0.12.tgz#50aa8345d7f62402680c6d2d9814660761837001"
integrity sha512-l3BiQRkD7qrnQv6ms6sqPLczvwbQpXt5iAVwjDvX0iumrz6yEonQkNAzNjeDX25/OJMFDTxpHjkJZHGpM9ikWw==

"@humanwhocodes/config-array@^0.9.2":
version "0.9.2"
Expand Down
Loading