diff --git a/app/controllers/casa_admins_controller.rb b/app/controllers/casa_admins_controller.rb index 1cdd1f6564..2623a26f9a 100644 --- a/app/controllers/casa_admins_controller.rb +++ b/app/controllers/casa_admins_controller.rb @@ -7,7 +7,8 @@ def index @admins = policy_scope(current_organization.casa_admins) end - def edit; end + def edit + end def update if @casa_admin.update(update_casa_admin_params) diff --git a/app/controllers/contact_type_groups_controller.rb b/app/controllers/contact_type_groups_controller.rb index fa5d5bc4ca..5df7765f2c 100644 --- a/app/controllers/contact_type_groups_controller.rb +++ b/app/controllers/contact_type_groups_controller.rb @@ -16,7 +16,8 @@ def create end end - def edit; end + def edit + end def update if @contact_type_group.update(contact_type_group_params) @@ -26,13 +27,13 @@ def update end end -private + private - def contact_type_group_params - params.require(:contact_type_group).permit(:name, :active) - end + def contact_type_group_params + params.require(:contact_type_group).permit(:name, :active) + end - def set_contact_type_group - @contact_type_group = ContactTypeGroup.find(params[:id]) - end + def set_contact_type_group + @contact_type_group = ContactTypeGroup.find(params[:id]) + end end diff --git a/app/controllers/contact_types_controller.rb b/app/controllers/contact_types_controller.rb index 612c5fe26e..d9690fd279 100644 --- a/app/controllers/contact_types_controller.rb +++ b/app/controllers/contact_types_controller.rb @@ -19,7 +19,8 @@ def create end end - def edit; end; + def edit + end def update if @contact_type.update(contact_type_params) @@ -29,7 +30,7 @@ def update end end -private + private def set_group_options @group_options = ContactTypeGroup.for_organization(current_organization).collect { |group| [group.name, group.id] } diff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rb index 554a0f392d..bea0ea5cf5 100644 --- a/app/controllers/imports_controller.rb +++ b/app/controllers/imports_controller.rb @@ -16,7 +16,7 @@ def create # If there were failed imports if import[:exported_rows] - message << "
" + link_to("Click here to download failed rows.", download_failed_imports_path) + + message << "
" + link_to("Click here to download failed rows.", download_failed_imports_path) + "
" + "#{ERR_FAILED_IMPORT_NOTE}
" session[:exported_rows] = import[:exported_rows] end @@ -51,7 +51,7 @@ def header { "volunteer" => VolunteerImporter::IMPORT_HEADER, "supervisor" => SupervisorImporter::IMPORT_HEADER, - "casa_case" => CaseImporter::IMPORT_HEADER, + "casa_case" => CaseImporter::IMPORT_HEADER } end @@ -98,10 +98,10 @@ def validate_file(file, import_type) unless header_valid?(file_header, import_type) message = "#{ERR_INVALID_HEADER}" \ - "Expected Header: #{header[import_type].to_s}.
" \ - "Received Header: #{file_header.to_s}
" - - return {type: :error, message: message} + "Expected Header: #{header[import_type]}." \ + "Received Header: #{file_header}
" + + {type: :error, message: message} end end end diff --git a/app/decorators/casa_case_decorator.rb b/app/decorators/casa_case_decorator.rb index 67b2bbc342..ed7546051d 100644 --- a/app/decorators/casa_case_decorator.rb +++ b/app/decorators/casa_case_decorator.rb @@ -9,6 +9,10 @@ def transition_aged_youth_only_icon object.transition_aged_youth ? "šš¦" : "" end + def court_report_submission + object.court_report_submitted ? "Submitted" : "Not Submitted" + end + def case_contacts_ordered_by_occurred_at object.case_contacts.sort_by(&:occurred_at) end diff --git a/app/helpers/ui_helper.rb b/app/helpers/ui_helper.rb index 282b79a3d0..599ec5f0a4 100644 --- a/app/helpers/ui_helper.rb +++ b/app/helpers/ui_helper.rb @@ -9,13 +9,13 @@ def grouped_options_for_assigning_case(volunteer) "Not Assigned", CasaCase .not_assigned(@volunteer.casa_org) - .map{ |casa_case| [casa_case.case_number, casa_case.id] } + .map { |casa_case| [casa_case.case_number, casa_case.id] } ], [ "Assigned", CasaCase .actively_assigned_excluding_volunteer(@volunteer) - .map{ |casa_case| [casa_case.case_number, casa_case.id] } + .map { |casa_case| [casa_case.case_number, casa_case.id] } ] ] end diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 9ca27e813e..527215a590 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -6,9 +6,9 @@ // this is how stylesheets are loaded into the running application import 'src/stylesheets/application.scss' - import 'bootstrap' import 'bootstrap-select' +import Select2 from 'select2' require('@rails/ujs').start() require('@rails/activestorage').start() require('channels') @@ -16,7 +16,6 @@ require('jquery') require('bootstrap-datepicker') require('datatables.net-dt') require('datatables.net-dt/css/jquery.dataTables.css') -import Select2 from 'select2' require('select2') require('select2/dist/css/select2') diff --git a/app/javascript/src/case_contact.js b/app/javascript/src/case_contact.js index 304fca5dca..0a003fdbeb 100644 --- a/app/javascript/src/case_contact.js +++ b/app/javascript/src/case_contact.js @@ -70,29 +70,29 @@ window.onload = function () { } function validateNoteContent (e) { - const note_content = document.getElementById('case_contact_notes').value; + const note_content = document.getElementById('case_contact_notes').value if (note_content != '') { - e.preventDefault(); - $('#confirm-submit').modal('show'); - document.getElementById('note-content').innerHTML = note_content; + e.preventDefault() + $('#confirm-submit').modal('show') + document.getElementById('note-content').innerHTML = note_content } } - $('#casa-contact-form').submit(function(e) { + $('#casa-contact-form').submit(function (e) { validateNoteContent(e) - }); + }) - $("#confirm-submit").on("focus", function () { - document.getElementById('modal-case-contact-submit').disabled = false; - }); + $('#confirm-submit').on('focus', function () { + document.getElementById('modal-case-contact-submit').disabled = false + }) - $("#confirm-submit").on("hide.bs.modal", function () { + $('#confirm-submit').on('hide.bs.modal', function () { caseContactSubmit.disabled = false - }); + }) const caseContactSubmitFromModal = document.getElementById('modal-case-contact-submit') caseContactSubmitFromModal.onclick = function () { - $('#casa-contact-form').unbind("submit"); + $('#casa-contact-form').unbind('submit') } caseContactSubmit.onclick = function (e) { diff --git a/app/javascript/src/sidebar.js b/app/javascript/src/sidebar.js index 0062476fdb..ede772ec31 100644 --- a/app/javascript/src/sidebar.js +++ b/app/javascript/src/sidebar.js @@ -1,13 +1,13 @@ /* global $ */ -function toggleSidebar() { - const isOpen = $( "#sidebar-js" ).hasClass( "sidebar-open" ); +function toggleSidebar () { + const isOpen = $('#sidebar-js').hasClass('sidebar-open') if (isOpen) { - $('#sidebar-js').removeClass('sidebar-open'); + $('#sidebar-js').removeClass('sidebar-open') } else { - $('#sidebar-js').addClass('sidebar-open'); + $('#sidebar-js').addClass('sidebar-open') } } $('document').ready(() => { - $('#toggle-sidebar-js, #sidebar-js').on("click", toggleSidebar); + $('#toggle-sidebar-js, #sidebar-js').on('click', toggleSidebar) }) diff --git a/app/lib/importers/case_importer.rb b/app/lib/importers/case_importer.rb index 959c2b88c7..2c18af4909 100644 --- a/app/lib/importers/case_importer.rb +++ b/app/lib/importers/case_importer.rb @@ -19,15 +19,13 @@ def import_cases failures << "Case #{case_number} already exists" if result[:existing] volunteers = email_addresses_to_users(Volunteer, String(row[:case_assignment])) volunteers.each do |volunteer| - begin - if volunteer.casa_cases.exists?(casa_case.id) - failures << "Volunteer #{volunteer.email} already assigned to #{case_number}" - else - casa_case.volunteers << volunteer - end - rescue StandardError => error - failures << error.to_s + if volunteer.casa_cases.exists?(casa_case.id) + failures << "Volunteer #{volunteer.email} already assigned to #{case_number}" + else + casa_case.volunteers << volunteer end + rescue => error + failures << error.to_s end raise failures.join("\n") unless failures.empty? @@ -35,18 +33,17 @@ def import_cases end end - private def create_casa_case(row_data) casa_case_params = row_data.to_hash.slice(:case_number, :transition_aged_youth, :birth_month_year_youth) casa_case = CasaCase.find_by(casa_case_params) - return { casa_case: casa_case, existing: true } if casa_case.present? + return {casa_case: casa_case, existing: true} if casa_case.present? casa_case = CasaCase.new(casa_case_params) casa_case.casa_org_id = org_id casa_case.save! - { casa_case: casa_case, existing: false } + {casa_case: casa_case, existing: false} end end diff --git a/app/lib/importers/file_importer.rb b/app/lib/importers/file_importer.rb index 0fb708560e..d6cd334973 100644 --- a/app/lib/importers/file_importer.rb +++ b/app/lib/importers/file_importer.rb @@ -23,7 +23,7 @@ def import @file_no_rows = false yield(row) @number_imported += 1 - rescue StandardError => error + rescue => error # email for supervisor or volunteer # display name for supervisor or volunteer # case number for casa_case @@ -41,14 +41,14 @@ def import } end -private + private def failed? !failed_imports.blank? end def success? - !failed? && !@file_no_rows + !failed? && !@file_no_rows end def message @@ -86,12 +86,12 @@ def email_addresses_to_users(clazz, comma_separated_emails) def create_user_record(user_class, row_data) user_params = row_data.to_hash.slice(:display_name, :email) user = user_class.find_by(user_params) - return { user: user, existing: true } if user.present? + return {user: user, existing: true} if user.present? user = user_class.new(user_params) user.casa_org_id, user.password = org_id, SecureRandom.hex(10) user.save! user.invite! - { user: user, existing: false } + {user: user, existing: false} end end diff --git a/app/lib/importers/supervisor_importer.rb b/app/lib/importers/supervisor_importer.rb index 955a329a8b..3350914adc 100644 --- a/app/lib/importers/supervisor_importer.rb +++ b/app/lib/importers/supervisor_importer.rb @@ -1,6 +1,6 @@ class SupervisorImporter < FileImporter IMPORT_HEADER = ["email", "display_name", "supervisor_volunteers"] - + def self.import_supervisors(csv_filespec, org_id) new(csv_filespec, org_id).import_supervisors end @@ -17,17 +17,15 @@ def import_supervisors failures = [] failures << "Supervisor #{supervisor.email} already exists" if result[:existing] email_addresses_to_users(Volunteer, String(row[:supervisor_volunteers])).each do |volunteer| - begin - if volunteer.supervisor - next if volunteer.supervisor == supervisor + if volunteer.supervisor + next if volunteer.supervisor == supervisor - failures << "Volunteer #{volunteer.email} already has a supervisor" - else - supervisor.volunteers << volunteer - end - rescue StandardError => error - failures << error.to_s + failures << "Volunteer #{volunteer.email} already has a supervisor" + else + supervisor.volunteers << volunteer end + rescue => error + failures << error.to_s end end diff --git a/app/lib/importers/volunteer_importer.rb b/app/lib/importers/volunteer_importer.rb index ec945c4752..d8fda509fa 100644 --- a/app/lib/importers/volunteer_importer.rb +++ b/app/lib/importers/volunteer_importer.rb @@ -1,6 +1,6 @@ class VolunteerImporter < FileImporter IMPORT_HEADER = ["display_name", "email"] - + def self.import_volunteers(csv_filespec, org_id) new(csv_filespec, org_id).import_volunteers end diff --git a/app/models/casa_case.rb b/app/models/casa_case.rb index f44404fd01..4142f7fd75 100644 --- a/app/models/casa_case.rb +++ b/app/models/casa_case.rb @@ -17,16 +17,16 @@ class CasaCase < ApplicationRecord case_assignments: {volunteer: volunteer, is_active: true} ) } - scope :actively_assigned_excluding_volunteer, -> (volunteer) { + scope :actively_assigned_excluding_volunteer, ->(volunteer) { joins(:case_assignments) - .where(case_assignments: { is_active: true }) - .where.not(case_assignments: { volunteer: volunteer }) + .where(case_assignments: {is_active: true}) + .where.not(case_assignments: {volunteer: volunteer}) .order(:case_number) } - scope :not_assigned, -> (casa_org) { + scope :not_assigned, ->(casa_org) { where(casa_org_id: casa_org.id) .left_outer_joins(:case_assignments) - .where(case_assignments: { id: nil }) + .where(case_assignments: {id: nil}) .order(:case_number) } diff --git a/app/models/case_contact.rb b/app/models/case_contact.rb index 3725516be6..6890d26f93 100644 --- a/app/models/case_contact.rb +++ b/app/models/case_contact.rb @@ -42,8 +42,10 @@ class CaseContact < ApplicationRecord where(want_driving_reimbursement: want_driving_reimbursement) if want_driving_reimbursement == true || want_driving_reimbursement == false } scope :contact_type, ->(contact_type = nil) { - joins(:db_contact_types) - .where("contact_types.name in (?)", contact_type) if contact_type.present? + if contact_type.present? + joins(:db_contact_types) + .where("contact_types.name in (?)", contact_type) + end } IN_PERSON = "in-person".freeze diff --git a/app/models/contact_type.rb b/app/models/contact_type.rb index a2e37ada09..bfd03c89d3 100644 --- a/app/models/contact_type.rb +++ b/app/models/contact_type.rb @@ -5,7 +5,7 @@ class ContactType < ApplicationRecord scope :for_organization, ->(org) { joins(:contact_type_group) - .where(contact_type_groups: { casa_org: org }) + .where(contact_type_groups: {casa_org: org}) } end diff --git a/app/models/user.rb b/app/models/user.rb index 415c1af067..a02c11b7f7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -84,7 +84,7 @@ def no_contact_for_two_weeks # Get ACTIVE volunteers that have ACTIVE supervisor assignments with at least one ACTIVE case # 1st condition: Volunteer has not created a contact AT ALL within the past 14 days # 2nd condition: Volunteer has ONLY created contacts in which contact_made = false within the past 14 days - + volunteers .includes(:case_assignments) .joins("LEFT JOIN case_contacts cc on cc.creator_id = users.id AND cc.occurred_at > (CURRENT_DATE - INTERVAL '14 days')") diff --git a/app/policies/casa_case_policy.rb b/app/policies/casa_case_policy.rb index 8f554d71d9..42f2799032 100644 --- a/app/policies/casa_case_policy.rb +++ b/app/policies/casa_case_policy.rb @@ -41,7 +41,7 @@ def assign_volunteers? def permitted_attributes common_attrs = [ :court_report_submitted, - casa_case_contact_types_attributes: [:contact_type_id], + casa_case_contact_types_attributes: [:contact_type_id] ] case @user diff --git a/app/views/all_casa_admins/dashboard/show.html.erb b/app/views/all_casa_admins/dashboard/show.html.erb index 2ef7e11757..a59087607d 100644 --- a/app/views/all_casa_admins/dashboard/show.html.erb +++ b/app/views/all_casa_admins/dashboard/show.html.erb @@ -1,7 +1,7 @@+
| - A CASA/Prince Georgeās County <%=@resource.type%> console account has been created for you. This console is for logging the time you spend and actions you take on your CASA case. You can log activity with your CASA youth, their family members, their foster family or placement, the DSS worker, your Case Supervisor and others associated with your CASA case (such as teachers and therapists). + A CASA/Prince Georgeās County <%= @resource.type %> console account has been created for you. This console is for logging the time you spend and actions you take on your CASA case. You can log activity with your CASA youth, their family members, their foster family or placement, the DSS worker, your Case Supervisor and others associated with your CASA case (such as teachers and therapists). |
| - Your console account is associated with this email. If this is not the correct email to use, please stop here and contact your Case Supervisor to change the email address. If you are ready to get started, please set your password. This is the first step to accessing your new <%=@resource.type%> account. + Your console account is associated with this email. If this is not the correct email to use, please stop here and contact your Case Supervisor to change the email address. If you are ready to get started, please set your password. This is the first step to accessing your new <%= @resource.type %> account. |