-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
['Редагування закладу' page] 'Далі' button stays enabled when mandatory field is empty #905 Contacts #1048
Conversation
if ((!form.get(el).value | ||
&& form.get(el).status !== 'VALID') | ||
|| (form?.get(el).value.street === '' | ||
|| form?.get(el).value.buildingNumber === '' | ||
|| form?.get(el).value.city === '' | ||
|| form?.get(el).value.district === '' | ||
|| form?.get(el).value.region === '') | ||
) { | ||
res.push(el); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can simplify it, use for example find
and go via controls to fins the first unvalid
res.push(el) | ||
res.push(el); | ||
} | ||
for (let elem in form?.get(el).value) { | ||
if (form?.get(el).value[elem] === '') { | ||
res.push(el); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think you can simplify it even more
So, the button should be disabled if one of the required fields is not filled
then do via the form required controls and look for the FIRST invalid/empty control. You can combine the conditions in one row. Plus, you do not need to find all invalid cases, right? If there is at least one, then it is enough for disabling. Use find/some methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, pls check)
…cial-projects/OoS-Frontend into provider-contacts-btnnext
…cial-projects/OoS-Frontend into provider-contacts-btnnext
…cial-projects/OoS-Frontend into provider-contacts-btnnext
for (let el in form?.controls) { | ||
if (!form.get(el).value && form.get(el).status !== 'VALID') { | ||
res.push(el) | ||
} | ||
if ((!form.get(el).value && form.get(el).status !== 'VALID') | ||
|| Object.values(form.get(el).value).some(el => el === '')) { | ||
res.push(el); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (let el in form.controls) {
return (!form.get(el).value && form.get(el).status !== 'VALID') || Object.values(form.get(el).value).some(el => el === '')
}
try this one, I think it should works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
['Редагування закладу' page] 'Далі' button stays enabled when mandatory field is empty #905