Skip to content

Commit

Permalink
Implements UIBehavior in A2 form
Browse files Browse the repository at this point in the history
  • Loading branch information
Oddvocado committed Aug 31, 2023
1 parent 88df972 commit 7b3b075
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 17 deletions.
32 changes: 16 additions & 16 deletions src/UDS.Net.Forms/Pages/UDS3/A2.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<label class="text-base font-semibold text-gray-900" asp-for="A2.INHISP"><span class="counter"></span><span class="counter invisible"></span> @Html.DisplayNameFor(model => model.A2.INHISP)</label>
<div class="mt-4 sm:col-span-2 sm:mt-0">
<p class="text-sm text-gray-500" asp-description-for="A2.INHISP"></p>
<radio-button-group id="A2_INHISP" for="@Model.A2.INHISP" items="Model.HispanicLatinoListItems"></radio-button-group>
<radio-button-group id="A2_INHISP" for="@Model.A2.INHISP" items="Model.HispanicLatinoListItems" ui-behaviors="Model.HispanicLatinoUIBehavior"></radio-button-group>
<span class="mt-2 text-sm text-red-600" asp-validation-for="A2.INHISP"></span>
</div>
</div>
Expand All @@ -60,7 +60,7 @@
<label class="text-base font-semibold text-gray-900" asp-for="A2.INHISPOR"><span class="counter"></span><span class="counter invisible"></span> @Html.DisplayNameFor(model => model.A2.INHISPOR)</label>
<div>
<p asp-description-for="A2.INHISPOR"></p>
<radio-button-group id="A2_INHISPOR" for="@Model.A2.INHISPOR" items="Model.OriginsListItems"></radio-button-group>
<radio-button-group id="A2_INHISPOR" for="@Model.A2.INHISPOR" items="Model.OriginsListItems" ui-behaviors="Model.OriginsUIBehavior"></radio-button-group>
<span class="mt-2 text-sm text-red-600" asp-validation-for="A2.INHISPOR"></span>
</div>
<div>
Expand All @@ -77,7 +77,7 @@
<label asp-for="A2.INRACE" class="text-base font-semibold text-gray-900"><span class="counter"></span> @Html.DisplayNameFor(model => model.A2.INRACE)</label>
<div>
<p class="text-sm text-gray-500" asp-description-for="@Model.A2.INRACE"></p>
<radio-button-group id="A2_INRACE" for="@Model.A2.INRACE" items="Model.RacialGroupsListItems"></radio-button-group>
<radio-button-group id="A2_INRACE" for="@Model.A2.INRACE" items="Model.RacialGroupsListItems" ui-behaviors = "Model.RacialGroupsUIBehavior"></radio-button-group>
<span class="mt-2 text-sm text-red-600" asp-validation-for="@Model.A2.INRACE"></span>
</div>
<div class="mt-4 space-y-4">
Expand All @@ -94,33 +94,33 @@
<label asp-for="A2.INRASEC" class="text-base font-semibold text-gray-900"><span class="counter"></span> @Html.DisplayNameFor(model => model.A2.INRASEC)</label>
<div>
<p class="text-sm text-gray-500" asp-description-for="@Model.A2.INRASEC"></p>
<radio-button-group id="A2_INRASEC" for="@Model.A2.INRASEC" items="Model.RacialGroupsListItems"></radio-button-group>
<radio-button-group id="A2_INRASEC" for="@Model.A2.INRASEC" items="Model.AdditionalRacialGroupsListItems" ui-behaviors="Model.AdditionalRacialGroupsUIBehavior"></radio-button-group>
<span class="mt-2 text-sm text-red-600" asp-validation-for="@Model.A2.INRASEC"></span>
</div>
<div class="mt-4 space-y-4">
<p class="text-sm text-gray-500" asp-description-for="@Model.A2.INRACEX"></p>
<label asp-for="@Model.A2.INRACEX">@Html.DisplayNameFor(m => m.A2.INRACEX)</label>
<p class="text-sm text-gray-500" asp-description-for="@Model.A2.INRASECX"></p>
<label asp-for="@Model.A2.INRASECX">@Html.DisplayNameFor(m => m.A2.INRASECX)</label>
<div class="mt-2">
<input asp-for="@Model.A2.INRACEX" />
<input asp-for="@Model.A2.INRASECX" />
</div>
<span class="mt-2 text-sm text-red-600" asp-validation-for="@Model.A2.INRACEX"></span>
<span class="mt-2 text-sm text-red-600" asp-validation-for="@Model.A2.INRASECX"></span>
</div>
</div>

