Create bar controller

This commit is contained in:
Stanko K.R.
2025-08-18 15:06:12 +02:00
parent ff48f8a301
commit 9a6fc1f54a
6 changed files with 85 additions and 22 deletions
@@ -0,0 +1,29 @@
import { Controller } from "@hotwired/stimulus"
import { post } from "@rails/request.js"
export default class extends Controller {
static targets = [ "modalTurboFrame" ]
static outlets = [ "dialog" ]
static values = {
searchUrl: String,
searchTurboFrameName: String,
askUrl: String,
askTurboFrameName: String
}
search() {
this.#openInTurboFrame(this.searchTurboFrameNameValue, this.searchUrlValue)
this.dialogOutlet.open()
}
async ask() {
post(this.askUrlValue)
this.#openInTurboFrame(this.askTurboFrameNameValue, this.askUrlValue)
this.dialogOutlet.open()
}
#openInTurboFrame(name, url) {
this.modalTurboFrameTarget.id = name
this.modalTurboFrameTarget.src = url
}
}