1import { Controller } from "@hotwired/stimulus" 2 3// Connects to data-controller="admin--list-object-outline" 4export default class extends Controller { 5 static targets = [ 6 'itemTypeInput', 'itemTitleSearchInput', 'itemSearchResults', 'insertButton' 7 ] 8 static outlets = [ 'admin--code-editor' ] 9 10 search(event) { 11 const searchQuery = this.itemTitleSearchInputTarget.value 12 const itemType = this.itemTypeInputTarget.value 13 14 if (!searchQuery.trim() || !itemType) { 15 return 16 } 17 18 const params = new URLSearchParams({ 19 admin_search_query: searchQuery, 20 item_type: itemType 21 }) 22 23 Turbo.visit( 24 `/admin/retrieve_outlines/new?${params.toString()}`, 25 { frame: 'itemSearchResultsFrame' } 26 ) 27 } 28 29 handleResultSelection(event) { 30 this.insertButtonTarget.classList.toggle('disabled', !event.target.value) 31 this.adminCodeEditorOutlet.insertValue = `${this.#filterOutline(event.target.value)},` 32 } 33 34 #filterOutline (outline, type = 'link') { 35 const outlineObj = JSON.parse(outline) 36 const parsedOutline = { 37 title: outlineObj.title, 38 path: outlineObj.path, 39 type: type 40 } 41 return JSON.stringify(parsedOutline); 42 } 43}
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.