<div class="@rowCSS">
<label asp-for="A2.INRATER"><span class="counter"></span> @Html.DisplayNameFor(model => model.A2.INRATER)</label>
<div>
<p class="text-sm text-gray-500" asp-description-for="A2.INRATER"></p>
<radio-button-group id="RacialGroupsTertiary" for="@Model.A2.INRATER" items="Model.RacialGroupsListItems"></radio-button-group>
<radio-button-group id="RacialGroupsTertiary" for="@Model.A2.INRATER" items="Model.RacialGroupsListItems" ui-behaviors="Model.BeyondAdditionalRacialGroupsUIBehavior"></radio-button-group>
<span class="mt-2 text-sm text-red-600" asp-validation-for="@Model.A2.INRATER"></span>
</div>
<div class="mt-4 space-y-4">
<p class="text-sm text-gray-500" asp-description-for="A2.INRATER"></p>
<label asp-for="@Model.A2.INRATER">@Html.DisplayNameFor(m => m.A2.INRATER)</label>
<p class="text-sm text-gray-500" asp-description-for="A2.INRATERX"></p>
<label asp-for="@Model.A2.INRATERX">@Html.DisplayNameFor(m => m.A2.INRATERX)</label>
<div class="mt-2">
<input asp-for="@Model.A2.INRATER" />
<input asp-for="@Model.A2.INRATERX" />
</div>
<span class="mt-2 text-sm text-red-600" asp-validation-for="@Model.A2.INRATER"></span>
<span class="mt-2 text-sm text-red-600" asp-validation-for="@Model.A2.INRATERX"></span>
</div>
</div>

Expand Down Expand Up @@ -157,7 +157,7 @@

<div class="mt-4 sm:col-span-2 sm:mt-0">
<p class="text-sm text-gray-500" asp-description-for="A2.INLIVWTH"></p>
<radio-button-group id="A2_INLIVWTH" for="@Model.A2.INLIVWTH" items="Model.LivingSituationListItems"></radio-button-group>
<radio-button-group id="A2_INLIVWTH" for="@Model.A2.INLIVWTH" items="Model.LivingSituationListItems" ui-behaviors="Model.LivingSituationUIBehavior"></radio-button-group>
<span class="mt-2 text-sm text-red-600" asp-validation-for="A2.INLIVWTH"></span>
</div>
</div>
Expand All @@ -167,7 +167,7 @@

<div class="mt-4 sm:col-span-2 sm:mt-0">
<p class="text-sm text-gray-500" asp-description-for="A2.INVISITS"></p>
<radio-button-group id="A2_INVISITS" for="@Model.A2.INVISITS" items="Model.ContactFrequencyListItems"></radio-button-group>
<radio-button-group id="A2_INVISITS" for="@Model.A2.INVISITS" items="Model.VisitContactFrequencyListItems" ui-behaviors="Model.VisitContactFrequencyUIBehavior"></radio-button-group>
<span class="mt-2 text-sm text-red-600" asp-validation-for="A2.INVISITS"></span>
</div>
</div>
Expand All @@ -177,7 +177,7 @@

