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 logic to correctly check 'display on button' checkbox #3383

Merged
merged 2 commits into from
Feb 15, 2018

Conversation

bmclaughlin
Copy link
Contributor

@bmclaughlin bmclaughlin commented Feb 7, 2018

@@ -70,7 +70,7 @@
= _('Text')
.col-md-8
= @record.name.split('|').first
- display = @record.set_data.key?(:display) ? @record.set_data[:display] : true
- display = @record.set_data.key?(:display) && @record.set_data[:display] == '1' ? true : false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't a plain

@record.set_data.key?(:display) && @record.set_data[:display]

suffice here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or @record.set_data.try(:[], :display)?

@@ -15,7 +15,8 @@
"data-miq_observe" => {:interval => '.5', :url => url}.to_json)
.input-group-addon
%label.checkbox-inline
= check_box_tag("display", "1", @edit[:new][:display],
- display = @record.set_data.key?(:display) && @record.set_data[:display] == '1' ? true : false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@bmclaughlin
Copy link
Contributor Author

@mzazrivec, Good catch, updated!

@miq-bot
Copy link
Member

miq-bot commented Feb 12, 2018

Checked commits bmclaughlin/manageiq-ui-classic@958518b~...86f69d1 with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 1 offense detected

**

  • 💣 💥 🔥 🚒 - Linter/Haml - Linter::Haml STDERR:
warning: parser/current is loading parser/ruby23, which recognizes
warning: 2.3.5-compliant syntax, but you are running 2.3.3.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.

@mzazrivec mzazrivec self-assigned this Feb 15, 2018
@mzazrivec mzazrivec added this to the Sprint 80 Ending Feb 26, 2018 milestone Feb 15, 2018
@mzazrivec mzazrivec merged commit 65241dd into ManageIQ:master Feb 15, 2018
@bmclaughlin bmclaughlin deleted the fix-display-on-button-behavior branch February 15, 2018 13:30
@himdel
Copy link
Contributor

himdel commented Feb 19, 2018

This PR breaks creating custom button groups for any entity...

  1. Go to /miq_ae_customization/explorer, Buttons accordion
  2. Select an entity type
  3. Configuration > Add a New Button Group
Error caught: [ActionView::Template::Error] undefined method `key?' for nil:NilClass
/home/himdel/manageiq-ui-classic/app/views/shared/buttons/_group_form.html.haml:18:in `__home_himdel_manageiq_ui_classic_app_views_shared_buttons__group_form_html_haml___609203824699480359_47349268667640'
...
/home/himdel/manageiq-ui-classic/app/views/shared/buttons/_ab_list.html.haml:114:in `__home_himdel_manageiq_ui_classic_app_views_shared_buttons__ab_list_html_haml__3055858347431745674_70219509216400'
...
/home/himdel/manageiq-ui-classic/app/controllers/miq_ae_customization_controller.rb:365:in `block in render_proc'
/home/himdel/manageiq-ui-classic/app/controllers/miq_ae_customization_controller.rb:430:in `setup_presenter_for_ab_tree'
/home/himdel/manageiq-ui-classic/app/controllers/miq_ae_customization_controller.rb:397:in `setup_presenter_based_on_active_tree'
/home/himdel/manageiq-ui-classic/app/controllers/miq_ae_customization_controller.rb:258:in `replace_right_cell'
/home/himdel/manageiq-ui-classic/app/controllers/application_controller/buttons.rb:685:in `group_new_edit'
/home/himdel/manageiq-ui-classic/app/controllers/application_controller/buttons.rb:15:in `ab_group_new'
/home/himdel/manageiq-ui-classic/app/controllers/application_controller/explorer.rb:201:in `generic_x_button'
/home/himdel/manageiq-ui-classic/app/controllers/miq_ae_customization_controller.rb:44:in `x_button'

Looks like @record.set_data is always nil in _group_form.html.haml

EDIT: fixed in #3431

@himdel
Copy link
Contributor

himdel commented Feb 20, 2018

When backporting to gaprindashvili, please backport together with #3431.

simaishi pushed a commit that referenced this pull request Mar 8, 2018
Fix logic to correctly check 'display on button' checkbox
(cherry picked from commit 65241dd)

https://bugzilla.redhat.com/show_bug.cgi?id=1553214
@simaishi
Copy link
Contributor

simaishi commented Mar 8, 2018

Gaprindashvili backport details:

$ git log -1
commit 471232b2d2100831bcf3039b8518ccfb3c5bc822
Author: Milan Zázrivec <mzazrivec@redhat.com>
Date:   Thu Feb 15 12:58:00 2018 +0100

    Merge pull request #3383 from bmclaughlin/fix-display-on-button-behavior
    
    Fix logic to correctly check 'display on button' checkbox
    (cherry picked from commit 65241dd33dfa21d66d15d41ff2c680ac4686afdc)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1553214

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.

6 participants