diff --git a/js/components/checkbox_input.js b/js/components/checkbox_input.js index db542fef..9236caf8 100644 --- a/js/components/checkbox_input.js +++ b/js/components/checkbox_input.js @@ -19,11 +19,20 @@ export default { } }, + created: function() { + emitEvent('field-mount', this, { + optional: this.optional, + name: this.name, + valid: this.isChecked, + }) + }, + methods: { onInput: function(e) { emitEvent('field-change', this, { value: e.target.checked, name: this.name, + valid: this.isChecked, }) }, }, diff --git a/js/mixins/form.js b/js/mixins/form.js index 01f2f24f..7ba7629d 100644 --- a/js/mixins/form.js +++ b/js/mixins/form.js @@ -1,6 +1,10 @@ export default { props: { initialSelectedSection: String, + hasChanges: { + type: Boolean, + default: false, + }, }, mounted: function() { @@ -44,6 +48,20 @@ export default { }, }, + computed: { + canSave: function() { + const formValid = !this.invalid + + if (formValid) { + return true + } else if (this.changed && formValid) { + return true + } else { + return false + } + }, + }, + data: function() { return { changed: this.hasChanges, @@ -51,11 +69,4 @@ export default { invalid: true, } }, - - props: { - hasChanges: { - type: Boolean, - default: false, - }, - }, } diff --git a/templates/task_orders/builder_base.html b/templates/task_orders/builder_base.html index e99aef9b..14c3eaa4 100644 --- a/templates/task_orders/builder_base.html +++ b/templates/task_orders/builder_base.html @@ -13,7 +13,7 @@