Skip to content
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

Merged
merged 19 commits into from
Apr 18, 2022

Conversation

Olya-web7
Copy link
Contributor

['Редагування закладу' page] 'Далі' button stays enabled when mandatory field is empty #905

@Olya-web7 Olya-web7 requested a review from dmitryy90 April 10, 2022 10:36
Comment on lines 154 to 162
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);
Copy link
Contributor

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

@Olya-web7 Olya-web7 requested review from litvinets and dmitryy90 and removed request for dmitryy90 and litvinets April 12, 2022 08:10
Comment on lines 155 to 160
res.push(el)
res.push(el);
}
for (let elem in form?.get(el).value) {
if (form?.get(el).value[elem] === '') {
res.push(el);
}
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, pls check)

@Olya-web7 Olya-web7 requested a review from litvinets April 12, 2022 14:20
@Olya-web7 Olya-web7 requested review from litvinets and removed request for litvinets April 14, 2022 09:16
Comment on lines 153 to 157
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);
}
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Olya-web7 Olya-web7 merged commit 9064456 into develop Apr 18, 2022
@Olya-web7 Olya-web7 deleted the provider-contacts-btnnext branch April 18, 2022 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants