Bug 1447442 - Default value of dynamic dropdown list not honored CloudForms 4.2
Summary: Default value of dynamic dropdown list not honored CloudForms 4.2
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Automate
Version: 5.7.0
Hardware: All
OS: All
high
high
Target Milestone: GA
: 5.9.0
Assignee: eclarizi
QA Contact: Shveta
URL:
Whiteboard: dialog
Depends On:
Blocks: 1448419 1448421
TreeView+ depends on / blocked
 
Reported: 2017-05-02 19:55 UTC by myoder
Modified: 2020-07-16 09:31 UTC (History)
11 users (show)

Fixed In Version: 5.9.0.1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1448419 1448421 (view as bug list)
Environment:
Last Closed: 2018-03-06 14:32:50 UTC
Category: Bug
Cloudforms Team: CFME Core
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
dynamic_dropdown (4.02 KB, application/x-gzip)
2017-05-12 18:25 UTC, Ryan Spagnola
no flags Details

Description myoder 2017-05-02 19:55:13 UTC
Description of problem:
We have a Service Dialog that is launched from a button on a VM that has several dynamic dropdown lists. This dropdowns are percentages from 0 to 100.

The $evm.object['values'] hash that is dynamically generated has keys that are integers (e.g. 0, 5, 10, etc.). We also set $evm.object['default_value'] to one of the percentages if a value has previously been saved as a custom attribute on the VM.

In CF 4.1 when the dialog is loaded the dropdown lists correctly show the default percentages. In CF 4.2 the $evm.object['default_value'] is not honored and "0 %" is always shown.

If the keys on the $evm.object['values'] hash are changed to strings (e.g. "0", "5", "10", etc.) then the $evm.object['default_value'] is honored and the correct value is shown as the default.

$evm.object['data_type'] is set to integer.


Version-Release number of selected component (if applicable):
CFME 5.7.2.1

How reproducible:
Always

Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Looks similar to bug 1439942:
 https://bugzilla.redhat.com/show_bug.cgi?id=1439942

Comment 2 eclarizi 2017-05-03 18:03:26 UTC
I've determined the cause, and until we can get a fix out, the workaround to make the keys strings will work. They will still be submitted to the request as integers, because the data-type is set to integer, but currently the 'default_value' is always being treated as a string, so when comparing the string to the integer, it fails.

Is it feasible to continue with this workaround for now until I can get a proper fix put together?

Comment 4 CFME Bot 2017-05-04 20:41:14 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/830dc8ab3a09a40bb5e1632111d07fb9d6e9f2cf

commit 830dc8ab3a09a40bb5e1632111d07fb9d6e9f2cf
Author:     Erik Clarizio <eclarizi>
AuthorDate: Thu May 4 09:23:12 2017 -0700
Commit:     Erik Clarizio <eclarizi>
CommitDate: Thu May 4 10:12:57 2017 -0700

    Coerce default_value for sorted items into appropriate type
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1447442

 app/models/dialog_field_sorted_item.rb          |  9 +++--
 spec/models/dialog_field_drop_down_list_spec.rb | 52 +++++++++++++++++++++----
 2 files changed, 51 insertions(+), 10 deletions(-)

Comment 7 Shveta 2017-05-11 23:05:16 UTC
Can you please attach the dialog and dynamic method used .
Thanks, 
Shveta

Comment 8 Ryan Spagnola 2017-05-12 18:25:36 UTC
Created attachment 1278295 [details]
dynamic_dropdown

Attached the dynamic dropdown provided by the customer

Comment 9 Shveta 2017-10-18 18:47:53 UTC
Default value is stored in 5.9.0.2.20171010190026_0413a06


Note You need to log in before you can comment on or make changes to this bug.