Skip to content

Commit

Permalink
Merge pull request #687 from bitzesty/main
Browse files Browse the repository at this point in the history
Staging release
  • Loading branch information
DaniBitZesty authored Apr 22, 2024
2 parents 0776504 + 49fa1f2 commit c66c941
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/lieutenants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Admin::LieutenantsController < Admin::UsersController
before_action :permit_search_params, except: [:index]

def index
params[:search] ||= LieutenantSearch::DEFAULT_SEARCH
params[:search] ||= LieutenantSearch.default_search
params[:search].permit!
authorize :lieutenant, :index?

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/lieutenant/lieutenants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Lieutenant::LieutenantsController < Lieutenant::BaseController
def index
authorize :lieutenant, :index?

params[:search] ||= LieutenantSearch::DEFAULT_SEARCH
params[:search] ||= LieutenantSearch.default_search
params[:search].permit!

@search = LieutenantSearch.new(Lieutenant.from_county(current_lieutenant.ceremonial_county))
Expand Down
15 changes: 10 additions & 5 deletions app/search/lieutenant_search.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
class LieutenantSearch < Search
DEFAULT_SEARCH = {
sort: "full_name",
search_filter: {}
}

include FullNameSort

def self.default_search
{
sort: "full_name",
search_filter: {
assigned_ceremonial_county: LieutenantSearch.ceremonial_county_options.map(&:second)
}
}
end


def filter_by_assigned_ceremonial_county(scoped_results, value)
value = value.map do |v|
v == "not_assigned" ? nil : v
Expand Down

0 comments on commit c66c941

Please sign in to comment.