From b112cc3563389e492672433099d07020b1541e70 Mon Sep 17 00:00:00 2001 From: andrew nimmo Date: Sat, 17 Aug 2024 13:09:43 -0700 Subject: [PATCH] identify stimulus controllers on connect --- app/javascript/controllers/advanced-search_controller.js | 2 +- app/javascript/controllers/banner_controller.js | 2 +- app/javascript/controllers/donate_controller.js | 2 +- app/javascript/controllers/field-slip-job_controller.js | 2 +- app/javascript/controllers/file-input_controller.js | 2 +- app/javascript/controllers/form-images_controller.js | 2 +- app/javascript/controllers/geocode_controller.js | 2 +- app/javascript/controllers/lazyload_controller.js | 2 +- app/javascript/controllers/lightgallery_controller.js | 2 +- app/javascript/controllers/links_controller.js | 2 +- app/javascript/controllers/matrix-table_controller.js | 2 +- app/javascript/controllers/modal-toggle_controller.js | 3 ++- app/javascript/controllers/modal_controller.js | 2 +- app/javascript/controllers/name-list_controller.js | 2 +- app/javascript/controllers/name-panels_controller.js | 2 +- app/javascript/controllers/naming-reason_controller.js | 5 ++--- app/javascript/controllers/naming-vote_controller.js | 4 +++- app/javascript/controllers/nav-active_controller.js | 2 +- app/javascript/controllers/nav_controller.js | 2 +- app/javascript/controllers/reviewed-toggle_controller.js | 2 +- app/javascript/controllers/section-update_controller.js | 2 +- app/javascript/controllers/suggestions_controller.js | 2 +- app/javascript/controllers/thumbnail-map_controller.js | 2 +- app/javascript/controllers/translation_controller.js | 2 +- app/javascript/controllers/year-input_controller.js | 2 +- 25 files changed, 29 insertions(+), 27 deletions(-) diff --git a/app/javascript/controllers/advanced-search_controller.js b/app/javascript/controllers/advanced-search_controller.js index 74354491ff..88b73f7bbd 100644 --- a/app/javascript/controllers/advanced-search_controller.js +++ b/app/javascript/controllers/advanced-search_controller.js @@ -5,7 +5,7 @@ export default class extends Controller { static targets = ["searchModel", "filter"] connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "advanced-search-connected"; this.disableUnusedFilters(); } diff --git a/app/javascript/controllers/banner_controller.js b/app/javascript/controllers/banner_controller.js index 4c4dfe27ea..7ac360d090 100644 --- a/app/javascript/controllers/banner_controller.js +++ b/app/javascript/controllers/banner_controller.js @@ -3,7 +3,7 @@ import { Controller } from "@hotwired/stimulus" // Connects to data-controller="banner" export default class extends Controller { connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "banner-connected"; } setCookie({ params: { time } }) { diff --git a/app/javascript/controllers/donate_controller.js b/app/javascript/controllers/donate_controller.js index a82d330456..992de05b2e 100644 --- a/app/javascript/controllers/donate_controller.js +++ b/app/javascript/controllers/donate_controller.js @@ -5,7 +5,7 @@ export default class extends Controller { static targets = ['otherCheck', 'otherAmount'] connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "donate-connected"; } checkOther() { diff --git a/app/javascript/controllers/field-slip-job_controller.js b/app/javascript/controllers/field-slip-job_controller.js index f65fbac72b..f111256fd2 100644 --- a/app/javascript/controllers/field-slip-job_controller.js +++ b/app/javascript/controllers/field-slip-job_controller.js @@ -16,7 +16,7 @@ export default class extends Controller { connect() { // Just a "sanity check" convention, so you can tell "is this thing on?" - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "field-slip-job-connected"; this.status_id = this.element.dataset.status this.start_timer_sending_requests() diff --git a/app/javascript/controllers/file-input_controller.js b/app/javascript/controllers/file-input_controller.js index 4ecdfd356f..7a3c3d3b02 100644 --- a/app/javascript/controllers/file-input_controller.js +++ b/app/javascript/controllers/file-input_controller.js @@ -5,7 +5,7 @@ export default class extends Controller { static targets = ['input', 'name'] connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "file-input-connected"; this.max_size = Number(this.inputTarget.dataset.maxUploadSize); this.error_msg = this.inputTarget.dataset.maxUploadMsg; this.old_callback = this.inputTarget.onchange; diff --git a/app/javascript/controllers/form-images_controller.js b/app/javascript/controllers/form-images_controller.js index b08c398756..83a520ece1 100644 --- a/app/javascript/controllers/form-images_controller.js +++ b/app/javascript/controllers/form-images_controller.js @@ -54,7 +54,7 @@ export default class extends Controller { } connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "form-images-connected"; Object.assign(this, internalConfig); Object.assign(this.localized_text, diff --git a/app/javascript/controllers/geocode_controller.js b/app/javascript/controllers/geocode_controller.js index 1284151180..892b06ee9c 100644 --- a/app/javascript/controllers/geocode_controller.js +++ b/app/javascript/controllers/geocode_controller.js @@ -13,7 +13,7 @@ export default class extends Controller { static outlets = ["autocompleter"] connect() { - this.element.dataset.stimulus = "connected" + this.element.dataset.stimulus = "geocode-connected" // These private vars are for keeping track of user inputs to a form // that should update the form after a timeout. diff --git a/app/javascript/controllers/lazyload_controller.js b/app/javascript/controllers/lazyload_controller.js index b1904eb2fa..bc417a64f5 100644 --- a/app/javascript/controllers/lazyload_controller.js +++ b/app/javascript/controllers/lazyload_controller.js @@ -3,7 +3,7 @@ import { Controller } from "@hotwired/stimulus" // Connects to data-controller="lazyload" export default class extends Controller { connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "lazyload-connected"; if (window.lazyLoadInstance != undefined) window.lazyLoadInstance.update(); diff --git a/app/javascript/controllers/lightgallery_controller.js b/app/javascript/controllers/lightgallery_controller.js index 4e4fda18ce..ca522def36 100644 --- a/app/javascript/controllers/lightgallery_controller.js +++ b/app/javascript/controllers/lightgallery_controller.js @@ -5,7 +5,7 @@ import lgZoom from 'lightgallery/plugins/zoom' // Connects to data-controller="lightgallery", currently "#content" export default class extends Controller { connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "lightgallery-connected"; lightGallery(this.element, { selector: '.theater-btn', diff --git a/app/javascript/controllers/links_controller.js b/app/javascript/controllers/links_controller.js index 4a775a7eb3..c57e95a9b8 100644 --- a/app/javascript/controllers/links_controller.js +++ b/app/javascript/controllers/links_controller.js @@ -3,7 +3,7 @@ import { Controller } from "@hotwired/stimulus" // Connects to data-controller="links" export default class extends Controller { connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "links-connected"; } disable(e) { diff --git a/app/javascript/controllers/matrix-table_controller.js b/app/javascript/controllers/matrix-table_controller.js index 44e3090305..3ab0fac1ee 100644 --- a/app/javascript/controllers/matrix-table_controller.js +++ b/app/javascript/controllers/matrix-table_controller.js @@ -3,7 +3,7 @@ import { Controller } from "@hotwired/stimulus" // Connects to data-controller="matrix-table" export default class extends Controller { connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "matrix-table-connected"; this.matrixBoxes = document.querySelectorAll('.matrix-box') this.boxes = document.querySelectorAll('.matrix-box .panel-sizing') diff --git a/app/javascript/controllers/modal-toggle_controller.js b/app/javascript/controllers/modal-toggle_controller.js index 9290da4a0c..a3ed06b854 100644 --- a/app/javascript/controllers/modal-toggle_controller.js +++ b/app/javascript/controllers/modal-toggle_controller.js @@ -7,10 +7,11 @@ import { get } from "@rails/request.js" // For example, you can start entering a collection number, close the modal, // open a herbarium record form, close it and go back to the collection number // and find the form form as you left it, or vice versa, until you submit. +// Connects to data-controller="modal-toggle" export default class extends Controller { connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "modal-toggle-connected"; this.modalSelector = this.element.dataset.modal this.destination = this.element.getAttribute("href") } diff --git a/app/javascript/controllers/modal_controller.js b/app/javascript/controllers/modal_controller.js index 0740c84292..ea0738fa44 100644 --- a/app/javascript/controllers/modal_controller.js +++ b/app/javascript/controllers/modal_controller.js @@ -7,7 +7,7 @@ export default class extends Controller { connect() { // console.log("Hello Modal " + this.element.id); - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "modal-connected"; } // Modal is only removed in the event that the page section updates. diff --git a/app/javascript/controllers/name-list_controller.js b/app/javascript/controllers/name-list_controller.js index 96738b2c18..609d9a747b 100644 --- a/app/javascript/controllers/name-list_controller.js +++ b/app/javascript/controllers/name-list_controller.js @@ -43,7 +43,7 @@ export default class extends Controller { } connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "name-list-connected"; // These are the div elements for each column. this.DIVS = { diff --git a/app/javascript/controllers/name-panels_controller.js b/app/javascript/controllers/name-panels_controller.js index e6863dfe3b..dfe89a1dbd 100644 --- a/app/javascript/controllers/name-panels_controller.js +++ b/app/javascript/controllers/name-panels_controller.js @@ -7,7 +7,7 @@ export default class extends Controller { static targets = ['classification', 'lifeform'] connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "name-panels-connected"; this.equalizePanelHeights() } diff --git a/app/javascript/controllers/naming-reason_controller.js b/app/javascript/controllers/naming-reason_controller.js index ae878ec301..7431894fba 100644 --- a/app/javascript/controllers/naming-reason_controller.js +++ b/app/javascript/controllers/naming-reason_controller.js @@ -1,8 +1,6 @@ import { Controller } from "@hotwired/stimulus" import { delegate, abnegate } from 'jquery-events-to-dom-events' -// Connects to data-controller="naming-reason" - // https://github.com/leastbad/jquery-events-to-dom-events // We use a Stimulus action that listens to `$shown.bs.collapse` on the div // (note the `$`). This depends on using `delegate` from the imported library @@ -11,11 +9,12 @@ import { delegate, abnegate } from 'jquery-events-to-dom-events' // // If moving to BS 5, can remove. +// Connects to data-controller="naming-reason" export default class extends Controller { static targets = ['collapse', 'input'] connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "naming-reason-connected"; this.delegate = delegate('shown.bs.collapse') } diff --git a/app/javascript/controllers/naming-vote_controller.js b/app/javascript/controllers/naming-vote_controller.js index aeb3123c50..ce4ae2e74f 100644 --- a/app/javascript/controllers/naming-vote_controller.js +++ b/app/javascript/controllers/naming-vote_controller.js @@ -2,6 +2,8 @@ import { Controller } from "@hotwired/stimulus" // Controller deals with naming vote select bindings ** per select. ** // the controller is on the
+ +// Connects to data-controller="naming-vote" export default class extends Controller { static targets = ["select", "submit"] @@ -11,7 +13,7 @@ export default class extends Controller { connect() { // console.log("Hello Modal"); - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "naming-vote-connected"; // The localized text is for the modal progress caption. Object.assign(this.localized_text, JSON.parse(this.element.dataset.localization)); diff --git a/app/javascript/controllers/nav-active_controller.js b/app/javascript/controllers/nav-active_controller.js index 4ff0ebda5f..26780431e2 100644 --- a/app/javascript/controllers/nav-active_controller.js +++ b/app/javascript/controllers/nav-active_controller.js @@ -6,7 +6,7 @@ export default class extends Controller { static targets = ['link'] connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "nav-active-connected"; this.pickActive(); } diff --git a/app/javascript/controllers/nav_controller.js b/app/javascript/controllers/nav_controller.js index 61766e685a..18dd41718d 100644 --- a/app/javascript/controllers/nav_controller.js +++ b/app/javascript/controllers/nav_controller.js @@ -5,7 +5,7 @@ export default class extends Controller { static targets = ['hamburger', 'search', 'container', 'offcanvas', 'topNav'] connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "nav-connected"; } // HAMBURGER HELPER action to toggle offcanvas left nav diff --git a/app/javascript/controllers/reviewed-toggle_controller.js b/app/javascript/controllers/reviewed-toggle_controller.js index 2805c4cdf3..b0e3eb4afc 100644 --- a/app/javascript/controllers/reviewed-toggle_controller.js +++ b/app/javascript/controllers/reviewed-toggle_controller.js @@ -6,7 +6,7 @@ export default class extends Controller { static targets = ['toggle'] connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "reviewed-toggle-connected"; } // https://stackoverflow.com/questions/68624668/how-can-i-submit-a-form-on-input-change-with-turbo-streams diff --git a/app/javascript/controllers/section-update_controller.js b/app/javascript/controllers/section-update_controller.js index 38519e5cf7..f8a5f4b80b 100644 --- a/app/javascript/controllers/section-update_controller.js +++ b/app/javascript/controllers/section-update_controller.js @@ -6,7 +6,7 @@ export default class extends Controller { // this is a handler for page elements that get updated // on successful form submit, so it "cleans up" connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "section-update-connected"; // Note: this is simpler than adding an action on every frame. hides modal this.element.addEventListener("turbo:frame-render", this.updated()); diff --git a/app/javascript/controllers/suggestions_controller.js b/app/javascript/controllers/suggestions_controller.js index f68a978ca1..6838e3dba2 100644 --- a/app/javascript/controllers/suggestions_controller.js +++ b/app/javascript/controllers/suggestions_controller.js @@ -10,7 +10,7 @@ export default class extends Controller { } connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "suggestions-connected"; this.progressModal = document.getElementById("mo_ajax_progress") this.progressCaption = document.getElementById("mo_ajax_progress_caption") diff --git a/app/javascript/controllers/thumbnail-map_controller.js b/app/javascript/controllers/thumbnail-map_controller.js index 508f5d6dc7..b9d7c0dc57 100644 --- a/app/javascript/controllers/thumbnail-map_controller.js +++ b/app/javascript/controllers/thumbnail-map_controller.js @@ -5,7 +5,7 @@ export default class extends Controller { static targets = ["mapContainer", "map", "globe"] connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "thumbnail-map-connected"; this.map_url = this.element.dataset.mapUrl this.coords = JSON.parse(this.element.dataset.coordinates) diff --git a/app/javascript/controllers/translation_controller.js b/app/javascript/controllers/translation_controller.js index 4c646fcee4..9615c72d60 100644 --- a/app/javascript/controllers/translation_controller.js +++ b/app/javascript/controllers/translation_controller.js @@ -8,7 +8,7 @@ export default class extends Controller { ] connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "translate-connected"; this.LOCALE = this.element.dataset.locale; this.CONFIRM_STRING = this.element.dataset.confirmString; diff --git a/app/javascript/controllers/year-input_controller.js b/app/javascript/controllers/year-input_controller.js index 4ed344bce5..b320ea2258 100644 --- a/app/javascript/controllers/year-input_controller.js +++ b/app/javascript/controllers/year-input_controller.js @@ -3,7 +3,7 @@ import { Controller } from "@hotwired/stimulus" // Connects to data-controller="year-input" export default class extends Controller { connect() { - this.element.dataset.stimulus = "connected"; + this.element.dataset.stimulus = "year-input-connected"; this.id = this.element.getAttribute("id"); // console.log(this.id)