Skip to content

Commit

Permalink
feat: wip accountants multiselect
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticspoon committed Apr 18, 2024
1 parent db4f4ca commit 068eca2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
6 changes: 6 additions & 0 deletions app/controllers/accountants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class AccountantsController < ApplicationController
before_action :confirm_data_access, only: [:index]
before_action :confirm_data_access_async, only: [:search, :edit]
before_action :find_patient, only: [:edit]
before_action :set_clinics, only: [:index]

def index
@patients = Patient.where(pledge_sent: true)
Expand All @@ -25,6 +26,11 @@ def edit

private

def set_clinics
@clinics = Clinic.all
@selected_clinics = (params[:clinic_id] || []).map(&:to_i)
end

def find_patient
@patient = Patient.find params[:id]
end
Expand Down
35 changes: 25 additions & 10 deletions app/views/accountants/_search_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,33 @@
method: 'GET' do |f| %>
<%= f.hidden_field :locale, value: params[:locale] %>
<%= f.text_field :search,
placeholder: t('accountants.search_placeholder'),
hide_label: true,
value: params[:search],
class: 'search_form_input accountant mr-4' %>
<%= f.select :clinic_id,
options_for_select(clinic_options.reject{ |x| x.blank? },
params[:clinic_id]),
placeholder: t("accountants.search_placeholder"),
hide_label: true,
include_blank: t('accountants.search_all_clinics'),
class: 'search_form_input accountant' %>
value: params[:search],
class: "search_form_input accountant mr-4" %>

<div class="dropdown">
<button
href="#"
data-toggle="dropdown"
class="btn dropdown-toggle navbar-text"
id="clinic-dropdown"
data-bs-auto-close="outside"
aria-haspopup="true"
aria-expanded="false"
>
Select a Clinic
</button>

<div class="dropdown-menu" aria-labelledby="clinic-dropdown">
<% @clinics.each do |clinic| %>
<li class="flex dropdown-item">
<%= label_tag "clinic_#{clinic.id}", clinic.name %>
<%= check_box_tag "clinic_id[]", clinic.id, @selected_clinics.include?(clinic.id) %>
</li>
<% end %>
</div>
</div>
<%= f.button title: t('common.search'), class: 'btn btn-primary ml-4' do %>
<i class="fas fa-search"></i>
<% end %>
Expand Down

0 comments on commit 068eca2

Please sign in to comment.