-
Notifications
You must be signed in to change notification settings - Fork 53
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
Fix form validation when adding machine with multiple MACs. #963
Conversation
<label for="mac-address" class="p-form__label col-2" ng-class="{ 'is-required': mac === machine.macs[0] }"> | ||
<span data-ng-if="mac === machine.macs[0]">MAC Address</span> | ||
<label for="mac-address-{$ $index $}" class="p-form__label col-2" ng-class="{ 'is-required': mac === machine.macs[0] }"> | ||
<span data-ng-if="mac === machine.macs[0]">MAC Address</span> |
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.
perhaps I'm misunderstanding this, but won't this make an empty <label>
for the second and subsequent macs?
also instead of checking for === the first machine.macs can't we just use $first
? (re: https://docs.angularjs.org/api/ng/directive/ngRepeat )
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 agree I don't think we should have this conditional in the label content. It looks like it just determines if the field should be required or not.
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.
perhaps I'm misunderstanding this, but won't this make an empty for the second and subsequent macs?
That's exactly what it does!
also instead of checking for === the first machine.macs can't we just use $first? (re: https://docs.angularjs.org/api/ng/directive/ngRepeat )
That's definitely the smarter way to do this. Generally with the angular pages I try to only change the things that are actually causing bugs (e.g. the input validation, not the labels), because often fixing/improving the current code leads to completely unrelated things breaking. This seems pretty innocuous though.
<label for="mac-address" class="p-form__label col-2" ng-class="{ 'is-required': mac === machine.macs[0] }"> | ||
<span data-ng-if="mac === machine.macs[0]">MAC Address</span> | ||
<label for="mac-address-{$ $index $}" class="p-form__label col-2" ng-class="{ 'is-required': mac === machine.macs[0] }"> | ||
<span data-ng-if="mac === machine.macs[0]">MAC Address</span> |
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 agree I don't think we should have this conditional in the label content. It looks like it just determines if the field should be required or not.
0149847
to
bf8431c
Compare
Done
QA
Fixes
Fixes #905