Skip to content

Commit

Permalink
identify stimulus controllers on connect
Browse files Browse the repository at this point in the history
  • Loading branch information
nimmolo committed Aug 17, 2024
1 parent fdcaa4d commit b112cc3
Show file tree
Hide file tree
Showing 25 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion app/javascript/controllers/advanced-search_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/banner_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } }) {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/donate_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/field-slip-job_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/file-input_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/form-images_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/geocode_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/lazyload_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/lightgallery_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/links_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/matrix-table_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/controllers/modal-toggle_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/modal_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/name-list_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/name-panels_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
5 changes: 2 additions & 3 deletions app/javascript/controllers/naming-reason_controller.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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')
}

Expand Down
4 changes: 3 additions & 1 deletion app/javascript/controllers/naming-vote_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Controller } from "@hotwired/stimulus"

// Controller deals with naming vote select bindings ** per select. **
// the controller is on the <form>

// Connects to data-controller="naming-vote"
export default class extends Controller {
static targets = ["select", "submit"]

Expand All @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/nav-active_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/nav_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/reviewed-toggle_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/section-update_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/suggestions_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/thumbnail-map_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/translation_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/controllers/year-input_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b112cc3

Please sign in to comment.