Skip to content

Commit

Permalink
GL-1067: Implement Search Functionality for Exemptions on Category As…
Browse files Browse the repository at this point in the history
…sessments Page
  • Loading branch information
rasikasri committed Sep 27, 2024
1 parent 070773b commit a3e72a2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class CategoryAssessmentsController < AuthenticatedController
before_action :disable_service_switching!
before_action :check_service
def index
@category_assessments = GreenLanes::CategoryAssessment.all(page: current_page).fetch
@category_assessments = GreenLanes::CategoryAssessment.all(query: { exemption_code: params[:exemption_code], page: current_page}).fetch
end

def new
Expand Down
16 changes: 16 additions & 0 deletions app/views/green_lanes/category_assessments/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@

<%= link_to 'Add a Category Assessment', new_green_lanes_category_assessment_path, class: 'govuk-button' %>

<%= form_with url: green_lanes_category_assessments_path, method: :get, class: "govuk-form-group" do |form| %>
<fieldset class="govuk-fieldset">
<legend class="govuk-fieldset__legend govuk-fieldset__legend--m">
Search Category Assessments
</legend>
<div class="govuk-form-group">
<%= form.label :exemption_code, "Green Lanes Exemption Code", class: "govuk-label" %>
<%= form.text_field :exemption_code, class: "govuk-input govuk-!-width-one-third", id: "search-term", width: 'one-third'%>
</div>

<div class="govuk-form-group">
<%= form.submit "Search", class: "govuk-button" %>
</div>
</fieldset>
<% end %>

<% if @category_assessments.any? %>
<table>
<thead>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

describe 'GET #index' do
before do
stub_api_request('/admin/green_lanes/category_assessments?page=1', backend: 'xi').and_return \
stub_api_request('/admin/green_lanes/category_assessments?query[exemption_code]&query[page]=1', backend: 'xi').and_return \
jsonapi_response :category_assessments, attributes_for_list(:category_assessment, 3, :with_theme)
end

Expand Down

0 comments on commit a3e72a2

Please sign in to comment.