Skip to content

Commit

Permalink
Add required input check for screenWithOneInput
Browse files Browse the repository at this point in the history
  • Loading branch information
spokenbird authored and coltborg committed Feb 21, 2024
1 parent caedcbc commit 9d5cde8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
13 changes: 11 additions & 2 deletions intellij-settings/LiveTemplates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
<option name="HTML" value="true" />
</context>
</template>
<template name="cfa:checkbox" value="&lt;th:block th:replace=&quot;~{fragments/inputs/checkbox ::&#10; checkbox(inputName='$INPUT_NAME$',&#10; label=#{$LABEL$},&#10; value=#{$VALUE$},&#10; helpText=#{$CHECKBOX_HELP_TEXT$})}&quot;/&gt;" description="A field checkbox with label, name, optional help text and optional icon" toReformat="false" toShortenFQNames="true">
<variable name="INPUT_NAME" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="VALUE" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="LABEL" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="CHECKBOX_HELP_TEXT" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="HTML" value="true" />
</context>
</template>
<template name="cfa:conditionMethod" value="public static Boolean $METHOD_NAME$(Submission submission) {&#10; if (submission.getInputData().containsKey(&quot;$FIELD_NAME$&quot;)) {&#10; // Change logic to suit your needs&#10; return submission.getInputData().get(&quot;$FIELD_NAME$&quot;)$CURSOR$;&#10; }&#10; return false;&#10;}" description="Create a condition method that first check for db field existance then your conditional logic" toReformat="false" toShortenFQNames="true">
<variable name="METHOD_NAME" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="FIELD_NAME" expression="" defaultValue="" alwaysStopAt="true" />
Expand Down Expand Up @@ -241,7 +250,7 @@
<option name="HTML" value="true" />
</context>
</template>
<template name="cfa:screenWithOneInput" value="&lt;th:block&#10; th:replace=&quot;~{fragments/screens/screenWithOneInput ::&#10; screenWithOneInput(&#10; title=#{$TITLE$},&#10; header=#{$HEADER$},&#10; subtext=#{$SUBTEXT$},&#10; formAction=${formAction},&#10; inputContent=~{::inputContent})}&quot;&gt;&#10; &lt;th:block th:ref=&quot;inputContent&quot;&gt;&#10; &lt;!-- Be sure to have `ariaLabel='header'` to label the input with the header --&gt;&#10; &lt;th:block th:replace=&quot;~{fragments/inputs/text ::&#10; text(inputName='$INPUT_NAME$',&#10; ariaLabel='header')}&quot;/&gt;&#10; &lt;/th:block&gt;&#10;&lt;/th:block&gt;" description="An entire screen that has one input and is labelled by the page header." toReformat="false" toShortenFQNames="true">
<template name="cfa:screenWithOneInput" value="&lt;th:block&#10; th:replace=&quot;~{fragments/screens/screenWithOneInput ::&#10; screenWithOneInput(&#10; title=#{$TITLE$},&#10; header=#{$HEADER$},&#10; inputName='$INPUT_NAME$',&#10; subtext=#{$SUBTEXT$},&#10; formAction=${formAction},&#10; inputContent=~{::inputContent})}&quot;&gt;&#10; &lt;th:block th:ref=&quot;inputContent&quot;&gt;&#10; &lt;!-- Be sure to have `ariaLabel='header'` to label the input with the header --&gt;&#10; &lt;th:block th:replace=&quot;~{fragments/inputs/text ::&#10; text(inputName='$INPUT_NAME$',&#10; ariaLabel='header')}&quot;/&gt;&#10; &lt;/th:block&gt;&#10;&lt;/th:block&gt;" description="An entire screen that has one input and is labelled by the page header." toReformat="false" toShortenFQNames="true">
<variable name="TITLE" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="HEADER" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="SUBTEXT" expression="" defaultValue="" alwaysStopAt="true" />
Expand Down Expand Up @@ -315,4 +324,4 @@
<context>
<option name="HTML" value="true" />
</context>
</template>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<header
th:fragment="cardHeaderForSingleInputScreen"
th:with="
hasSubtext=${!#strings.isEmpty(subtext)},
isRequiredInput=${requiredInputs.getOrDefault(inputName, false)}"
th:assert="${!#strings.isEmpty(header)}"
class="form-card__header">
<h1 id="header" class="h2" >
<span th:text="${header}"></span>
<span th:if="${isRequiredInput}" class="required-input" aria-hidden="true">*</span>
</h1>
<p id="header-help-message"
th:if="${hasSubtext}"
th:utext="${subtext}"></p>
</header>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
<main id="content" role="main" class="form-card spacing-above-35">
<th:block th:replace="${hasIconName} ? ~{'fragments/icons' :: ${iconName}} : _" />
<th:block
th:replace="~{fragments/cardHeader :: cardHeader(header=${header}, subtext=${subtext})}"/>
th:replace="~{fragments/cardHeaderForSingleInputScreen ::
cardHeaderForSingleInputScreen(header=${header}, subtext=${subtext}, inputName=${inputName})}"/>
<th:block
th:replace="~{fragments/form :: form(action=${formAction}, content=~{::formContent})}">
<th:block th:ref="formContent">
Expand Down

0 comments on commit 9d5cde8

Please sign in to comment.