diff --git a/app/javascript/application.js b/app/javascript/application.js index 9fff3fc64f..a27b35c18a 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -1,39 +1,38 @@ -/* global window */ -import './jQueryGlobalizer.js' -import '@hotwired/turbo-rails' -import 'bootstrap' -import 'bootstrap-select' -import './sweet-alert-confirm.js' -import './controllers' -import 'trix' -import '@rails/actiontext' -import './datatable.js' -Turbo.session.drive = false +import "./jquery.js"; +import "@hotwired/turbo-rails"; +import "bootstrap"; +import "bootstrap-select"; +import "./sweet-alert-confirm.js"; +import "./controllers"; +import "trix"; +import "@rails/actiontext"; +import "./datatable.js"; +Turbo.session.drive = false; -require('datatables.net-dt')(null, window.jQuery) // First parameter is the global object. Defaults to window if null -require('select2')(window.jQuery) -require('@rails/ujs').start() -require('@rails/activestorage').start() -require('bootstrap-datepicker') -require('./src/add_to_calendar_button') -require('./src/case_contact') -require('./src/case_emancipation') -require('./src/casa_case') -require('./src/new_casa_case') -require('./src/dashboard') -require('./src/emancipations') -require('./src/import') -require('./src/password_confirmation') -require('./src/read_more') -require('./src/reimbursements') -require('./src/reports') -require('./src/require_communication_preference') -require('./src/select') -require('./src/tooltip') -require('./src/time_zone') -require('./src/session_timeout_poller.js') -require('./src/display_app_metric.js') -require('./src/casa_org') -require('./src/sms_reactivation_toggle') -require('./src/validated_form') -require('./src/learning_hours') +require("datatables.net-dt")(null, window.jQuery); // First parameter is the global object. Defaults to window if null +require("select2")(window.jQuery); +require("@rails/ujs").start(); +require("@rails/activestorage").start(); +require("bootstrap-datepicker"); +require("./src/add_to_calendar_button"); +require("./src/case_contact"); +require("./src/case_emancipation"); +require("./src/casa_case"); +require("./src/new_casa_case"); +require("./src/dashboard"); +require("./src/emancipations"); +require("./src/import"); +require("./src/password_confirmation"); +require("./src/read_more"); +require("./src/reimbursements"); +require("./src/reports"); +require("./src/require_communication_preference"); +require("./src/select"); +require("./src/tooltip"); +require("./src/time_zone"); +require("./src/session_timeout_poller.js"); +require("./src/display_app_metric.js"); +require("./src/casa_org"); +require("./src/sms_reactivation_toggle"); +require("./src/validated_form"); +require("./src/learning_hours"); diff --git a/app/javascript/datatable.js b/app/javascript/datatable.js index 439af46cd1..7af6758cd4 100644 --- a/app/javascript/datatable.js +++ b/app/javascript/datatable.js @@ -1,5 +1,3 @@ -/* global $ */ - export function initializeDataTable (selector) { if ($(selector).length > 0) { $(selector).DataTable({ searching: true, order: [[0, 'asc']] }) diff --git a/app/javascript/jQueryGlobalizer.js b/app/javascript/jQueryGlobalizer.js deleted file mode 100644 index 788c0f91f7..0000000000 --- a/app/javascript/jQueryGlobalizer.js +++ /dev/null @@ -1,3 +0,0 @@ -import jquery from 'jquery' -window.jQuery = jquery -window.$ = jquery diff --git a/app/javascript/jquery.js b/app/javascript/jquery.js new file mode 100644 index 0000000000..dbcd38bfb1 --- /dev/null +++ b/app/javascript/jquery.js @@ -0,0 +1,7 @@ +import jquery from "jquery"; +window.jQuery = jquery; +window.$ = jquery; + +$(function () { + console.log("Hey!"); +}); diff --git a/app/javascript/src/add_to_calendar_button.js b/app/javascript/src/add_to_calendar_button.js index b252d41f64..6b48530059 100644 --- a/app/javascript/src/add_to_calendar_button.js +++ b/app/javascript/src/add_to_calendar_button.js @@ -1,5 +1,3 @@ -/* global $ */ - import 'add-to-calendar-button' function createCalendarEvents () { diff --git a/app/javascript/src/all_casa_admin/tables.js b/app/javascript/src/all_casa_admin/tables.js index 5054d519f0..de8ce4366c 100644 --- a/app/javascript/src/all_casa_admin/tables.js +++ b/app/javascript/src/all_casa_admin/tables.js @@ -1,5 +1,3 @@ -/* global $ */ - import { initializeDataTable } from '../../datatable' $(() => { diff --git a/app/javascript/src/casa_case.js b/app/javascript/src/casa_case.js index 3ada7c2ea1..bd06aa9018 100644 --- a/app/javascript/src/casa_case.js +++ b/app/javascript/src/casa_case.js @@ -2,7 +2,6 @@ /* global FormData */ /* global DOMParser */ /* global spinner */ -/* global $ */ import Swal from 'sweetalert2' @@ -149,23 +148,6 @@ function clearSelectErrors () { errorEl.classList.add('d-none') } -function handleModalClose () { - const selectEl = document.querySelector('#case-selection') - - if (!selectEl) return - - clearSelectErrors() - // this line taken from docs https://select2.org/programmatic-control/add-select-clear-items - $('#case-selection').val(null).trigger('change') -} - -// re-initialized for setting modal as dropdownParent -function handleDropdownSelection () { - if ($('#case-selection').hasClass('select2')) { - $('#case-selection').select2() - } -} - $(() => { // JQuery's callback for the DOM loading $('button.copy-court-button').on('click', copyOrdersFromCaseWithConfirmation) @@ -182,12 +164,6 @@ $(() => { // JQuery's callback for the DOM loading disableBtn($('button.copy-court-button')[0]) } }) - // modal id is defined in _generate_docx.html.erb so would like to be able to implement modal close logic in that file - // but not sure how to - $('#generate-docx-report-modal').on('hidden.bs.modal', () => handleModalClose()) - - $('#generate-docx-report-modal').on('shown.bs.modal', () => handleDropdownSelection()) - $('#btnGenerateReport').on('click', handleGenerateReport) if (/\/casa_cases\/.*\?.*success=true/.test(window.location.href)) { diff --git a/app/javascript/src/case_contact.js b/app/javascript/src/case_contact.js index 77ee094d24..83023b5108 100644 --- a/app/javascript/src/case_contact.js +++ b/app/javascript/src/case_contact.js @@ -1,58 +1,51 @@ -/* global window */ -/* global $ */ +import Swal from "sweetalert2"; -import Swal from 'sweetalert2' -function convertDateToSystemTimeZone (date) { - return new Date((typeof date === 'string' ? new Date(date) : date)) +function convertDateToSystemTimeZone(date) { + return new Date(typeof date === "string" ? new Date(date) : date); } -async function displayFollowupAlert () { - const { value: text, isConfirmed } = await fireSwalFollowupAlert() +async function displayFollowupAlert() { + const { value: text, isConfirmed } = await fireSwalFollowupAlert(); - if (!isConfirmed) return + if (!isConfirmed) return; - const params = text ? { note: text } : {} - const caseContactId = this.id.replace('followup-button-', '') + const params = text ? { note: text } : {}; + const caseContactId = this.id.replace("followup-button-", ""); - $.post( - `/case_contacts/${caseContactId}/followups`, - params, - () => window.location.reload() - ) + $.post(`/case_contacts/${caseContactId}/followups`, params, () => window.location.reload()); } -async function fireSwalFollowupAlert () { - const inputLabel = 'Optional: Add a note about what followup is needed.' +async function fireSwalFollowupAlert() { + const inputLabel = "Optional: Add a note about what followup is needed."; return await Swal.fire({ - input: 'textarea', + input: "textarea", title: inputLabel, - inputPlaceholder: 'Type your note here...', - inputAttributes: { 'aria-label': 'Type your note here' }, + inputPlaceholder: "Type your note here...", + inputAttributes: { "aria-label": "Type your note here" }, showCancelButton: true, showCloseButton: true, - confirmButtonText: 'Confirm', - confirmButtonColor: '#dc3545', + confirmButtonText: "Confirm", + confirmButtonColor: "#dc3545", customClass: { - inputLabel: 'mx-5' - } - }) + inputLabel: "mx-5", + }, + }); } -$(document).on('turbo:load', function () { - $('.filter-form').on('change', '.filter-input', function () { - $(this).closest('form').submit() - }) -}) +$(document).on("turbo:load", function () { + $(".filter-form").on("change", ".filter-input", function () { + $(this).closest("form").submit(); + }); +}); -$(() => { // JQuery's callback for the DOM loading - $('[data-toggle="tooltip"]').tooltip() - $('.followup-button').on('click', displayFollowupAlert) -}) +$(() => { + // JQuery's callback for the DOM loading + $('[data-toggle="tooltip"]').tooltip(); + $(".followup-button").on("click", displayFollowupAlert); +}); -export { - convertDateToSystemTimeZone -} +export { convertDateToSystemTimeZone }; diff --git a/app/javascript/src/case_emancipation.js b/app/javascript/src/case_emancipation.js index f4868ed13a..ae6d013d1f 100644 --- a/app/javascript/src/case_emancipation.js +++ b/app/javascript/src/case_emancipation.js @@ -1,5 +1,4 @@ /* eslint-env jquery */ -/* global $ */ const { Notifier } = require('./notifier') const TypeChecker = require('./type_checker') diff --git a/app/javascript/src/dashboard.js b/app/javascript/src/dashboard.js index 56989d3493..f46e804c70 100644 --- a/app/javascript/src/dashboard.js +++ b/app/javascript/src/dashboard.js @@ -1,5 +1,4 @@ /* global alert */ -/* global $ */ const { Notifier } = require('./notifier') let pageNotifier diff --git a/app/javascript/src/emancipations.js b/app/javascript/src/emancipations.js index 10406bab44..2a16d36edd 100644 --- a/app/javascript/src/emancipations.js +++ b/app/javascript/src/emancipations.js @@ -1,5 +1,3 @@ -/* global $ */ - $(() => { // JQuery's callback for the DOM loading $('table#all-case-emancipations').DataTable({ autoWidth: false, diff --git a/app/javascript/src/import.js b/app/javascript/src/import.js index c5e9055a0a..c99b5b3ffe 100644 --- a/app/javascript/src/import.js +++ b/app/javascript/src/import.js @@ -4,7 +4,6 @@ /* global localStorage */ /* global File */ /* global DataTransfer */ -/* global $ */ function dataURItoBlob (dataURI) { // convert base64 to raw binary data held in a string diff --git a/app/javascript/src/notifier.js b/app/javascript/src/notifier.js index 3f65ebacf7..a5344d5ca3 100644 --- a/app/javascript/src/notifier.js +++ b/app/javascript/src/notifier.js @@ -1,4 +1,3 @@ -/* global $ */ import { escape } from 'lodash' const TypeChecker = require('./type_checker.js') diff --git a/app/javascript/src/password_confirmation.js b/app/javascript/src/password_confirmation.js index 58f12caf87..ec44c1b8bb 100644 --- a/app/javascript/src/password_confirmation.js +++ b/app/javascript/src/password_confirmation.js @@ -1,5 +1,4 @@ /* eslint-env jquery */ -/* global $ */ import Swal from 'sweetalert2' import { disableBtn, enableBtn } from './casa_case' diff --git a/app/javascript/src/reimbursements.js b/app/javascript/src/reimbursements.js index a170ff9fcf..60008d41f7 100644 --- a/app/javascript/src/reimbursements.js +++ b/app/javascript/src/reimbursements.js @@ -1,5 +1,3 @@ -/* global $ */ - $(() => { // JQuery's callback for the DOM loading const { groupBy, map, mapValues } = require('lodash') diff --git a/app/javascript/src/select.js b/app/javascript/src/select.js index 03ee914fc3..1d111d6abb 100644 --- a/app/javascript/src/select.js +++ b/app/javascript/src/select.js @@ -1,11 +1,12 @@ -/* global $ */ - -$(() => { // JQuery's callback for the DOM loading - $('.select2').select2( - { - theme: 'bootstrap-5', - width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style', - placeholder: $(this).data('placeholder') - } - ) -}) +$(() => { + // JQuery's callback for the DOM loading + $(".select2").select2({ + theme: "bootstrap-5", + width: $(this).data("width") + ? $(this).data("width") + : $(this).hasClass("w-100") + ? "100%" + : "style", + placeholder: $(this).data("placeholder"), + }); +}); diff --git a/app/javascript/src/tooltip.js b/app/javascript/src/tooltip.js index 4cdc13035d..d1dc6e75b8 100644 --- a/app/javascript/src/tooltip.js +++ b/app/javascript/src/tooltip.js @@ -1,5 +1,3 @@ -/* global $ */ - $(() => { // JQuery's callback for the DOM loading $('[data-toggle="tooltip"]').tooltip() }) diff --git a/app/javascript/src/validated_form.js b/app/javascript/src/validated_form.js index 41cf7526f3..9a6d6926e0 100644 --- a/app/javascript/src/validated_form.js +++ b/app/javascript/src/validated_form.js @@ -1,4 +1,3 @@ -/* global $ */ const { Notifier } = require('./notifier') const TypeChecker = require('./type_checker') @@ -253,7 +252,6 @@ $(() => { // JQuery's callback for the DOM loading if ($('#case_contact_miles_driven').length) { safeInstantiateComponent('non driving contact medium warning', () => { const contactMediumWithMilesDrivenWarning = new NonDrivingContactMediumWarning(validatedFormCollection.find('.contact-medium.form-group input:not([type=hidden]), #case_contact_miles_driven'), pageNotifier) - console.log(contactMediumWithMilesDrivenWarning) validatableFormSectionComponents.push(contactMediumWithMilesDrivenWarning) }) } diff --git a/package-lock.json b/package-lock.json index 095449f990..f7953349c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,12 +22,11 @@ "bootstrap": "5.3.6", "bootstrap-datepicker": "^1.10.1", "bootstrap-scss": "^5.3.8", - "bootstrap-select": "^1.13.18", "chart.js": "^4.5.1", "chartjs-adapter-luxon": "^1.3.1", "datatables.net-dt": "^1.13.11", "esbuild": "^0.27.2", - "jquery": "^3.7.1", + "jquery": "^4.0.0", "js-cookie": "^3.0.5", "jstz": "^2.1.1", "lodash": "^4.17.21", @@ -5001,22 +5000,18 @@ "jquery": ">=3.4.0 <4.0.0" } }, + "node_modules/bootstrap-datepicker/node_modules/jquery": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.7.1.tgz", + "integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==", + "license": "MIT" + }, "node_modules/bootstrap-scss": { "version": "5.3.8", "resolved": "https://registry.npmjs.org/bootstrap-scss/-/bootstrap-scss-5.3.8.tgz", "integrity": "sha512-lDjTMXl2lRwfhGJY3vmDXlWSk50gg7eW2+zzCQi9tsyeZgD6N5hcmMk3G28F7MvLniJKS9LZV+2YNCxiW8+WIw==", "license": "MIT" }, - "node_modules/bootstrap-select": { - "version": "1.13.18", - "resolved": "https://registry.npmjs.org/bootstrap-select/-/bootstrap-select-1.13.18.tgz", - "integrity": "sha512-V1IzK4rxBq5FrJtkzSH6RmFLFBsjx50byFbfAf8jYyXROWs7ZpprGjdHeoyq2HSsHyjJhMMwjsQhRoYAfxCGow==", - "license": "MIT", - "peerDependencies": { - "bootstrap": ">=3.0.0", - "jquery": "1.9.1 - 3" - } - }, "node_modules/brace-expansion": { "version": "1.1.12", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", @@ -11001,9 +10996,9 @@ } }, "node_modules/jquery": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.7.1.tgz", - "integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-4.0.0.tgz", + "integrity": "sha512-TXCHVR3Lb6TZdtw1l3RTLf8RBWVGexdxL6AC8/e0xZKEpBflBsjh9/8LXw+dkNFuOyW9B7iB3O1sP7hS0Kiacg==", "license": "MIT" }, "node_modules/js-cookie": { diff --git a/package.json b/package.json index ca4b2a642c..ac47ace73f 100644 --- a/package.json +++ b/package.json @@ -26,12 +26,11 @@ "bootstrap": "5.3.6", "bootstrap-datepicker": "^1.10.1", "bootstrap-scss": "^5.3.8", - "bootstrap-select": "^1.13.18", "chart.js": "^4.5.1", "chartjs-adapter-luxon": "^1.3.1", "datatables.net-dt": "^1.13.11", "esbuild": "^0.27.2", - "jquery": "^3.7.1", + "jquery": "^4.0.0", "js-cookie": "^3.0.5", "jstz": "^2.1.1", "lodash": "^4.17.21",