Skip to content

Commit

Permalink
Push local changes, adjustments to feature
Browse files Browse the repository at this point in the history
  • Loading branch information
mlan225 committed Jan 31, 2025
1 parent a9e120a commit 2c99c5b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/UDS.Net.Forms/Pages/UDS4/B6.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<div class="space-y-5">
<div class="relative flex items-start">
<div class="flex h-6 items-center">
@Html.CheckBox("B6.NOGDS", Model.B6.NOGDS, new { @class = "h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600", @data_action="input->b6#NOGDSBehavior" })
@Html.CheckBox("B6.NOGDS", Model.B6.NOGDS, new { @class = "h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600", @data_b6_target="NOGDSInput", @data_action="input->b6#NOGDSBehavior" })
</div>
<div class="ml-3 text-sm leading-6">
<label asp-for="B6.NOGDS" class="font-medium text-gray-900">@Html.DisplayNameFor(m => m.B6.NOGDS)</label>
Expand Down Expand Up @@ -169,7 +169,7 @@
<label asp-for="B6.GDS"><span class="counter"></span> @Html.DisplayNameFor(m => m.B6.GDS)</label>
<div class="mt-4 sm:col-span-2 sm:mt-0">
<p class="text-sm text-gray-500" asp-description-for="@Model.B6.GDS"></p>
<input asp-for="@Model.B6.GDS" data-b6-target="GDSInput"/>
<input readonly asp-for="@Model.B6.GDS" data-b6-target="GDSInput"/>
<span class="italic text-gray-500">(max score =15; did not complete = 88)</span>
<div>
<span class="mt-2 text-sm text-red-600" asp-validation-for="B6.GDS"></span>
Expand Down
20 changes: 16 additions & 4 deletions src/UDS.Net.Forms/wwwroot/js/js_controllers/b6_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ export default class extends Controller {

static targets = [
"radioTable",
"GDSInput"
"GDSInput",
"NOGDSInput"
]

connect() {
connect() {
this.CreateRadioButtonEvents()
this.CalculateGDS()
this.NOGDSBehavior()
}

CalculateGDS() {
Expand Down Expand Up @@ -40,9 +42,19 @@ export default class extends Controller {
}

//GDS must be 88 if NOGDS checkbox is checked. Auto set for user on check
NOGDSBehavior(event) {
if (event.target.checked) {
NOGDSBehavior() {
if (this.NOGDSInputTarget.checked) {
this.GDSInputTarget.value = 88
this.radioTableTarget.querySelectorAll('input[type="radio"]').forEach((radio) => {
radio.disabled = true
})
} else {
this.radioTableTarget.querySelectorAll('input[type="radio"]').forEach((radio) => {
radio.disabled = false
})

//recalculate GDS with enabled radios
this.CalculateGDS()
}
}
}

0 comments on commit 2c99c5b

Please sign in to comment.