automate employer setup import from word and manual entry working
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static values = {
|
||||
formColor: { type: Array, default: [] } // Declares 'items' as an Array value
|
||||
}
|
||||
static targets = ["template", "container", "plan", "button"]
|
||||
|
||||
add(event) {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
|
||||
const content = this.#updateTemplatePlan()
|
||||
|
||||
this.buttonTarget.insertAdjacentHTML("beforebegin", content)
|
||||
|
||||
}
|
||||
|
||||
#updateTemplatePlan() {
|
||||
const nextIndex = this.planTargets.length
|
||||
const num_of_colors = this.formColorValue.length
|
||||
let colorIndex = 0
|
||||
if (nextIndex != 0) {
|
||||
colorIndex = nextIndex % num_of_colors
|
||||
}
|
||||
const newColor = this.formColorValue[colorIndex]
|
||||
return this.templateTarget.innerHTML
|
||||
.replace(/NEW_RECORD/g, nextIndex)
|
||||
.replace(/NEW_PLAN/g, nextIndex + 1)
|
||||
.replace(/NEXT_COLOR/g, newColor)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user