import { Controller } from "@hotwired/stimulus"; import { GisState } from "../state.js"; import UI from "../ui.js"; const html = String.raw; export default class extends Controller { static values = { 'coords': String, 'group': String, 'id': String, }; static targets = ['search', 'results']; /** * * @param {Event} event */ async submitSearch(event) { event.preventDefault(); const data = new FormData(event.target); const body = {}; for (const entry of data.entries()) { body[entry[0]] = entry[1]; } const response = await fetch("https://caprigis-api.ddev.site:33001/search?" + new URLSearchParams(body)); const results = await response.json(); console.debug(results); this.#injectResults(results); this.#filterMap(results); } #injectResults(results) { /** * @type {HTMLOutputElement} output */ const output = this.resultsTarget; output.innerHTML = ''; for (const result of results) { const item = html`
${result.label}
`; output.innerHTML += item; } } /** * * @param {Array