ManageIQ / ui-components

Angular UI Components for ManageIQ
Apache License 2.0
16 stars 52 forks source link

DialogUser - convert single-select default_value to the right data_type #402

Closed himdel closed 5 years ago

himdel commented 5 years ago

Introduced in https://github.com/ManageIQ/ui-components/pull/394, we now require default_value's type to match the types of keys in values.

But:

So now, all of these get converted (on load) to the type in data_type:

The conversion rules are as follow:

A side effect of this change is that 0 gets treated as a valid default dropdown option, so a first option with 0 value will now always get sorted first, whereas previously, this treatment would only apply to non-numeric or null.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1729046

gmcculloug commented 5 years ago

@miq-bot add_reviewer @eclarizio

himdel commented 5 years ago

Ok, @eclarizio if you can (re)review, I think this should be ready, and the description matches the current state.

(I'd still like to write some tests, just to make sure the behaviour is also tested with weird values, not only the strictly valid ones)

himdel commented 5 years ago

Thanks :) Fixed a couple more tests which were failing because of the 0 thing.

And maybe I'll leave the other tests for a separate PR so that we can merge & build.

eclarizio commented 5 years ago

Yeah that seems fine to me. Nice 👍

miq-bot commented 5 years ago

Checked commits https://github.com/himdel/ui-components/compare/135048cb8b05d5ab43bfc1ef9f196928beefb8d6~...6f3ccce40d2aa812a71e0ce7c28433792d085443 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 0 files checked, 0 offenses detected Everything looks fine. :cake:

simaishi commented 5 years ago

Hammer backport details:

$ git log -1
commit 2fbdd510fd60cba955839abad2265804a8627f18
Author: Harpreet Kataria <hkataria@redhat.com>
Date:   Fri Jul 12 14:32:00 2019 -0400

    Merge pull request #402 from himdel/integer-single-bz1729046

    DialogUser - convert single-select default_value to the right data_type

    (cherry picked from commit 8b48923eeee45c72ced0d34807f747ce98c1ff2f)

    https://bugzilla.redhat.com/show_bug.cgi?id=1729594