PageSourceSearch

https://bikeindex.org/assets/controllers/register/propulsion_contr…5094620b6319ee9713702cdaded5a20eb8d36f3f.js

js bikeindex.org collected 2026-10-01 10:24:39 UTC 1,074 bytes, 27 lines download raw bytes

1import { Controller } from '@hotwired/stimulus'
2
3// Connects to data-controller='register--propulsion'
4//
5// Mirrors the registration embed's UpdatePropulsionType: the electric checkbox
6// is forced on/off (and disabled) for always/never-motorized vehicle types.
7export default class extends Controller {
8  static targets = ['motorized', 'motorizedWrapper']
9  static values = { alwaysMotorized: Array, neverMotorized: Array }
10
11  // Modules load lazily, so this one can arrive after the selection - or after
12  // form-persist has announced the restore that filled the combobox
13  connect () {
14    this.update()
15  }
16
17  update = () => {
18    const cycleType = this.element.querySelector('input[name$="[cycle_type]"]')?.value
19    const forced = this.alwaysMotorizedValue.includes(cycleType)
20      ? true
21      : (this.neverMotorizedValue.includes(cycleType) ? false : null)
22
23    if (forced !== null) this.motorizedTarget.checked = forced
24    this.motorizedTarget.disabled = forced !== null
25    this.motorizedWrapperTarget.classList.toggle('tw:opacity-60', forced !== null)
26  }
27};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.