Skip to content

Commit

Permalink
Merge pull request #684 from bitzesty/main
Browse files Browse the repository at this point in the history
Staging release
  • Loading branch information
saenom authored Apr 22, 2024
2 parents df6e8ed + 65ebc73 commit 0776504
Show file tree
Hide file tree
Showing 8 changed files with 362 additions and 247 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ rspec.watchr
.pgpass
certs/*
.env
.env.development.local
.history/

*.swp
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ruby 3.2.3
nodejs 16.14.0
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WORKDIR /app

RUN apt-get update
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
RUN apt-get install -y nodejs npm
RUN apt-get install -y nodejs
RUN npm install yarn -g

# ENV SSL_CERT_DIR=/etc/ssl/certs
Expand Down
34 changes: 33 additions & 1 deletion app/search/lieutenant_search.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,43 @@
class LieutenantSearch < Search
DEFAULT_SEARCH = {
sort: "full_name"
sort: "full_name",
search_filter: {}
}

include FullNameSort

def filter_by_assigned_ceremonial_county(scoped_results, value)
value = value.map do |v|
v == "not_assigned" ? nil : v
end
scoped_results.where(ceremonial_county_id: value)
end

def sort_by_ceremonial_county_name(scoped_results, desc = false)
scoped_results.joins(:ceremonial_county).order("ceremonial_counties.name #{sort_order(desc)}")
end

class << self
def ceremonial_county_options
collection_mapping(county_options)
end

private

def collection_mapping(options)
options.map do |k, v|
[v[:label], k]
end
end

def county_options
options = Hash[not_assigned: { label: "Not assigned" }]

CeremonialCounty.ordered.collect do |county|
options[county.id] = { label: county.name }
end

options
end
end
end
51 changes: 51 additions & 0 deletions app/views/admin/lieutenants/index.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
.dashboard
h1.govuk-heading-xl
| Users
= simple_form_for @search, url: "#", method: :get, as: :search, html: { class: "search-form" } do |f|
= render 'admin/users/navigation' do
.govuk-tabs__panel
.govuk-grid-row
p.govuk-body-l.govuk-grid-column-two-thirds class="govuk-!-font-weight-bold"
| Search Lieutenancy office users
.govuk-grid-row
.govuk-grid-column-one-third
.form-group.search-input
= f.input :query, label: "Name", input_html: { type: "search" }
.govuk-grid-column-two-third
.form-group.search-input
= f.simple_fields_for [:filters, @search.filters] do |g|
= render "shared/form_answers/filters/assigned_lieutenancy_filter", g: g, options: LieutenantSearch.ceremonial_county_options
.govuk-button-group
= f.submit "Search", class: 'govuk-button'
= link_to "Clear search",
[:admin, controller_name.to_sym],
class: "govuk-button govuk-button--secondary",
role: "button",
aria: { label: "Clear search" }
.govuk-grid-row
= render "shared/users/search_count"
.govuk-button-group
- if action_name == "deleted"
= link_to "Show active users",
admin_lieutenants_path,
class: "new-user govuk-button pull-right",
role: "button",
aria: { label: "Show active users" }

- else
= link_to "Show deleted users",
deleted_admin_lieutenants_path,
class: "new-user govuk-button pull-right",
role: "button",
aria: { label: "Show deleted users" }

= link_to public_send("new_admin_#{controller_name.singularize}_path", search: params[:search], page: params[:page]), class: 'new-user govuk-button pull-right', role: 'button' do
= t("admin.users.new_button.#{controller_name}")
.clear

= render 'list', resources: @resources, f: f

.govuk-grid-row
.col-xs-12.text-right
= paginate @resources
.clear
15 changes: 0 additions & 15 deletions app/views/admin/users/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,6 @@
.govuk-grid-row
= render "shared/users/search_count"
.govuk-button-group
- if controller_name == "lieutenants"
- if action_name == "deleted"
= link_to "Show active users",
admin_lieutenants_path,
class: "new-user govuk-button pull-right",
role: "button",
aria: { label: "Show active users" }

- else
= link_to "Show deleted users",
deleted_admin_lieutenants_path,
class: "new-user govuk-button pull-right",
role: "button",
aria: { label: "Show deleted users" }

= link_to public_send("new_admin_#{controller_name.singularize}_path", search: params[:search], page: params[:page]), class: 'new-user govuk-button pull-right', role: 'button' do
= t("admin.users.new_button.#{controller_name}")
.clear
Expand Down
4 changes: 2 additions & 2 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
unless Admin.exists?
admin_args = {
email: "[email protected]",
password: SecureRandom.alphanumeric(12),
password: SecureRandom.alphanumeric(14),
first_name: "First name",
last_name: "Last name",
confirmed_at: DateTime.now
Expand All @@ -17,7 +17,7 @@
assessor_args = {
email: "[email protected]",
sub_group: "sub_group_1",
password: SecureRandom.alphanumeric(12),
password: SecureRandom.alphanumeric(14),
first_name: "First name",
last_name: "Last name",
confirmed_at: DateTime.now
Expand Down
Loading

0 comments on commit 0776504

Please sign in to comment.