You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
994 B
29 lines
994 B
3 years ago
|
import { Controller } from "@hotwired/stimulus"
|
||
|
|
||
|
export default class extends Controller {
|
||
|
static targets = [ "override" ]
|
||
|
|
||
|
initialize() {
|
||
3 years ago
|
let url = window.location.href + "/soft-validations"
|
||
3 years ago
|
let div = this.overrideTarget
|
||
3 years ago
|
fetch(url, { headers: { accept: "application/json" } })
|
||
3 years ago
|
.then(response => response.json())
|
||
|
.then((response) => {
|
||
|
if(response["show"]){
|
||
|
div.style.display = "block"
|
||
|
let innerHTML = div.innerHTML
|
||
|
innerHTML = innerHTML.replace("soft-validations-placeholder-message", response["label"])
|
||
|
innerHTML = innerHTML.replace("soft-validations-placeholder-hint-text", response["hint"])
|
||
|
div.innerHTML = innerHTML
|
||
|
} else {
|
||
|
div.style.display = "none"
|
||
|
let buttons = document.getElementsByName(`case_log[override_net_income_validation][]`)
|
||
|
Object.entries(buttons).map(([idx, button]) => {
|
||
|
button.checked = false
|
||
|
})
|
||
|
}
|
||
3 years ago
|
}
|
||
|
)
|
||
3 years ago
|
}
|
||
|
}
|