Merge pull request #1039 from dod-ccpo/user-profile-validation
User profile validation
This commit is contained in:
commit
5d8280b84d
@ -36,6 +36,7 @@ export default {
|
|||||||
month: this.initialmonth,
|
month: this.initialmonth,
|
||||||
year: this.initialyear,
|
year: this.initialyear,
|
||||||
name: this.nameTag,
|
name: this.nameTag,
|
||||||
|
showValidation: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -160,6 +161,8 @@ export default {
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onInput: function(e) {
|
onInput: function(e) {
|
||||||
|
this.showValidation = true
|
||||||
|
|
||||||
emitEvent('field-change', this, {
|
emitEvent('field-change', this, {
|
||||||
value: this.formattedDate,
|
value: this.formattedDate,
|
||||||
name: this.name,
|
name: this.name,
|
||||||
|
@ -36,7 +36,7 @@ export default {
|
|||||||
const showError = (this.initialErrors && this.initialErrors.length) || false
|
const showError = (this.initialErrors && this.initialErrors.length) || false
|
||||||
return {
|
return {
|
||||||
showError: showError,
|
showError: showError,
|
||||||
showValid: !showError && !!this.initialValue,
|
showValid: false,
|
||||||
validationError: this.initialErrors.join(' '),
|
validationError: this.initialErrors.join(' '),
|
||||||
value: this.initialValue,
|
value: this.initialValue,
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ export default {
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
insetForm: Boolean,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
data: function() {
|
data: function() {
|
||||||
@ -61,7 +60,7 @@ export default {
|
|||||||
this._checkIfValid({
|
this._checkIfValid({
|
||||||
value: this.value,
|
value: this.value,
|
||||||
invalidate: true,
|
invalidate: true,
|
||||||
showValidationIcon: !this.insetForm,
|
showValidationIcon: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (this.mask && this.validation !== 'email') {
|
if (this.mask && this.validation !== 'email') {
|
||||||
@ -103,6 +102,8 @@ export default {
|
|||||||
onBlur: function(e) {
|
onBlur: function(e) {
|
||||||
if (!(this.optional && e.target.value === '')) {
|
if (!(this.optional && e.target.value === '')) {
|
||||||
this._checkIfValid({ value: e.target.value.trim(), invalidate: true })
|
this._checkIfValid({ value: e.target.value.trim(), invalidate: true })
|
||||||
|
} else if (this.modified && !this.optional) {
|
||||||
|
this._checkIfValid({ value: e.target.value.trim(), invalidate: true })
|
||||||
}
|
}
|
||||||
this.value = e.target.value.trim()
|
this.value = e.target.value.trim()
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
:optional='{{ optional | string | lower }}'
|
:optional='{{ optional | string | lower }}'
|
||||||
inline-template>
|
inline-template>
|
||||||
|
|
||||||
<fieldset class="usa-input date-picker" v-bind:class="{ 'usa-input--success': isDateValid }">
|
<fieldset class="usa-input date-picker" v-bind:class="{ 'usa-input--success': isDateValid && showValidation }">
|
||||||
<legend>
|
<legend>
|
||||||
<div class="usa-input__title">
|
<div class="usa-input__title">
|
||||||
{{ label }}
|
{{ label }}
|
||||||
@ -76,8 +76,13 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="usa-form-group-date-ok" v-if="isDateValid">
|
<div v-if="showValidation">
|
||||||
{{ Icon("ok", classes="icon--green") }}
|
<div class="usa-form-group-date-ok" v-if="isDateValid">
|
||||||
|
{{ Icon("ok", classes="icon--green") }}
|
||||||
|
</div>
|
||||||
|
<div class="usa-form-group-date-ok" v-else>
|
||||||
|
{{ Icon("alert", classes="icon--red")}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
{% from "components/icon.html" import Icon %}
|
{% from "components/icon.html" import Icon %}
|
||||||
{% from "components/tooltip.html" import Tooltip %}
|
{% from "components/tooltip.html" import Tooltip %}
|
||||||
|
|
||||||
{% macro OptionsInput(field, tooltip, inline=False, label=True, show_validation=True, disabled=False, watch=False, optional=True) -%}
|
{% macro OptionsInput(
|
||||||
|
field,
|
||||||
|
tooltip,
|
||||||
|
inline=False,
|
||||||
|
label=True,
|
||||||
|
show_validation=True,
|
||||||
|
disabled=False,
|
||||||
|
watch=False,
|
||||||
|
optional=True) -%}
|
||||||
<optionsinput
|
<optionsinput
|
||||||
name='{{ field.name }}'
|
name='{{ field.name }}'
|
||||||
inline-template
|
inline-template
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
{% from "components/text_input.html" import TextInput %}
|
{% from "components/text_input.html" import TextInput %}
|
||||||
|
|
||||||
{% macro PhoneInput(phone_number, phone_ext, placeholder_phone="") %}
|
{% macro PhoneInput(phone_number, phone_ext, placeholder_phone="", phone_optional=True, extension_optional=True) %}
|
||||||
<div class='phone-input'>
|
<div class='phone-input'>
|
||||||
<div class='phone-input__phone'>
|
<div class='phone-input__phone'>
|
||||||
{{ TextInput(phone_number, placeholder=placeholder_phone, validation='usPhone') }}
|
{{ TextInput(phone_number, placeholder=placeholder_phone, validation='usPhone', optional=phone_optional) }}
|
||||||
</div>
|
</div>
|
||||||
<div class='phone-input__extension'>
|
<div class='phone-input__extension'>
|
||||||
{{ TextInput(phone_ext, validation='phoneExt')}}
|
{{ TextInput(phone_ext, validation='phoneExt', optional=extension_optional) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
@ -17,8 +17,7 @@
|
|||||||
optional=True,
|
optional=True,
|
||||||
showLabel=True,
|
showLabel=True,
|
||||||
watch=False,
|
watch=False,
|
||||||
show_validation=True,
|
show_validation=True) -%}
|
||||||
inset_form=False) -%}
|
|
||||||
|
|
||||||
<textinput
|
<textinput
|
||||||
v-cloak
|
v-cloak
|
||||||
@ -29,7 +28,6 @@
|
|||||||
{% if initial_value or field.data is not none %}initial-value='{{ initial_value or field.data }}'{% endif %}
|
{% if initial_value or field.data is not none %}initial-value='{{ initial_value or field.data }}'{% endif %}
|
||||||
{% if field.errors %}v-bind:initial-errors='{{ field.errors | list }}'{% endif %}
|
{% if field.errors %}v-bind:initial-errors='{{ field.errors | list }}'{% endif %}
|
||||||
v-bind:optional={{ optional|lower }}
|
v-bind:optional={{ optional|lower }}
|
||||||
v-bind:inset-form={{ inset_form|lower }}
|
|
||||||
key='{{ field.name }}'
|
key='{{ field.name }}'
|
||||||
:watch='{{ watch | string | lower }}'
|
:watch='{{ watch | string | lower }}'
|
||||||
inline-template>
|
inline-template>
|
||||||
|
@ -11,16 +11,16 @@
|
|||||||
<div class='panel__content'>
|
<div class='panel__content'>
|
||||||
<div class='form-row'>
|
<div class='form-row'>
|
||||||
<div class='form-col form-col--half'>
|
<div class='form-col form-col--half'>
|
||||||
{{ TextInput(form.first_name, validation='requiredField') }}
|
{{ TextInput(form.first_name, validation='requiredField', optional=False) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class='form-col form-col--half'>
|
<div class='form-col form-col--half'>
|
||||||
{{ TextInput(form.last_name, validation='requiredField') }}
|
{{ TextInput(form.last_name, validation='requiredField', optional=False) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ TextInput(form.email, validation='email') }}
|
{{ TextInput(form.email, validation='email', optional=False) }}
|
||||||
{{ PhoneInput(form.phone_number, form.phone_ext) }}
|
{{ PhoneInput(form.phone_number, form.phone_ext, phone_optional=False) }}
|
||||||
|
|
||||||
{{ OptionsInput(form.service_branch) }}
|
{{ OptionsInput(form.service_branch) }}
|
||||||
{{ OptionsInput(form.citizenship) }}
|
{{ OptionsInput(form.citizenship) }}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
{{ portfolio_form.csrf_token }}
|
{{ portfolio_form.csrf_token }}
|
||||||
<div class='form-row'>
|
<div class='form-row'>
|
||||||
<div class='form-col form-col--half'>
|
<div class='form-col form-col--half'>
|
||||||
{{ TextInput(portfolio_form.name, validation="portfolioName", inset_form=True) }}
|
{{ TextInput(portfolio_form.name, validation="portfolioName") }}
|
||||||
</div>
|
</div>
|
||||||
<div class='edit-portfolio-name action-group'>
|
<div class='edit-portfolio-name action-group'>
|
||||||
{{ SaveButton(text='Save', additional_classes='usa-button-big') }}
|
{{ SaveButton(text='Save', additional_classes='usa-button-big') }}
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
</p>
|
</p>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-col form-col--two-thirds">
|
<div class="form-col form-col--two-thirds">
|
||||||
{{ TextInput(application_form.name, inset_form=True) }}
|
{{ TextInput(application_form.name) }}
|
||||||
{{ TextInput(application_form.description, paragraph=True, inset_form=True) }}
|
{{ TextInput(application_form.description, paragraph=True) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="form-col form-col--third">
|
<div class="form-col form-col--third">
|
||||||
{% if user_can(permissions.DELETE_APPLICATION) %}
|
{% if user_can(permissions.DELETE_APPLICATION) %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user