2025-12-03 11:42:15 -05:00
|
|
|
import { Controller } from "@hotwired/stimulus"
|
|
|
|
|
|
|
|
|
|
export default class extends Controller {
|
2025-12-10 13:22:33 -05:00
|
|
|
static values = {
|
|
|
|
|
parentColor: String
|
2025-12-03 11:42:15 -05:00
|
|
|
}
|
|
|
|
|
|
2025-12-10 13:22:33 -05:00
|
|
|
static targets = ["template", "container"]
|
|
|
|
|
|
2025-12-03 11:42:15 -05:00
|
|
|
add(event) {
|
|
|
|
|
console.log("start")
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
event.stopPropagation()
|
|
|
|
|
|
2025-12-10 13:22:33 -05:00
|
|
|
const content = this.#updateTemplateException()
|
2025-12-03 11:42:15 -05:00
|
|
|
|
|
|
|
|
this.containerTarget.insertAdjacentHTML("beforeend", content)
|
2025-12-10 13:22:33 -05:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#updateTemplateException() {
|
|
|
|
|
const nextIndex = new Date().getTime()
|
|
|
|
|
console.log("~~ " + this.parentColorValue)
|
|
|
|
|
return this.templateTarget.innerHTML
|
|
|
|
|
.replace(/NEW_EXC_RECORD/g, nextIndex)
|
|
|
|
|
.replace(/PARENT_SECONDARY_COLOR/g, this.parentColorValue)
|
|
|
|
|
|
|
|
|
|
|
2025-12-03 11:42:15 -05:00
|
|
|
}
|
|
|
|
|
}
|