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

Fixes #27478 - extract onchange event handlers #6945

Merged
merged 1 commit into from
Sep 21, 2019

Conversation

ezr-ondrej
Copy link
Member

No description provided.

@theforeman-bot
Copy link
Member

Issues: #27478

$(document).on('change', '#host_hostgroup_id', function(evt) {
hostgroup_changed(evt.target);
});
$(document).on('change', '#host_compute_resource_id, #compute_profile', function(evt) {
Copy link
Member

Choose a reason for hiding this comment

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

are we certain there are no other matching elements anywhere in foreman or any of the plugins?

Copy link
Member Author

Choose a reason for hiding this comment

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

should be as it is purpose of ID, but fair point... I can find some unique parent.

Copy link
Contributor

@sharvit sharvit left a comment

Choose a reason for hiding this comment

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

app/assets/javascripts/host_edit.js Outdated Show resolved Hide resolved
app/views/common/os_selection/_initial.html.erb Outdated Show resolved Hide resolved
$(document)
.on('change', '.hostgroup-select', function(evt) {
hostgroup_changed(evt.target);
}).on('change', '.host-form-compute-resource-handle', function(evt) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference between select suffix and handle suffix?
Aren't they all selects?

Copy link
Member Author

Choose a reason for hiding this comment

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

The handle class is used more than once 🤔
I am terrible with naming... any ideas?

Copy link
Contributor

Choose a reason for hiding this comment

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

What about something like this? (not sure if it's the right syntax)

Suggested change
}).on('change', '.host-form-compute-resource-handle', function(evt) {
}).on('change', '.host-form-compute-resource-select, .host-form-compute-profile-select', function(evt) {

@@ -23,7 +23,7 @@

<div class="tab-pane active" id="primary">
<%= select_f(f, :parent_id, parent_hostgroups, :id, :to_label, {:include_blank => true}, {:label => _('Parent'),
:onchange => 'hostgroup_changed(this);', :'data-url'=> process_hostgroup_hostgroups_path,
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

@ezr-ondrej ezr-ondrej Aug 6, 2019

Choose a reason for hiding this comment

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

yeah, I meant to rewrite it, but it slipped my fingers 🙄 🤦‍♂️
(:arrow_down:)

@ezr-ondrej
Copy link
Member Author

@amirfefer can you take a look, so we can merge the webcomponents?

Copy link
Member

@amirfefer amirfefer left a comment

Choose a reason for hiding this comment

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

Tested, works but somehow .host-form-compute-resource-handle's change event triggers right after other events (i.e after changing a taxonomy)

@theforeman-bot theforeman-bot added Waiting on contributor Legacy JS PRs making changes in the legacy Javascript stack and removed Needs re-review labels Sep 10, 2019
@ezr-ondrej
Copy link
Member Author

Tested, works but somehow .host-form-compute-resource-handle's change event triggers right after other events (i.e after changing a taxonomy)

This seems to be intentional, not an regression and it got called only when compute resource is 'Bare Metal':

host_compute_resource_id.change();

in such case the event is just ensuring the VM related fields are hidden.

amirfefer
amirfefer previously approved these changes Sep 10, 2019
Copy link
Member

@amirfefer amirfefer left a comment

Choose a reason for hiding this comment

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

Thanks @ezr-ondrej LGTM !

sharvit
sharvit previously approved these changes Sep 15, 2019
Copy link
Contributor

@sharvit sharvit left a comment

Choose a reason for hiding this comment

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

Thanks @ezr-ondrej

@mmoll mmoll dismissed stale reviews from sharvit and amirfefer via de83d76 September 21, 2019 11:37
@mmoll
Copy link
Contributor

mmoll commented Sep 21, 2019

[test foreman]

@mmoll mmoll merged commit 6af08b0 into theforeman:develop Sep 21, 2019
@mmoll
Copy link
Contributor

mmoll commented Sep 21, 2019

merged, díky @ezr-ondrej!

@ezr-ondrej ezr-ondrej deleted the obfuscate_select2_onchange branch September 23, 2019 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Legacy JS PRs making changes in the legacy Javascript stack Needs testing
Projects
None yet
6 participants