PageSourceSearch

https://littlebirdelectronics.com.au/assets/controllers/ecommerce/suggestion_link_form_controller-98ef54b2.js

js littlebirdelectronics.com.au collected 2026-09-25 14:11:34 UTC 1,556 bytes, 39 lines download raw bytes

1import { Controller } from "@hotwired/stimulus"
2
3// Drives the "add link" form in the Search Suggestions admin: shows the picker
4// (product / collection / page) or custom-URL field that matches the selected
5// link type, and marks the label as required only for custom links.
6//
7//   <div data-controller="ecommerce--suggestion-link-form">
8//     <select data-ecommerce--suggestion-link-form-target="type"
9//             data-action="change->ecommerce--suggestion-link-form#change">…</select>
10//     <div data-ecommerce--suggestion-link-form-target="product">…</div>
11//     <div data-ecommerce--suggestion-link-form-target="collection">…</div>
12//     <div data-ecommerce--suggestion-link-form-target="page">…</div>
13//     <div data-ecommerce--suggestion-link-form-target="url">…</div>
14//     <input data-ecommerce--suggestion-link-form-target="label">
15//   </div>
16export default class extends Controller {
17  static targets = ["type", "product", "collection", "page", "url", "label"]
18
19  connect() {
20    this.update()
21  }
22
23  change() {
24    this.update()
25  }
26
27  update() {
28    const type = this.hasTypeTarget ? this.typeTarget.value : "product"
29    this.toggle(this.productTargets, type === "product")
30    this.toggle(this.collectionTargets, type === "collection")
31    this.toggle(this.pageTargets, type === "page")
32    this.toggle(this.urlTargets, type === "custom")
33    if (this.hasLabelTarget) this.labelTarget.required = type === "custom"
34  }
35
36  toggle(elements, show) {
37    elements.forEach((el) => el.classList.toggle("hidden", !show))
38  }
39}

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.