Project

General

Profile

Actions

Refactor #12395

open

Improve AJAX handling in host and hostgroup form

Added by Tomer Brisker over 8 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Web Interface
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

There is some code that adds the host or hostgroup id parameters to ajax requests refreshing parts of the host[group] form:

if (url.match('hostgroups')) {
  data = data + '&hostgroup_id=' + host_id
} else {
  data = data + '&host_id=' + host_id
}

(for example https://github.com/theforeman/foreman/blob/develop/app/assets/javascripts/host_edit.js#L190)
However, the preceding line is:
var data = $("form").serialize().replace('method=put', 'method=post');

which means that the host or hostgroup_id, if existing, is already present in the data variable. Therefor, this code can be removed from many places in the codebase with some minor changes to the relevant controllers, reducing code complexity.

No data to display

Actions

Also available in: Atom PDF