Require defense component input before showing Save button

This commit is contained in:
richard-dds 2019-06-12 15:58:20 -04:00
parent 0bafa51bb9
commit 31d95e51bc
4 changed files with 15 additions and 5 deletions

View File

@ -17,6 +17,14 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
optional: Boolean
},
created: function() {
emitEvent('field-mount', this, {
optional: this.optional,
name: this.name,
})
}, },
data: function() { data: function() {
@ -31,13 +39,15 @@ export default {
methods: { methods: {
onInput: function(e) { onInput: function(e) {
this.showError = false
this.showValid = true
emitEvent('field-change', this, { emitEvent('field-change', this, {
value: e.target.value, value: e.target.value,
name: this.name, name: this.name,
watch: this.watch, watch: this.watch,
valid: this.showValid
}) })
this.showError = false
this.showValid = true
}, },
}, },
} }

View File

@ -15,7 +15,6 @@ export default {
handleFieldChange: function(event) { handleFieldChange: function(event) {
const { value, name, valid, parent_uid, watch } = event const { value, name, valid, parent_uid, watch } = event
if (typeof this.fields[name] !== undefined) { if (typeof this.fields[name] !== undefined) {
this[name] = value
this.fields[name] = valid this.fields[name] = valid
if (parent_uid === this._uid || watch) { if (parent_uid === this._uid || watch) {
this.changed = true this.changed = true

View File

@ -1,7 +1,7 @@
{% 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, disabled=False, watch=False) -%} {% macro OptionsInput(field, tooltip, inline=False, label=True, disabled=False, watch=False, optional=True) -%}
<optionsinput <optionsinput
name='{{ field.name }}' name='{{ field.name }}'
inline-template inline-template
@ -9,6 +9,7 @@
{% if field.data and field.data != "None" %}v-bind:initial-value="'{{ field.data }}'"{% endif %} {% if field.data and field.data != "None" %}v-bind:initial-value="'{{ field.data }}'"{% endif %}
key='{{ field.name }}' key='{{ field.name }}'
v-bind:watch='{{ watch | string | lower }}' v-bind:watch='{{ watch | string | lower }}'
v-bind:optional={{ optional|lower }}
> >
<div <div
v-bind:class="['usa-input', { 'usa-input--error': showError, 'usa-input--success': showValid }]"> v-bind:class="['usa-input', { 'usa-input--error': showError, 'usa-input--success': showValid }]">

View File

@ -14,7 +14,7 @@
{{ form.csrf_token }} {{ form.csrf_token }}
{{ TextInput(form.name) }} {{ TextInput(form.name) }}
{{ OptionsInput(form.defense_component) }} {{ OptionsInput(form.defense_component, optional=False) }}
{{ TextInput(form.description, paragraph=True) }} {{ TextInput(form.description, paragraph=True) }}
<h3 id="reporting" class="subheading">{{ "task_orders.new.app_info.project_title" | translate }}</h3> <h3 id="reporting" class="subheading">{{ "task_orders.new.app_info.project_title" | translate }}</h3>