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

Fix form validation when adding machine with multiple MACs. #963

Merged
merged 1 commit into from
Apr 9, 2020

Conversation

Caleb-Ellis
Copy link
Contributor

Done

  • Fixed form validation for extra MACs fields when adding new machine.

QA

  • Go to angular machine list > Add hardware > Machine and add extra macs
  • Type into the macs fields and check that they validate correctly (just a red border in Vanilla 2.0.1)

Fixes

Fixes #905

<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>&nbsp;
<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>
Copy link
Contributor

@sparkiegeek sparkiegeek Apr 8, 2020

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 )

Copy link
Contributor

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.

Copy link
Contributor Author

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!

Screenshot_2020-04-09 Machines bolla MAAS

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>&nbsp;
<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>
Copy link
Contributor

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.

@Caleb-Ellis Caleb-Ellis merged commit 0de4095 into canonical:master Apr 9, 2020
@Caleb-Ellis Caleb-Ellis deleted the multiple-macs branch April 9, 2020 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot add mutiple MAC addresses in GUI
3 participants