Skip to content

Commit

Permalink
Add Select2 for form selects
Browse files Browse the repository at this point in the history
  • Loading branch information
Garbar committed Sep 13, 2020
1 parent e973637 commit 7c8ecfd
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions app/javascript/packs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'src/stylesheets/application.scss'

import 'bootstrap'
import 'bootstrap-select'
import Select2 from "select2"

require('@rails/ujs').start()
require('@rails/activestorage').start()
Expand All @@ -16,8 +17,10 @@ require('jquery')
require('bootstrap-datepicker')
require('datatables.net-dt')
require('datatables.net-dt/css/jquery.dataTables.css')
require("select2/dist/css/select2")

require('src/case_contact')
require('src/select')
require('src/dashboard')
require('src/index_reports')
require('src/sessions')
Expand Down
4 changes: 4 additions & 0 deletions app/javascript/src/select.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* global alert $ */
$('document').ready(() => {
$('.select2').select2({ theme: 'classic' })
})
2 changes: 1 addition & 1 deletion app/views/casa_cases/_volunteer_assignment.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

<div class='form-group'>
<label for='case_assignment_casa_case_id'>Select a Volunteer</label>
<select id='case_assignment_casa_case_id' name='case_assignment[volunteer_id]' class='form-control'>
<select id='case_assignment_casa_case_id' name='case_assignment[volunteer_id]' class='form-control select2'>
<% Volunteer.active.order(:display_name).each do |volunteer| %>
<option value="<%= volunteer.id %>"><%= volunteer.decorate.name %></option>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/case_assignments/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

<div class='form-group'>
<label for="case_assignment_casa_case_id">Select a Case</label>
<select id="is-this-used-anywhere" class='form-control'>
<select id="is-this-used-anywhere" class='form-control select2'>
<% CasaCase.all.each do |casa_case| %>
<option value="<%= casa_case.id %>"><%= casa_case.case_number %></option>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/supervisors/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

<div class='form-group'>
<label for='supervisor_volunteer_volunteer_id'>Select a Volunteer</label>
<select name='supervisor_volunteer[volunteer_id]' class='form-control'>
<select name='supervisor_volunteer[volunteer_id]' class='form-control select2'>
<% @available_volunteers.each do |volunteer| %>
<option value="<%= volunteer.id %>"><%= volunteer.decorate.name %></option>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/volunteers/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@

<div class='form-group'>
<label for='case_assignment_casa_case_id'>Select a Case</label>
<select id="case_assignment_casa_case_id" name='case_assignment[casa_case_id]' class='form-control'>
<select id="case_assignment_casa_case_id" name='case_assignment[casa_case_id]' class='form-control select2'>
<% CasaCase.available_for_volunteer(@volunteer).find_each do |casa_case| %>
<option value="<%= casa_case.id %>"><%= casa_case.case_number %></option>
<% end %>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"datatables.net-dt": "^1.10.20",
"jquery": "^3.5.0",
"popper.js": "^1.16.1",
"select2": "^4.0.13",
"turbolinks": "^5.2.0"
},
"version": "0.1.0",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8299,6 +8299,11 @@ select-hose@^2.0.0:
resolved "https://registry.yarnpkg.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca"
integrity sha1-Yl2GWPhlr0Psliv8N2o3NZpJlMo=

select2@^4.0.13:
version "4.0.13"
resolved "https://registry.yarnpkg.com/select2/-/select2-4.0.13.tgz#0dbe377df3f96167c4c1626033e924372d8ef44d"
integrity sha512-1JeB87s6oN/TDxQQYCvS5EFoQyvV6eYMZZ0AeA4tdFDYWN3BAGZ8npr17UBFddU0lgAt3H0yjX3X6/ekOj1yjw==

selfsigned@^1.10.7:
version "1.10.7"
resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-1.10.7.tgz#da5819fd049d5574f28e88a9bcc6dbc6e6f3906b"
Expand Down

0 comments on commit 7c8ecfd

Please sign in to comment.