Update validation icon placement and placeholders

This commit is contained in:
luis cielak 2018-08-14 15:03:59 -04:00 committed by luisgov
parent 483d606cf0
commit cda585c3a3
5 changed files with 70 additions and 18 deletions

View File

@ -18,7 +18,8 @@ export default {
type: String, type: String,
default: () => '' default: () => ''
}, },
initialErrors: Array initialErrors: Array,
paragraph: String
}, },
data: function () { data: function () {

View File

@ -7,31 +7,31 @@ export default {
mask: false, mask: false,
match: /^(?!\s*$).+/, match: /^(?!\s*$).+/,
unmask: [], unmask: [],
validationError: 'Please enter a response.' validationError: 'Please enter a response'
}, },
integer: { integer: {
mask: createNumberMask({ prefix: '', allowDecimal: false }), mask: createNumberMask({ prefix: '', allowDecimal: false }),
match: /^[1-9]\d*$/, match: /^[1-9]\d*$/,
unmask: [','], unmask: [','],
validationError: 'Please enter a number.' validationError: 'Please enter a number'
}, },
dollars: { dollars: {
mask: createNumberMask({ prefix: '$', allowDecimal: true }), mask: createNumberMask({ prefix: '$', allowDecimal: true }),
match: /^-?\d+\.?\d*$/, match: /^-?\d+\.?\d*$/,
unmask: ['$',','], unmask: ['$',','],
validationError: 'Please enter a dollar amount.' validationError: 'Please enter a dollar amount'
}, },
gigabytes: { gigabytes: {
mask: createNumberMask({ prefix: '', suffix:' GB', allowDecimal: false }), mask: createNumberMask({ prefix: '', suffix:' GB', allowDecimal: false }),
match: /^[1-9]\d*$/, match: /^[1-9]\d*$/,
unmask: [',',' GB'], unmask: [',',' GB'],
validationError: 'Please enter an amount of data in gigabytes.' validationError: 'Please enter an amount of data in gigabytes'
}, },
email: { email: {
mask: emailMask, mask: emailMask,
match: /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/, match: /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/,
unmask: [], unmask: [],
validationError: 'Please enter a valid e-mail address.' validationError: 'Please enter a valid e-mail address'
}, },
date: { date: {
mask: [/\d/,/\d/,'/',/\d/,/\d/,'/',/\d/,/\d/,/\d/,/\d/], mask: [/\d/,/\d/,'/',/\d/,/\d/,'/',/\d/,/\d/,/\d/,/\d/],
@ -39,18 +39,18 @@ export default {
unmask: [], unmask: [],
pipe: createAutoCorrectedDatePipe('mm/dd/yyyy HH:MM'), pipe: createAutoCorrectedDatePipe('mm/dd/yyyy HH:MM'),
keepCharPositions: true, keepCharPositions: true,
validationError: 'Please enter a valid date in the form MM/DD/YYYY.' validationError: 'Please enter a valid date in the form MM/DD/YYYY'
}, },
usPhone: { usPhone: {
mask: ['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/], mask: ['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/],
match: /^\d{10}$/, match: /^\d{10}$/,
unmask: ['(',')','-',' '], unmask: ['(',')','-',' '],
validationError: 'Please enter a 10-digit phone number.' validationError: 'Please enter a 10-digit phone number'
}, },
dodId: { dodId: {
mask: createNumberMask({ prefix: '', allowDecimal: false, includeThousandsSeparator: false }), mask: createNumberMask({ prefix: '', allowDecimal: false, includeThousandsSeparator: false }),
match: /^\d{10}$/, match: /^\d{10}$/,
unmask: [], unmask: [],
validationError: 'Please enter a 10-digit D.O.D. ID number.' validationError: 'Please enter a 10-digit DoD ID number'
} }
} }

View File

