Skip to content

Commit

Permalink
add filtering for users
Browse files Browse the repository at this point in the history
  • Loading branch information
JensRavens committed Oct 16, 2024
1 parent 17b2194 commit f98e760
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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: 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

0 comments on commit f98e760

Please sign in to comment.