From e6fd32f6124bd8efc3bc8fb4ed3e83ed0c0f8a1f Mon Sep 17 00:00:00 2001 From: dandds Date: Mon, 25 Mar 2019 13:36:54 -0400 Subject: [PATCH] phone number should be optional on add new portfolio member form --- js/components/text_input.js | 7 ++++++- templates/components/text_input.html | 4 +++- templates/portfolios/admin.html | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/js/components/text_input.js b/js/components/text_input.js index 98234f4d..bedc508c 100644 --- a/js/components/text_input.js +++ b/js/components/text_input.js @@ -25,6 +25,7 @@ export default { }, paragraph: String, noMaxWidth: String, + optional: Boolean, }, data: function() { @@ -82,7 +83,9 @@ export default { }, onBlur: function(e) { - this._checkIfValid({ value: e.target.value.trim(), invalidate: true }) + if (!(this.optional && e.target.value === "")) { + this._checkIfValid({ value: e.target.value.trim(), invalidate: true }) + } this.value = e.target.value.trim() if (this.validation === 'dollars') { @@ -97,6 +100,8 @@ export default { if (!this.modified && this.initialErrors && this.initialErrors.length) { valid = false + } else if (this.optional && value == "") { + valid = true } if (this.modified) { diff --git a/templates/components/text_input.html b/templates/components/text_input.html index 3f444c4c..64ab1a1f 100644 --- a/templates/components/text_input.html +++ b/templates/components/text_input.html @@ -13,7 +13,8 @@ disabled=False, initial_value='', classes='', - noMaxWidth=False) -%} + noMaxWidth=False, + optional=False) -%} diff --git a/templates/portfolios/admin.html b/templates/portfolios/admin.html index 76eb64bb..962f8843 100644 --- a/templates/portfolios/admin.html +++ b/templates/portfolios/admin.html @@ -81,7 +81,7 @@ {{ TextInput(member_form.email, validation='email') }}
- {{ TextInput(member_form.phone_number, validation='usPhone') }} + {{ TextInput(member_form.phone_number, validation='usPhone', optional=True) }}