@ -74,11 +74,12 @@
.icon-validation { .icon-validation {
position: absolute; position: absolute;
left: 100%; // left: 0%;
top: 100%; top: 100%;
margin-top: 1.4rem; margin-top: 1.4rem;
margin-left: $gap; margin-left: $gap;
} }
} }
.usa-input__title { .usa-input__title {
@ -109,6 +110,7 @@
@include line-max; @include line-max;
margin: 0; margin: 0;
box-sizing: border-box; box-sizing: border-box;
max-width: 32em;
&:hover, &:hover,
&:focus { &:focus {
@ -173,7 +175,55 @@
.usa-input__message { .usa-input__message {
@include h5; @include h5;
display: inline-block; display: inline-block;
padding-top: $gap; }
&--validation {
&--anything,
&--email {
input {
max-width: 26em;
}
.icon-validation {
left: 26em;
}
}
&--paragraph {
.icon-validation {
left: 32em;
}
}
&--integer,
&--dollars,
&--gigabytes, {
input {
max-width: 16em;
}
.icon-validation {
left: 16em;
}
}
&--date,
&--usPhone {
input {
max-width: 10em;
}
.icon-validation {
left: 10em;
}
}
&--dodId {
input {
max-width: 18em;
}
.icon-validation {
left: 18em;
}
}
} }
&.usa-input--error { &.usa-input--error {

View File

@ -5,13 +5,14 @@
<textinput <textinput
name='{{ field.name }}' name='{{ field.name }}'
validation='{{ validation }}' validation='{{ validation }}'
{% if paragraph %}paragraph='true'{% endif %}
{% if field.data %}initial-value='{{ field.data }}'{% endif %} {% if field.data %}initial-value='{{ field.data }}'{% endif %}
{% if field.errors %}v-bind:initial-errors='{{ field.errors }}'{% endif %} {% if field.errors %}v-bind:initial-errors='{{ field.errors }}'{% endif %}
key='{{ field.name }}' key='{{ field.name }}'
inline-template> inline-template>
<div <div
v-bind:class="['usa-input usa-input--validation--' + validation, { 'usa-input--error': showError, 'usa-input--success': showValid }]"> v-bind:class="['usa-input usa-input--validation--' + validation, { 'usa-input--error': showError, 'usa-input--success': showValid, 'usa-input--validation--paragraph': paragraph }]">
<label for={{field.name}}> <label for={{field.name}}>
<div class="usa-input__title">{{ field.label | striptags }} {% if tooltip %}{{ Tooltip(tooltip) }}{% endif %}</div> <div class="usa-input__title">{{ field.label | striptags }} {% if tooltip %}{{ Tooltip(tooltip) }}{% endif %}</div>

View File

@ -28,7 +28,7 @@
{{ TextInput(f.jedi_usage, paragraph=True, placeholder="Briefly describe how you are expecting to use the JEDI Cloud. \n e.g. We are migrating XYZ application to the cloud so that...") }} {{ TextInput(f.jedi_usage, paragraph=True, placeholder="Briefly describe how you are expecting to use the JEDI Cloud. \n e.g. We are migrating XYZ application to the cloud so that...") }}
<h2>Cloud Readiness</h2> <h2>Cloud Readiness</h2>
{{ TextInput(f.num_software_systems,validation="integer",tooltip="A software system can be any code that you plan to host on cloud infrastructure. For example, it could be a custom-developed web application, or a large ERP system.",placeholder="42") }} {{ TextInput(f.num_software_systems,validation="integer",tooltip="A software system can be any code that you plan to host on cloud infrastructure. For example, it could be a custom-developed web application, or a large ERP system.",placeholder="0") }}
{{ OptionsInput(f.jedi_migration, tooltip="Cloud migration is the process of moving data, applications or other business elements from an organization\\'s onsite computers/data centers to the cloud, or moving them from one cloud environment to another.") }} {{ OptionsInput(f.jedi_migration, tooltip="Cloud migration is the process of moving data, applications or other business elements from an organization\\'s onsite computers/data centers to the cloud, or moving them from one cloud environment to another.") }}
<transition name='slide'> <transition name='slide'>
@ -54,7 +54,7 @@
</transition> </transition>
<h2>Financial Usage</h2> <h2>Financial Usage</h2>
{{ TextInput(f.estimated_monthly_spend, tooltip="Refer to financial verification step help docs", validation="dollars", placeholder="$42,000") }} {{ TextInput(f.estimated_monthly_spend, tooltip="Refer to financial verification step help docs", validation="dollars", placeholder="$0") }}
<div class='alert alert-info'> <div class='alert alert-info'>
<div class='alert__content'> <div class='alert__content'>
@ -68,14 +68,14 @@
<template v-if="annualSpend > 1000000"> <template v-if="annualSpend > 1000000">
<fieldset class='form__sub-fields'> <fieldset class='form__sub-fields'>
<h3>Because the approximate annual spend is over $1,000,000, please answer a few additional questions.</h3> <h3>Because the approximate annual spend is over $1,000,000, please answer a few additional questions.</h3>
{{ TextInput(f.number_user_sessions, validation='integer', placeholder="42") }} {{ TextInput(f.number_user_sessions, validation='integer', placeholder="0") }}
{{ TextInput(f.average_daily_traffic, tooltip="Requests are the client-to-server network traffic that is being transferred to your systems",validation="integer", placeholder="42") }} {{ TextInput(f.average_daily_traffic, tooltip="Requests are the client-to-server network traffic that is being transferred to your systems",validation="integer", placeholder="0") }}
{{ TextInput(f.average_daily_traffic_gb, tooltip="GB uploaded is the gigabyte amount of data traffic that is being transferred to your systems",validation="gigabytes", placeholder="42GB") }} {{ TextInput(f.average_daily_traffic_gb, tooltip="GB uploaded is the gigabyte amount of data traffic that is being transferred to your systems",validation="gigabytes", placeholder="0GB") }}
</fieldset> </fieldset>
</template> </template>
</transition> </transition>
{{ TextInput(f.dollar_value, validation='dollars', placeholder="$42,000") }} {{ TextInput(f.dollar_value, validation='dollars', placeholder="$0") }}
{{ TextInput(f.start_date, validation='date', placeholder='MM / DD / YYYY') }} {{ TextInput(f.start_date, validation='date', placeholder='MM / DD / YYYY') }}
</div> </div>