Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
59454d9
LG-5040: refactor text field
mdiarra3 Sep 22, 2021
d0eb3f3
Merge remote-tracking branch 'origin/main' into md-lg-5040-refactor-t…
mdiarra3 Sep 23, 2021
6cd90b1
add inline js
mdiarra3 Sep 24, 2021
cd90262
validation html
mdiarra3 Sep 24, 2021
9759f1e
LG-5040: refactor text field
mdiarra3 Sep 28, 2021
260e3f3
LG-5040: add inline validation
mdiarra3 Oct 1, 2021
046fefd
Merge remote-tracking branch 'origin/main' into md-lg-5040-refactor-t…
mdiarra3 Oct 1, 2021
cf9fc9a
LG-5040: validation yaml fixes
mdiarra3 Oct 1, 2021
a8a918a
Merge remote-tracking branch 'origin/main' into md-lg-5040-refactor-t…
mdiarra3 Oct 1, 2021
26b4c0b
LG-5040: updated inputs for inline-validation
mdiarra3 Oct 1, 2021
fde1b02
LG-5040: leverage css more
mdiarra3 Oct 4, 2021
ea6bad9
Merge remote-tracking branch 'origin/main' into md-lg-5040-refactor-t…
mdiarra3 Oct 4, 2021
a683928
LG-5040: fix linting issue
mdiarra3 Oct 4, 2021
4009f7e
LG-5040: lint fixes
mdiarra3 Oct 4, 2021
e9b0d1e
LG-5040: update spec to make sure its properly setting aria invalid p…
mdiarra3 Oct 4, 2021
7c27911
LG-5040: clean up styling, remove error-state css class
mdiarra3 Oct 6, 2021
8a6031c
LG-5040: lint fix
mdiarra3 Oct 6, 2021
96ca325
LG-5040: add validation to send link and verify account
mdiarra3 Oct 12, 2021
8e37a80
LG-5040: madd spacing
mdiarra3 Oct 12, 2021
cc1bcbe
LG-5040: update styling
mdiarra3 Oct 12, 2021
22266b9
Merge remote-tracking branch 'origin/main' into md-lg-5040-refactor-t…
mdiarra3 Oct 12, 2021
7911de7
LG-5040: add padding
mdiarra3 Oct 13, 2021
462e966
LG-5157: address invalidation inline
mdiarra3 Oct 14, 2021
596ff89
Merge remote-tracking branch 'origin/main' into md-lg-5040-refactor-t…
mdiarra3 Oct 15, 2021
9900074
Merge remote-tracking branch 'origin/md-lg-5040-refactor-text-field' …
mdiarra3 Oct 18, 2021
09131a2
LG-5157: address line validation
mdiarra3 Oct 18, 2021
8c0fbaf
Merge remote-tracking branch 'origin/main' into md-lg-5040-refactor-t…
mdiarra3 Oct 18, 2021
f0b972d
Merge remote-tracking branch 'origin/md-lg-5040-refactor-text-field' …
mdiarra3 Oct 18, 2021
54da400
Merge remote-tracking branch 'origin/main' into md-lg-5157-address-in…
mdiarra3 Oct 18, 2021
cc8c457
Merge remote-tracking branch 'origin/main' into md-lg-5157-address-in…
mdiarra3 Oct 20, 2021
fe906f9
LG-5157: add new address inline validation
mdiarra3 Oct 20, 2021
b8a32f6
LG-5157: fix up html
mdiarra3 Oct 20, 2021
685e0b1
LG-5157: fix linting issue
mdiarra3 Oct 20, 2021
e1c7017
LG-5157: update spec file
mdiarra3 Oct 20, 2021
5186706
update spacing
mdiarra3 Oct 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions app/javascript/packs/form-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { loadPolyfills } from '@18f/identity-polyfill';
/** @typedef {{t:(key:string)=>string, key:(key:string)=>string}} LoginGovI18n */
/** @typedef {{LoginGov:{I18n:LoginGovI18n}}} LoginGovGlobal */

const PATTERN_TYPES = ['personal-key', 'ssn', 'zipcode'];
const PATTERN_TYPES = ['personal-key', 'ssn'];

