-
Notifications
You must be signed in to change notification settings - Fork 898
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
Adds field unique validator check to dialog #16487
Conversation
@miq-bot assign @gmcculloug |
@miq-bot add_label bug |
app/models/dialog_group.rb
Outdated
@@ -38,6 +38,10 @@ def validate_children | |||
errors.add(:base, _("Box %{box_label} must have at least one Element") % {:box_label => label}) | |||
end | |||
|
|||
if dialog_fields.collect(&:name).duplicates.present? | |||
errors.add(:base, _("Dialog field name cannot be duplicated on a dialog: %{duplicates}") % {:duplicates => dialog_fields.collect(&:name).duplicates.join(', ')}) |
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.
This does not belong on the group object since dialog_fields
would only validate objects in that group and not the entire dialog.
adb28df
to
c238ee0
Compare
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.
Looks to me like it should do the job 👍
@eclarizio The problem with this currently is that we have no flash messages in new dialog editor, so this error is never shown anywhere. |
@d-m-u Right, I realize that's why it's marked as WIP, but just wanted to give the 👍 approval for if/when the UI side gets sorted out. |
@miq-bot add_label bug |
app/models/dialog.rb
Outdated
@@ -61,6 +61,10 @@ def validate_children | |||
errors.add(:base, _("Dialog %{dialog_label} must have at least one Tab") % {:dialog_label => label}) | |||
end | |||
|
|||
if dialog_fields.collect(&:name).duplicates.present? |
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.
@d-m-u Set dialog_fields.collect(&:name).duplicates
to a variable so we do not need to call it twice if there are duplicates.
c238ee0
to
eeace51
Compare
Checked commit d-m-u@eeace51 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 |
|
@simaishi I set the |
Adds field unique validator check to dialog (cherry picked from commit ece6e89) https://bugzilla.redhat.com/show_bug.cgi?id=1518267
Gaprindashvili backport details:
|
This adds a uniqueness check on dialog field names (from this bz: https://bugzilla.redhat.com/show_bug.cgi?id=1491790) so we don't end up with dialogs with two equal field names which goes kaput.
Linked PR adds back in flash messages on dialog edit screen that went kaput when new dialog editor came online. Without it, this check fails silently and is yuck.
Will be a terrible experience unless this gets in soon too: ( 🎉 )
ManageIQ/manageiq-ui-classic#2772
(and by soon I mean basically at the same time)