<div class="mt-4 sm:col-span-2 sm:mt-0">
<p class="text-sm text-gray-500" asp-description-for="A2.INCALLS"></p>
<radio-button-group id="A2_INCALLS" for="@Model.A2.INCALLS" items="Model.ContactFrequencyListItems"></radio-button-group>
<radio-button-group id="A2_INCALLS" for="@Model.A2.INCALLS" items="Model.VisitContactFrequencyListItems"></radio-button-group>
<span class="mt-2 text-sm text-red-600" asp-validation-for="A2.INCALLS"></span>
</div>
</div>
Expand Down
110 changes: 109 additions & 1 deletion src/UDS.Net.Forms/Pages/UDS3/A2.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public class A2Model : FormPageModel
new RadioListItem("Yes", "2"),
new RadioListItem("Unknown (If Unknown, SKIP TO QUESTION below)", "9")
};
public Dictionary<string, UIBehavior> HispanicLatinoUIBehavior = new Dictionary<string, UIBehavior>
{
{ "1", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INHISPOR") } },
{ "2", new UIBehavior { PropertyAttribute = new UIEnableAttribute("A2.INHISPOR") } },
{ "9", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INHISPOR") } }
};

public List<RadioListItem> OriginsListItems { get; } = new List<RadioListItem>
{
Expand All @@ -44,6 +50,18 @@ public class A2Model : FormPageModel
new RadioListItem("Unknown","99")
};

public Dictionary<string, UIBehavior> OriginsUIBehavior = new Dictionary<string, UIBehavior>
{
{ "1", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INHISPOX") } },
{ "2", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INHISPOX") } },
{ "3", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INHISPOX") } },
{ "4", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INHISPOX") } },
{ "5", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INHISPOX") } },
{ "6", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INHISPOX") } },
{ "50", new UIBehavior { PropertyAttribute = new UIEnableAttribute("A2.INHISPOX") } },
{ "99", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INHISPOX") } }

};
public List<RadioListItem> RacialGroupsListItems { get; } = new List<RadioListItem>
{
new RadioListItem("White", "1"),
Expand All @@ -55,6 +73,66 @@ public class A2Model : FormPageModel
new RadioListItem("Unknown", "99")
};


public Dictionary<string, UIBehavior> RacialGroupsUIBehavior = new Dictionary<string, UIBehavior>
{
{ "1", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRACEX") } },
{ "2", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRACEX") } },
{ "3", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRACEX") } },
{ "4", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRACEX" ) } },
{ "5", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRACEX") } },
{ "50", new UIBehavior { PropertyAttribute = new UIEnableAttribute("A2.INRACEX") } },
{ "99", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRACEX") } },

};

public List<RadioListItem> AdditionalRacialGroupsListItems { get; } = new List<RadioListItem>
{
new RadioListItem("White", "1"),
new RadioListItem("Black or African American", "2"),
new RadioListItem("American Indian or Alaska Native", "3"),
new RadioListItem("Native Hawaiian or other Pacific Islander", "4"),
new RadioListItem("Asian", "5"),
new RadioListItem("Other (specify)", "50"),
new RadioListItem("Unknown", "99")
};

public Dictionary<string, UIBehavior> AdditionalRacialGroupsUIBehavior = new Dictionary<string, UIBehavior>
{
{ "1", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRASECX") } },
{ "2", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRASECX") } },
{ "3", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRACEX") } },
{ "4", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRASECX" ) } },
{ "5", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRASECX") } },
{ "50", new UIBehavior { PropertyAttribute = new UIEnableAttribute("A2.INRASECX") } },
{ "99", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRASECX") } },

};

public List<RadioListItem> BeyondAdditionalRacialGroupsListItems { get; } = new List<RadioListItem>
{
new RadioListItem("White", "1"),
new RadioListItem("Black or African American", "2"),
new RadioListItem("American Indian or Alaska Native", "3"),
new RadioListItem("Native Hawaiian or other Pacific Islander", "4"),
new RadioListItem("Asian", "5"),
new RadioListItem("Other (specify)", "50"),
new RadioListItem("Unknown", "99")
};

public Dictionary<string, UIBehavior> BeyondAdditionalRacialGroupsUIBehavior = new Dictionary<string, UIBehavior>
{
{ "1", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRATERX") } },
{ "2", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRATERX") } },
{ "3", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRATERX") } },
{ "4", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRATERX" ) } },
{ "5", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRATERX") } },
{ "50", new UIBehavior { PropertyAttribute = new UIEnableAttribute("A2.INRATERX") } },
{ "99", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INRATERX") } },

};


public List<RadioListItem> RelationshipTypesListItems { get; } = new List<RadioListItem>
{
new RadioListItem("Spouse, partner, or companion (include ex-spouse, ex-partner, fiancé, boyfriend, girlfriend)", "1"),
Expand All @@ -71,7 +149,37 @@ public class A2Model : FormPageModel
new RadioListItem("Yes (If Yes, SKIP TO QUESTION 10)", "1")
};

public List<RadioListItem> ContactFrequencyListItems { get; } = new List<RadioListItem>
public Dictionary<string, UIBehavior> LivingSituationUIBehavior = new Dictionary<string, UIBehavior>
{

{ "0", new UIBehavior { PropertyAttribute = new UIEnableAttribute("A2.INVISITS") } },
{ "1", new UIBehavior { PropertyAttribute = new UIDisableAttribute("A2.INVISITS") } },

};

public List<RadioListItem> VisitContactFrequencyListItems { get; } = new List<RadioListItem>
{
new RadioListItem("Daily", "1"),
new RadioListItem("At least 3 times per week", "2"),
new RadioListItem("Weekly", "3"),
new RadioListItem("At least three times per month", "4"),
new RadioListItem("Monthly", "5"),
new RadioListItem("Less than once a month", "6"),
};

public Dictionary<string, UIBehavior> VisitContactFrequencyUIBehavior = new Dictionary<string, UIBehavior>
{

{ "1", new UIBehavior { PropertyAttribute = new UIEnableAttribute("A2.INCALLS") } },
{ "2", new UIBehavior { PropertyAttribute = new UIEnableAttribute("A2.INCALLS") } },
{ "3", new UIBehavior { PropertyAttribute = new UIEnableAttribute("A2.INCALLS") } },
{ "4", new UIBehavior { PropertyAttribute = new UIEnableAttribute("A2.INCALLS") } },
{ "5", new UIBehavior { PropertyAttribute = new UIEnableAttribute("A2.INCALLS") } },
{ "6", new UIBehavior { PropertyAttribute = new UIEnableAttribute("A2.INCALLS") } },

};

public List<RadioListItem> TelephoneContactFrequencyListItems { get; } = new List<RadioListItem>
{
new RadioListItem("Daily", "1"),
new RadioListItem("At least 3 times per week", "2"),
Expand Down

0 comments on commit 7b3b075

Please sign in to comment.