const snakeCase = (string) => string.replace(/[ -]/g, '_').replace(/\W/g, '').toLowerCase();

Expand Down Expand Up @@ -60,8 +60,6 @@ function checkInputValidity(event) {
PATTERN_TYPES.forEach((type) => {
if (input.classList.contains(type)) {
// i18n-tasks-use t('idv.errors.pattern_mismatch.personal_key')
// i18n-tasks-use t('idv.errors.pattern_mismatch.ssn')
// i18n-tasks-use t('idv.errors.pattern_mismatch.zipcode')
input.setCustomValidity(I18n.t(`idv.errors.pattern_mismatch.${snakeCase(type)}`));
}
});
Expand Down
31 changes: 24 additions & 7 deletions app/views/idv/address/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,40 @@
:idv_form, url: idv_address_path, method: 'POST',
html: {autocomplete: 'off', class: 'margin-top-2'}
) do |f| %>

<%= f.input :address1, label: t('idv.form.address1'), wrapper_html: {class: 'margin-bottom-1'},
required: true, maxlength: 255, input_html: { aria: { invalid: false }, value: @pii['address1'] } %>
<div class="margin-bottom-4">
<%= f.input :address1, label: t('idv.form.address1'), wrapper: false,
required: true, maxlength: 255, input_html: { aria: { invalid: false }, value: @pii['address1'] } %>
<span class='usa-error-message margin-top-1 display-if-invalid display-if-invalid--value-missing margin-bottom-1' role='alert'>
<%= t('simple_form.required.text') %>
</span>
</div>
<%= f.input :address2, label: t('idv.form.address2'), required: false, maxlength: 255,
input_html: { value: @pii['address2'] } %>
<%= f.input :city, label: t('idv.form.city'), required: true, maxlength: 255,
input_html: { aria: { invalid: false }, value: @pii['city'] } %>
<div class="margin-bottom-4">
<%= f.input :city, label: t('idv.form.city'), required: true, maxlength: 255, wrapper: false,
input_html: { aria: { invalid: false }, class: 'usa-input', value: @pii['city'] } %>
<span class='usa-error-message margin-top-1 display-if-invalid display-if-invalid--value-missing margin-bottom-1' role='alert'>
<%= t('simple_form.required.text') %>
</span>
</div>

<%= f.input :state, collection: us_states_territories,
label: t('idv.form.state'), required: true,
selected: @pii['state'] %>
<div class="tablet:grid-col-6">
<div class="tablet:grid-col-6 margin-bottom-4">
<%# using :tel for mobile numeric keypad %>
<%= f.input :zipcode, as: :tel,
label: t('idv.form.zipcode'), required: true,
pattern: '(\d{5}([\-]\d{4})?)',
input_html: { aria: { invalid: false }, class: 'zipcode', value: @pii['zipcode'] } %>
wrapper: false,
input_html: { aria: { invalid: false }, class: 'usa-input', value: @pii['zipcode'] } %>
<span class='usa-error-message margin-top-1 display-if-invalid display-if-invalid--value-missing margin-bottom-1' role='alert'>
<%= t('simple_form.required.text') %>
</span>

<span class='usa-error-message margin-top-1 pattern-mismatch display-if-invalid display-if-invalid--pattern-mismatch margin-bottom-1' role='alert'>
<%= t('idv.errors.pattern_mismatch.zipcode') %>
</span>
</div>
<div class="margin-top-0">
<button type="submit" class="usa-button usa-button--big usa-button--wide margin-top-2">
Expand Down
28 changes: 23 additions & 5 deletions app/views/idv/gpo/_new_address.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@
html: { autocomplete: 'off', class: 'margin-top-2' }
) do |f| %>

<%= f.input :address1, label: t('idv.form.address1'), wrapper_html: { class: 'margin-bottom-1' },
required: true, input_html: { aria: { invalid: false } }, maxlength: 255 %>
<div class="margin-bottom-4">
<%= f.input :address1, label: t('idv.form.address1'), wrapper: false,
required: true, input_html: { aria: { invalid: false } }, maxlength: 255 %>
<span class='usa-error-message margin-top-1 display-if-invalid display-if-invalid--value-missing margin-bottom-1' role='alert'>
<%= t('simple_form.required.text') %>
</span>
</div>
<%= f.input :address2, label: t('idv.form.address2'), required: false, maxlength: 255 %>
<%= f.input :city, label: t('idv.form.city'), required: true, maxlength: 255 %>

