Revision 92ea9c3b
Added by Joseph Magen almost 10 years ago
app/helpers/application_helper.rb | ||
---|---|---|
environment.puppetclasses.map(&:id).include?(puppetclass.id)
|
||
end
|
||
|
||
def show_parent?(obj)
|
||
(obj.new_record? && obj.class.count > 0) || (!obj.new_record? && obj.class.count > 1)
|
||
end
|
||
|
||
private
|
||
def edit_inline(object, property, options={})
|
||
name = "#{type}[#{property}]"
|
app/views/hostgroups/_form.html.erb | ||
---|---|---|
<div class="tab-content">
|
||
|
||
<div class="tab-pane active" id="primary">
|
||
<%= select_f f, :parent_id, accessible_hostgroups, :id, :to_label, {:include_blank => true}, {:label => _('Parent'),
|
||
<%= select_f(f, :parent_id, accessible_hostgroups, :id, :to_label, {:include_blank => true}, {:label => _('Parent'),
|
||
:onchange => 'hostgroup_changed(this);', :'data-url'=> process_hostgroup_hostgroups_path,
|
||
:disabled => !@hostgroup.new_record?,
|
||
:help_inline => :indicator } %>
|
||
:help_inline => :indicator }) if show_parent?(@hostgroup) %>
|
||
<%= text_f f, :name %>
|
||
<%= select_f f, :environment_id, Environment.all, :id, :to_label, {:include_blank => blank_or_inherit_f(f, :environment)},
|
||
{:label => _("Environment"), :onchange => 'update_puppetclasses(this);', :"data-url" => environment_selected_hostgroups_path} %>
|
app/views/taxonomies/_form.html.erb | ||
---|---|---|
|
||
<%= form_for taxonomy do |f| %>
|
||
<%= base_errors_for taxonomy %>
|
||
<%= select_f f, :parent_id, taxonomy.class.where("id NOT IN (#{taxonomy.subtree_ids.join(',')})").order(:title), :id, :title, { :include_blank => true },
|
||
<%= select_f(f, :parent_id, taxonomy.class.where("id NOT IN (#{taxonomy.subtree_ids.join(',')})").order(:title), :id, :title, { :include_blank => true },
|
||
{ :label => _('Parent'), :onchange => 'parent_taxonomy_changed(this);',
|
||
:help_inline => :indicator,
|
||
:'data-url' => (controller_name == 'organizations' ? parent_taxonomy_selected_organization_path(taxonomy.id) :
|
||
parent_taxonomy_selected_location_path(taxonomy.id))
|
||
} %>
|
||
}) if show_parent?(taxonomy) %>
|
||
|
||
<%= text_f f, :name %>
|
||
<div class="form-group row">
|
app/views/taxonomies/_step1.html.erb | ||
---|---|---|
<%= form_for taxonomy do |f| %>
|
||
<%= base_errors_for taxonomy %>
|
||
<%= wizard_header 1, _("Create %s") % taxonomy.class.name, _("Select Hosts"), _("Edit Properties") %>
|
||
<%= select_f f, :parent_id, taxonomy.class.order(:title), :id, :title, { :include_blank => true }, { :label => _('Parent') } %>
|
||
<%= select_f(f, :parent_id, taxonomy.class.order(:title), :id, :title, { :include_blank => true }, { :label => _('Parent') }) if show_parent?(taxonomy) %>
|
||
<%= text_f f, :name %>
|
||
|
||
<%= submit_or_cancel f %>
|
Also available in: Unified diff
fixes #5809 - don't show parent location/organization/hostgroup select box if zero or one location/organization/hostgroup