Project

General

Profile

« Previous | Next » 

Revision a576b23a

Added by Dominic Cleal about 8 years ago

fixes #14041 - don't call select2 on CR form templates

select2 must be called only when the select becomes visible, not for
hidden template elements. add_child_node() already does when adding a
new set of fields from the template. without_select2 is removed from
all CR volume fields and a typo from ce59b508 fixed to ensure the first,
default volume initialises select2 when a CR is selected.

The interface_type_selected function is fixed to only call select2 on
its elements instead of the entire page, which also broke the volume
form templates if a NIC type was changed.

(cherry picked from commit 26eeda8011cf1c16be9446625b201c36ebe70751)

View differences:

app/assets/javascripts/application.js
$.cookie('timezone', tz.name(), { path: '/', secure: location.protocol === 'https:' });
$('.full-value').SelectOnClick();
$('select:not(.without_select2)').select2({ allowClear: true });
activate_select2(':root');
$('input.remove_form_templates').closest('form').submit(function(event) {
$(this).find('.form_template').remove()
......
data: form,
success: function(response, status, xhr) {
$(div).html(response);
$('select').select2({ allowClear: true });
activate_select2(div);
},
error: function(jqXHR, textStatus, errorThrown) {
$(div).html('<div class="alert alert-warning alert-dismissable">' +
......
function reloadOnAjaxComplete(element) {
$(element).indicator_hide();
$('[rel="twipsy"]').tooltip();
$('select:not(.without_select2)').select2({ allowClear: true });
activate_select2(':root');
}
function set_fullscreen(element){
......
$(item).blur();
}
function activate_select2(container, allowClear) {
allowClear = typeof allowClear !== 'undefined' ? allowClear : true;
$(container).find('select:not(.without_select2)').
not('.form_template select').
not('#interfaceForms select').
select2({ 'allowClear': allowClear });
}
app/assets/javascripts/host_edit.js
$('#compute_resource_tab a').addClass('tab-error');
},
success: function(result){
$('#compute_resource').html(result).find('select:not(without_select2)').select2();
$('#compute_resource').html(result);
activate_select2('#compute_resource');
if ($('#compute_resource').find('.alert-danger').length > 0) $('#compute_resource_tab a').addClass('tab-error');
update_capabilities($('#capabilities').val());
}
......
subnet_options.attr('disabled', true);
}
reloadOnAjaxComplete(element);
subnet_options.filter('select').select2({allowClear: true})
activate_select2(subnet_options);
}
});
}
......
request.done(function() {
password_caps_lock_hint();
$("#interfaceModal").find('a[rel="popover-modal"]').popover();
$('select:not(.without_select2)').select2({ allowClear: true });
activate_select2('#interfaceModal');
});
}
app/assets/javascripts/host_edit_interfaces.js
modal_window.modal({'show': true});
modal_window.find('a[rel="popover-modal"]').popover();
modal_window.find('select:not(.without_select2)').select2({ allowClear: true });
activate_select2(modal_window);
}
function save_interface_modal() {
app/assets/javascripts/lookup_keys.js
$(item).closest("form").trigger({type: 'nested:fieldAdded', field: field});
$('a[rel="popover"]').popover();
$('a[rel="twipsy"]').tooltip();
$(field).find('select:not(.matcher_key)').select2();
activate_select2($(field).not('.matcher_key'));
return new_id;
}
app/views/compute_resources_vms/form/libvirt/_volume.html.erb
<%= selectable_f f, :pool_name, compute_resource.storage_pools.map(&:name), { }, :class => "col-md-2 without_select2", :label => _("Storage pool") %>
<%= selectable_f f, :pool_name, compute_resource.storage_pools.map(&:name), { }, :class => "col-md-2", :label => _("Storage pool") %>
<%= text_f f, :capacity, :class => "col-md-2", :label => _("Size (GB)"), :onchange => 'capacity_edit(this)' %>
<%= allocation_text_f f %>
<%= select_f f, :format_type, %w[RAW QCOW2],:downcase, :to_s, { }, :class => "col-md-2 without_select2", :label => _("Type") %>
<%= select_f f, :format_type, %w[RAW QCOW2],:downcase, :to_s, { }, :class => "col-md-2", :label => _("Type") %>
app/views/compute_resources_vms/form/ovirt/_volume.html.erb
<%= text_f f,:size_gb, :label => _('Size (GB)'), :disabled => !new_host, :class => "col-md-2" %>
<%= f.hidden_field :size_gb if !new_host %>
<%= select_f f, :storage_domain, compute_resource.storage_domains, :id, :name,
{ }, :label => _('Storage domain'), :disabled => !new_host, :class => "col-md-2 without_select2" %>
{ }, :label => _('Storage domain'), :disabled => !new_host, :class => "col-md-2" %>
<%= f.hidden_field :storage_domain if !new_host %>
<%= f.hidden_field :id %>
app/views/compute_resources_vms/form/vmware/_volume.html.erb
<%= selectable_f f, :datastore, vsphere_datastores(compute_resource), { }, :class => "span5 without_select2", :label => _("Data store") %>
<%= selectable_f f, :datastore, vsphere_datastores(compute_resource), { }, :class => "span5", :label => _("Data store") %>
<%= text_f f, :name, :class => "col-md-2", :label => _("Name") %>
<%= text_f f, :size_gb,
:class => "col-md-2",
app/views/nic/_base_form.html.erb
{ :include_blank => accessible_subnets.any? ? true : _("No subnets")},
{ :disabled => accessible_subnets.empty? ? true : false,
:help_inline => :indicator,
:class => 'interface_subnet without_select2', :'data-url' => freeip_subnets_path } %>
:class => 'interface_subnet', :'data-url' => freeip_subnets_path } %>
<% end %>
<%= text_f f, :ip,
:class => :interface_ip,

Also available in: Unified diff