<div class="margin-bottom-4">
<%= f.input :city, label: t('idv.form.city'), wrapper: false, required: true, maxlength: 255 %>
<span class='usa-error-message margin-top-1 display-if-invalid display-if-invalid--value-missing margin-bottom-1' role='alert'>
<%= t('simple_form.required.text') %>
</span>
</div>

<div class="clearfix margin-x-neg-1">
<div class="sm-col sm-col-8 padding-x-1">
Expand All @@ -20,8 +31,15 @@
<%# using :tel for mobile numeric keypad %>
<%= f.input :zipcode, as: :tel,
label: t('idv.form.zipcode'), required: true,
pattern: '(\d{5}([\-]\d{4})?)',
input_html: { class: 'zipcode' } %>
wrapper: false,
pattern: '(\d{5}([\-]\d{4})?)' %>
<span class='usa-error-message margin-top-1 display-if-invalid display-if-invalid--value-missing margin-bottom-1' role='alert'>
<%= t('simple_form.required.text') %>
</span>

<span class='usa-error-message margin-top-1 pattern-mismatch display-if-invalid display-if-invalid--pattern-mismatch margin-bottom-1' role='alert'>
<%= t('idv.errors.pattern_mismatch.zipcode') %>
</span>
</div>
</div>
<div class="margin-top-0">
Expand Down
2 changes: 1 addition & 1 deletion config/locales/idv/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ en:
personal_key: 'Please enter your personal key for this account. Example:
ABC1-DEF2-G3HI-J456'
ssn: 'Your Social Security Number must be entered in as ###-##-####'
zipcode: 'Your zipcode must be entered in as #####-####'
zipcode: Enter a 5 or 9 digit ZIP code
unsupported_otp_delivery_method: Select a method to receive a code.
failure:
attempts:
Expand Down
2 changes: 1 addition & 1 deletion config/locales/idv/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ es:
personal_key: 'Introduzca su clave personal para esta cuenta. Ejemplo:
ABC1-DEF2-G3HI-J456'
ssn: 'Su número de Seguro Social debe ser ingresado como ### - ## - ####'
zipcode: 'Su código postal debe ser ingresado como #####-####'
zipcode: Ingresa un código postal de 5 o 9 dígitos
unsupported_otp_delivery_method: Seleccione una manera de recibir un código.
failure:
attempts:
Expand Down
2 changes: 1 addition & 1 deletion config/locales/idv/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fr:
exemple : ABC1-DEF2-G3HI-J456'
ssn: 'Votre numéro de sécurité sociale doit être inscrit de cette façon :
###-##-####'
zipcode: 'Votre code ZIP doit être inscrit de cette façon : #####-####'
zipcode: Entrez un code postal à 5 ou 9 chiffres
unsupported_otp_delivery_method: Sélectionnez une méthode pour recevoir un code.
failure:
attempts:
Expand Down
5 changes: 0 additions & 5 deletions spec/javascripts/packs/form-validation-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ describe('form-validation', () => {
<input type="text" aria-label="required field" required class="field">
<input type="text" aria-label="format" pattern="\\\\A\\\\d{5}(-?\\\\d{4})?\\\\z">
<input type="text" aria-label="format unknown field" pattern="\\\\A\\\\d{5}(-?\\\\d{4})?\\\\z" class="field">
<input type="text" aria-label="format field" pattern="\\\\A\\\\d{5}(-?\\\\d{4})?\\\\z" class="field zipcode">
</form>`;

initialize(document.querySelector('form'));
Expand All @@ -83,9 +82,5 @@ describe('form-validation', () => {
expect(formatUnknownField.validationMessage).to.not.be.empty.and.not.match(
/^idv\.errors\.pattern_mismatch\./,
);

const formatField = screen.getByLabelText('format field');
await userEvent.type(formatField, 'a');
expect(formatField.validationMessage).to.equal('idv.errors.pattern_mismatch.zipcode');
});
});