Fixed problem removing automount keys and DNS records.

Due to a recent change the deleting automount keys and DNS records no
longer worked. The functions that are supposed to get the selected
values has been fixed to use the correct names and element type. They
also have been converted into methods of the search facets.

Ticket #2256
This commit is contained in:
Endi Sukma Dewata
2012-01-12 11:11:47 -06:00
committed by Petr Voborník
parent d50618f6bd
commit 3bfd49a465
3 changed files with 61 additions and 55 deletions

View File

@@ -71,12 +71,12 @@ IPA.automount.map_entity = function(spec) {
that.builder.containing_entity('automountlocation').
facet_groups([ 'automountkey', 'settings' ]).
nested_search_facet({
factory: IPA.automount.key_search_facet,
facet_group: 'automountkey',
nested_entity: 'automountkey',
pagination: false,
label: IPA.metadata.objects.automountkey.label,
name: 'keys',
get_values: IPA.get_option_values,
columns: [
{
factory: IPA.automount_key_column,
@@ -301,19 +301,28 @@ IPA.automountmap_adder_dialog = function(spec) {
return that;
};
IPA.get_option_values = function(){
IPA.automount.key_search_facet = function(spec) {
var values = [];
$('input[name="select"]:checked', this.table.tbody).each(function() {
var value = {};
$('span',$(this).parent().parent()).each(function(){
var name = this.attributes['name'].value;
var that = IPA.nested_search_facet(spec);
value[name] = $(this).text();
that.get_selected_values = function() {
var values = [];
$('input[name="description"]:checked', that.table.tbody).each(function() {
var value = {};
$('div', $(this).parent().parent()).each(function() {
var div = $(this);
var name = div.attr('name');
value[name] = div.text();
});
values.push(value);
});
values.push (value);
});
return values;
return values;
};
return that;
};
IPA.register('automountlocation', IPA.automount.location_entity);

View File

@@ -98,7 +98,6 @@ IPA.dns.zone_entity = function(spec) {
pagination: false,
title: IPA.metadata.objects.dnszone.label_singular,
label: IPA.metadata.objects.dnsrecord.label,
get_values: IPA.dnsrecord_get_delete_values,
columns: [
{
name: 'idnsname',
@@ -485,6 +484,46 @@ IPA.dns.record_search_facet = function(spec) {
}
};
that.get_selected_values = function() {
var values = [];
var records = {};
var value;
var record_type;
$('input[name="idnsname"]:checked', that.table.tbody).each(function() {
$('div', $(this).parent().parent()).each(function() {
var div = $(this);
var name = div.attr('name');
var text = div.text();
if (name === 'idnsname') {
value = records[text];
if (!value) {
value = { pkey: text };
records[text] = value;
}
} else if (name === 'type') {
record_type = text.toLowerCase()+'record';
} else if (name === 'data') {
if (!value[record_type]) {
value[record_type] = text;
} else {
value[record_type] += ',' + text;
}
}
});
});
for (var key in records) {
values.push(records[key]);
}
return values;
};
return that;
};
@@ -864,42 +903,6 @@ IPA.widget_factories['force_dnszone_add_checkbox'] = IPA.force_dnszone_add_check
IPA.field_factories['force_dnszone_add_checkbox'] = IPA.checkbox_field;
IPA.dnsrecord_get_delete_values = function() {
var records = {};
var value;
var record_type;
$('input[name="select"]:checked', this.table.tbody).each(function() {
$('span',$(this).parent().parent()).each(function(){
var name = this.attributes['name'].value;
if (name === 'idnsname'){
value = records[$(this).text()];
if (!value){
value = {pkey:$(this).text()};
records[$(this).text()] = value;
}
}else if (name === 'type'){
record_type = $(this).text();
}else if (name === 'data'){
if (!value[record_type]){
value[record_type] = $(this).text();
}else{
value[record_type] += "," + $(this).text();
}
}
});
});
var value_array = [];
for (var key in records){
value_array.push(records[key]);
}
return value_array;
};
IPA.ip_address_validator = function(spec) {
spec = spec || {};

View File

@@ -38,12 +38,6 @@ IPA.search_facet = function(spec) {
var that = IPA.table_facet(spec);
function get_values() {
return that.table.get_selected_values();
}
that.get_values = spec.get_values || get_values;
var init = function() {
that.init_table(that.managed_entity);
@@ -127,7 +121,7 @@ IPA.search_facet = function(spec) {
that.show_remove_dialog = function() {
var values = that.get_values();
var values = that.get_selected_values();
var title;
if (!values.length) {