Files
baclight/app/javascript/controllers/add_network_exception_controller.js
2025-12-10 13:22:33 -05:00

30 lines
780 B
JavaScript

import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static values = {
parentColor: String
}
static targets = ["template", "container"]
add(event) {
console.log("start")
event.preventDefault()
event.stopPropagation()
const content = this.#updateTemplateException()
this.containerTarget.insertAdjacentHTML("beforeend", content)
}
#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)
}
}